When I'm trying to build a panel into my grafana dashboard using a counter metric, it's telling me:
Selected metric is a counter. Consider calculating rate of counter by adding rate().
scrape_interval?I'm using those metrics:
method_timed_seconds_count -> countermethod_timed_seconds_max -> gaugemethod_timed_seconds_sum -> counterHow should I visualize them? I mean, which promQL should I use?
Currently, I'm using them straightforwardly.
Counter metrics are rarely useful when displayed on the graph. For example, try obtaining any useful information from the graph on the method_timed_seconds_sum metric. That's why it is recommended wrapping these metrics into rate or increase functions:
rate(m[d]) returns the average per-second increase rate for counters matching m series selector over the lookbehind window d. For example, rate(method_timed_seconds_count[5m]) returns the average requests per second over the last 5 minites.increase(m[d]) returns the increase of counters matching m over the lookbehind window d. For example, increase(method_timed_seconds_count[1h]) returns the number of requests during the last hour.Both method_timed_seconds_count and method_timed_seconds_sum counters can be used for calculating the average request duration on an arbitrary lookbehind window. For example, the following query returns the average request duration over the last 5 minutes:
increase(method_timed_seconds_sum[5m])
/
increase(method_timed_seconds_count[5m])
E.g. this query divides the sum of duration of all the requests during the last 5 minutes by the the number of requests during the last 5 minutes.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With