Search code examples
prometheusmonitoringmetricspromql

Sum all counter by one lablel - prometheus


Hi everybody I have an error counter that gives me metrics like below, I want to get a total sum of each error reason in the last 7 days. I've tried using increase but it seems that the increase function doesn't support by/without operators so I get results including machine_type.

How can I not include machine_type in the query result?

{instance="localhost:8000", job="prometheus", reason="Some_reason", machine_type="gpu"}

This is what I've tried increase(error_count_total[24h]) And results are

{instance="localhost:8000", job="prometheus", reason="Some_reason", machine_type="gpu"}: 15
{instance="localhost:8000", job="prometheus", reason="Some_reason", machine_type="cpu"}: 10

And I want to get

{instance="localhost:8000", job="prometheus", reason="Some_reason"}: 25

Solution

  • Try the following query:

    sum without (machine_type) (increase(error_count_total[24h]))