Moving Average of metrics for a group of hosts

Running influxdbv2. I have a metric from telegraf called “benchmark”. I am able to see all the host’s benchmark (duration in seconds). However, I would like to aggregate all its benchmark number (avg) and them compute a moving average. How would I do that?
so, I have
from(bucket:“telegraf”)


|> group(columns:['“host”])

Hi @rmo

Assuming you have a tag called host , maybe something like this?

from(bucket: "telegraf")
  |> range(start: -1h) // Adjust the time range as needed
  |> filter(fn: (r) => r._measurement == "your_measurement")
  |> filter(fn: (r) => r._field == "benchmark")
  |> group(columns: ["host"]) // Group by host
  |> movingAverage(n: 5) // Calculate the moving average over a defined number of points, e.g., 5 in this example