I'm trying to write a query that will return the following information:
for metric m1 (of type counter) - return the sum of values, grouped by (p1,p2) in a sliding window of 1h.
I think the base should be something like:
sum_over_time(m1[1h])
but this cannot be grouped by (p1,p2)
One way to do the grouping is by
sum(sum_over_time(m1[1h])) by (p1, p2)
but i'm not sure if adding the external sum here, just in order to group, is the way to go.
Another possibility it to do:
topk(100, sum_over_time(m1[1h])) by (p1, p2)
but in this case the grouping doesn't seem to happen right, as the results contain a lot of rows with the same (p1,p2) and different in some other labels (p3,p4)
what is the correct way to sum a metric, in a sliding window, by some lables?
sum(sum_over_time(m1[1h])) by (p1, p2)
makes sense :) – Asthmatic