2

I have a counter metric app_events_total that I am using to track events in my system. The metric has a label named "event" that contains the name of the event.

I would like to create a panel in my dashboard that shows a pie chart of the event counts that have occurred within the specified time range. A slice of the pie for each event name that occurred within the specified range. This is what I have so far.

sum(increase(app_events_total[$__range])) by (event)

The problem is that this is showing event counts in the thousands, even hundreds of thousands, for time ranges that should have no events whatsoever. I'm very stumped by this, any help is greatly appreciated.

Rob
  • 14,746
  • 28
  • 47
  • 65
secondbreakfast
  • 4,194
  • 5
  • 47
  • 101

2 Answers2

0

You can use

sum(increase(app_events_total[$__range])) by (event)

You just need Grafana to use only last value of you query while visualizing. For this: under your query expand Options and select Type: Instant.

This way Grafana will query Prometheus for single set of values for your query and not for whole time range of dashboard.

Additionally be advised on increase function and integer counters.

markalex
  • 8,623
  • 2
  • 7
  • 32
-1

Your query produces time series. But pie chart doesn't have a time dimension, so there is lots of event count "slices". Set Min step to reasonable value (e.g. 100d) and eventually switch to Table format, not timeseries.

Jan Garaj
  • 25,598
  • 3
  • 38
  • 59
  • Thanks for the clue / direction. When I try switching to Table and adjusting the min step to 1d (I get an error if I do 100d) it lumps everything in the chart into a single slice with another outrageously large number. – secondbreakfast Feb 16 '23 at 21:26