The current statsd reporter can only report a subset of Flink metrics owing to the manner in which Flink variables are handled, mainly around invalid characters and metrics too long. As an option, it would be quite useful to have a stricter dogstatsd compliant output. Dogstatsd metrics are tagged, should be less than 200 characters including tag names and values, be alphanumeric + underbar, delimited by periods. As a further pragmatic restriction, negative and other invalid values should be ignored rather than sent to the backend. These restrictions play well with a broad set of collectors and time series databases.
This mode would:
- convert output to ascii alphanumeric characters with underbar, delimited by periods. Runs of invalid characters within a metric segment would be collapsed to a single underbar.
- report all Flink variables as tags
- compress overly long segments, say over 50 chars, to a symbolic representation of the metric name, to preserve the unique metric time series but avoid downstream truncation
- compress 32 character Flink IDs like tm_id, task_id, job_id, task_attempt_id, to the first 8 characters, again to preserve enough distinction amongst metrics while trimming up to 96 characters from the metric
- remove object references from names, such as the instance hash id of the serializer
- drop negative or invalid numeric values such as "n/a", "-1" which is used for unknowns like JVM.Memory.NonHeap.Max, and "-9223372036854775808" which is used for unknowns like currentLowWaterMark
With these in place, it becomes quite reasonable to support LatencyGauge metrics as well.
One idea for symbolic compression is to take the first 10 valid characters plus a hash of the long name. For example, a value like this operator_name:
would first drop the instance references. The stable version would be:
and then the compressed name would be the first ten valid characters plus the hash of the stable string:
This is just one way of dealing with unruly default names, the main point would be to preserve the metrics so they are valid, avoid truncation, and can be aggregated along other dimensions even if this particular dimension is hard to parse after the compression.