Search code examples
prometheuspromql

Ignoring effect of non-significant labels in PromQL


I had a prometheus metric upload_latency with single label device_id. In prometheus web UI, with query of 'upload_latency' i see different lines for each device_id.

Now to enhance debugging i have added another label msg_type. If i query 'upload_latency' now, it plots separate lines for each combination of device_id and msg_type. It helps when i want to visualize latency w.r.t. msg_type but not when i really just want to visualize collective latencies per device_id.

What i am looking for is a way to ignore the label msg_type so that i can plot the lines per device_id like earlier whenever needed.

Any comments appriciated. Thanks in advance!


Solution

  • You could try using an aggregation combined with without.

    Something like sum without (msg_type) upload_latency

    Whether you use sum or max or some other aggregator function depends on if data points with the same device id and different message type can happen at the same time or not. But either way, without should be helpful.

    Link to the relevant documentation: https://prometheus.io/docs/prometheus/latest/querying/operators/#aggregation-operators