Search code examples
prometheusgrafanapromql

Advantage of avg_over_time(rate()) over rate() by itself?


Usually my queries with counter metrics look like this:

rate(metric_total[5m])
rate(metric_total[$__interval])

But while looking at various companies / teams using Prometheus and Grafana (for example the GitLab infrastructure team) I came across the following construct:

avg_over_time(recording_rule:rate_5m[$__interval])

So I would like to know: Is there an advantage to the second approach?


Here is a concrete example: https://dashboards.gitlab.com/d/frontend-main/frontend-overview?orgId=1&viewPanel=23


Solution

  • The 2nd approach doesn't require you to have recording rules for every possible interval over which you'd like an average rate, saving resources.