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.