3
votes

I am trying to chart total number of requests each hour with Grafana and Prometheus counters.

So I have a counter which gets incremented at every request http_requests.

I am using increase(http_requests[60m]) to calculate total requests in last 60 minutes from given instant T.

But this is giving me a trend line and I wish to get a histogram.

So for example

10:00-11:00 - 100 (calculated by counter_value_at_11 - counter_value_at_10)

Now lets say current time is 11:30 so I wish to get counts for the bucket 11:00-12:00 by giving me (count_now - count_at_11).

1.) Can counters be used to model such data ?

2.) I am open to use other metric types in Prometheus if they support such modelling

1

1 Answers

2
votes

For histogram graph you can found it in Visualization -> Draw Modes, there's Bars toggle that can be activated.

And for bucketing the data for each hour, you can set it in the Query section, by adding Min step value to "1h".

Example