1

Hi I have a use case where I have to aggregate my application response time for a time interval of 10 i.e (rate 10 and then calculate the average . The real problem is there is no way to calculate the number of events in riemann rate function for the time interval of 10. Is there any way to do that other than using (fixed-time-window .

Tinkaal Gogoi
  • 4,344
  • 4
  • 27
  • 36

1 Answers1

2

Rate is unlikely to be the function you want for this. If I understand it you would like your code to:

  1. gather all the events that happen in ten minutes
  2. once the events are all available, calculate the average of the :metric key
  3. emit one event with the service name, and that average as the value of it's metric.

If I'm not understanding then this answer won't fit, so let me know.

Rate takes in a reporting-interval and any number of streams to forward the average rate to. That first parameter to rate only determines how often it report the current rate and has no effect on the period over which it's aggregated. the built in rate function only has one available agrigation interval, it always reports in "metric per second". so it accumulates events for one second, and averages the mertic over that second, and it properly handles edge cases like reporting intervals with no events as a zero metric a reasonable number of times, though not forever. You should use rate where it fits, and not use it where you need explicit control over the aggregation period.

I often want events per minute, so I set the reporting period to 60 seconds, then multiply the output by 60 before forwarding it. This saves me handling all the edge cases in custom aggregation functions. keep in mind that this looses some accuracy in the rounding.

      (rate 60
            (adjust [:metric * 60]
                    index datadog))

You may also want to do something like:

(fixed-time-window 10
   (smap folds/median
       ... your stuff ...
Arthur Ulfeldt
  • 90,827
  • 27
  • 201
  • 284
  • Hi @Arthur my scenario is same as you explained . My worry with fixed-time-window is it has to wait until a new event arrives after the time window has finished. For time being I am using `(fixed-time-window 10 (smap folds/mean` – Tinkaal Gogoi Mar 20 '17 at 08:52
  • the rate function may be what you want after all then. It guarantees to produce an event at the end of a given window. – Arthur Ulfeldt Mar 22 '17 at 21:52
  • Yes rate is the perfect candidate but I couldn't find a way to calculate the number of events in the rate time interval. – Tinkaal Gogoi Mar 23 '17 at 07:17