Brent
Brent

Reputation: 239

How to generate an average in Prometheus

I have two counters. One is a measurement accumulator and another is the count of measurements. How do I generate a range vector average?

I've tried the following but got null results.

rate(my_events{type="sum"}[60s]) / rate(my_events{type="count"}[60s])

I want to generate a vector that I can put into a Grafana graph to plot the average over time.

Upvotes: 3

Views: 2792

Answers (1)

brian-brazil
brian-brazil

Reputation: 34172

You're onto the right idea, what you'd do is:

rate(my_events{type="sum"}[60s]) / ignoring(type) rate(my_events{type="count"}[60s])

However the canonical way of exporting and thus using this data is:

rate(my_events_sum[60s]) / rate(my_events_count[60s])

Which you can do with a Summary or Histogram.

Upvotes: 5

Related Questions