Group by time and aggregate in PromQL/MetricsQL

Viewed 2116

I have a metric say x, of type gauge, And the values are reported every 5m.

Now I want to make a query such that, I get sum of values in each hour in a day.

Exmaple: from 3PM to 5PM, the gauge values are 1,1,1,1,1,2,2,2,2,2,1,1,1,1,1,2,2,2,2,2,1,1,1,1,1,2,2,2,2,2,1,1,1,1,1,2,2,2,2,2,1,1,1,1,1,2,2,2,2,2,1,1,1,1,1,2,2,2,2,2 reported every 5 minutes - total 60 values

The result of my query should be 3PM-4PM -> 45 and 4PM-5PM -> 45 (sum of all values in the hour)

TIA

1 Answers
Related