Grafana + Prometheus: Display single stat of how often an event occurred

Viewed 2527

How do I use Prometheus + Grafana to tell how many time an event occurs during a given time period?

I have a Prometheus counter that I increment every time this event happens. I would like to display it in a Singlestat number. It seems like this should be as simple as:

sum(increase(some_event_happened{application="example-app"}[$__range]))

And the display set to "Current" value.

However, this gives numbers that are much higher than the actual number of events in the given range. Also, it seems to vary based on how much I offset the range, and how large the range is.

More importantly, it crashes our Prometheus server with an out of memory error when I have three or four of these on a single dashboard.

I've tried setting a recorded rule to address the crashes, but I haven't figured out the right way to slice up the record rule to still be able to display the Grafana range.

So in summary, I want a Singlestat displaying the number of times an event happened in the current time range set in the Grafana dashboard. It seems like this is a very basic thing for a monitoring system. Am I just using the wrong approach?

1 Answers
Related