siger
siger

Reputation: 3162

How to convert running total metric to change per time window?

I'm working with a metric that represents a running total.

Peaks are 30 seconds apart, making me think the count is stored every 30 seconds. My goal is to be able to see the delta in the running total per "$window" (template variable, ex: 1min, 30min). If my window is 30 seconds and the difference between two consecutive counts is 5, I'd like to see a "5" datapoint. If my window is 1min, it would be the delta between 3 peaks.

running total

My understanding was that derivative would help, but it produces a constant 0 line. I suppose this has to do with the pointy-nature of the graph. I've been playing with hitcount and perSecond, but I don't seem to be getting the right numbers. Any advice?

EDIT: I'm currently trying out summarize(derivative(summarize(my.metric, "30s")), "$window"). Idea is to enforce a minimum resolution of 30s (since I only have 1 datapoint per 30s) with summarize(my.metric, "30s"). Then, I use derivative to get the rate of change, and finally summarize with my templated $window to sum the rates of changes by the interval I'm interested in. Any comments?

Upvotes: 2

Views: 1200

Answers (1)

siger
siger

Reputation: 3162

Using summarize(derivative(summarize(my.metric, "30s")), "$window") worked.

Upvotes: 2

Related Questions