14 Mar 2025 06:35 PM
I have a duration metric that is populated every time a pipeline runs, i would also like to use this metric to see trends on how often the pipeline is run and the outcome. But because this is not very frequent a simple count on the timeseries does not give a very revealing graph. Instead i would need the sum over the time period for each datapoint to get a clearer picture, the equivalent of count_over_time in prometheus.
I see that i can do an array modification with arrayCumulativeSum or arrayMovingSum but i would need instead something related to time both options above also always start from a low sum which is not ideal.
Is there a way to do this?
Solved! Go to Solution.
20 May 2025 04:02 PM
I think this maybe helpful to get data you want to see.
I have metric (response time for service) which behaves quite like in your description: sometimes we have measurement with major break in between.
Query to get the data looks like this:
timeseries rt = avg(dt.service.request.response_time), filter:dt.entity.service=="SERVICE-4B4EB791A0B161BC"
The result looks like (one measurement over 0.8s, several below 50ms)
Apart of actual measurement (response time in this case), each timeseries keeps number of measurements/contributions to metric in specific time slot. To get this information use of rollup:total option is needed:
timeseries inv = sum(dt.service.request.response_time, rollup:total), filter:dt.entity.service=="SERVICE-4B4EB791A0B161BC"
Now we can see number of measurements over time. Of course spaces between bars stay away from each other, but timeseries command has interval: option which allows to widen interval according to needs. In my example I widen interval from default 1 minute to 10 minutes:
timeseries inv = sum(dt.service.request.response_time, rollup:total), filter:dt.entity.service=="SERVICE-4B4EB791A0B161BC", interval:10m
Now bars are not longer apart:
I hope this helps.