Conditional aggregation depending on number of data points retrieved

Hi, i have problems fetching high-frequency data from InfluxDB 2.x and visualization in Grafana. I choose my time window too large, so get a „too many data points“ error in Grafana.
Hence it would be nice if one could build a re-sampling query using the number of initially fetched data points and a goal number of data points to determine a re-sampling rate such that the number of points in the final output matches the goal number independent of the time range chosen.
Currently, I am using a static aggregateWindow(every: 1m, fn: max) to prevent the error. I saw as well the documentation to co dictional statements combined with aggregateWindow(…). However, I wouldn‘t know how to achieve what I want.

Any hint would be nice.

 |> aggregateWindow(every: v.windowPeriod, fn: last, createEmpty: false)

this will automaticaly select the window sizes, I do not know really how it divides the windows, I know that is based on time range only.

In grafana you have this other query options too:

however, I also understand the necessity of custom and more dynamic time windows, and I am sure it can be done. I am in the same situation, sometimes I need to look on hundreds of hours, sometimes less than 10 and some events are only noticeable on windows of 2s. I have yet to think about my ideal solution but whenever I do, I’ll be back and share it.

1 Like