Normalize data on time interval

Hello Everyone,
This might seem stupid but it's an issue I can't find a definitive answer and I'm not really sure how to search for it, so I might ask here:

I'm trying to visualize server requests rate over time by sending prometheus metrics to elastic via elastic agents.
Given it's spikey nature, I also want to visualize the trend so it's easier to understand how much requests I get on average.

My issue here is that when I change the time window and the @timestamp minimum interval increases, the Y-axis value increases or decreases.
like that:

the underling formulas:

  • for the green line max(prometheus.krakend_opencensus_io_http_server_request_count.rate)
  • for the red line moving_average(max(prometheus.krakend_opencensus_io_http_server_request_count.rate), window=60)

I get that the green line, once the minimum interval increases, shows only the max over the 10m interval, but how can I keep the trend line true to the data collected by the minute?

Thank you

I believe this is due to the window=60 that you're using. The window is not a timespan, it's the number of data points to use with each data point being based on a timestamp internal.

So, In your first graph, a window of 60 represents the moving average over the last 60 minutes (timestamp is per minute) In your second graph the window of 60 represents the moving average over the last 600 minutes (timestamp is per ten minutes).

There is a GitHub issue that explains this a little bit and outlines a potential solution using a "sliding window" which you might find matches the problem you're hitting: [Lens] Sliding window support · Issue #131073 · elastic/kibana · GitHub essentially the ask here is for window to be a timespan instead of a count.

Thank you for the answer William
I hoped the was some math solution I couldn't see like dividing for the real amount of records but i'm not sure how to apply it correctly.
reducing manually the window isn't a solution as enlarging the time window makes the moving average more and more towards the max and not the real average.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.