strimzi / metrics-reporter

Prometheus Metrics Reporter for Apache Kafka server and client components
Apache License 2.0
5 stars 10 forks source link

Handle non-numeric metric values #8

Closed mimaison closed 5 months ago

mimaison commented 10 months ago

As per the proposal, non-numeric values should be handled the following way:

Out of all the metrics emitted by Kafka brokers and clients, a few of them have non-numeric values. Prometheus only supports numeric values for metrics. When using jmx_exporter it is possible to write rules that move the non-numeric value to a label. For example we do it in kafka-connect-metrics for the status metric which has a string value.

I propose to do this automatically in the reporters. For example a metric named: kafka.connect:type=connector-task-metrics,connector="{connector}",task="{task}"<>status with the value running will be converted into kafka_connect_connector_task_metrics_status{connector="heartbeats",task="0",status="running"} and its value will be set to 1.0.

mimaison commented 5 months ago

Done in https://github.com/strimzi/metrics-reporter/pull/21