How to add values at each time point?

Hello everyone, I need help to display a single curve which, for each point, sums all the values of all the VMs.

(I upload an image of the whole text because I can’t display more than one image)

And here is my flux :

from(bucket: "GreenIT")
  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)
  |> filter(fn: (r) => r["_measurement"] == "ESX")
  |> filter(fn: (r) => r["_field"] == "CpuTotalGhz")
  |> aggregateWindow(every: v.windowPeriod, fn: mean, createEmpty: false)
  |> yield(name: "mean")

I hope that I have been clear enough and that you understand. This is a problem I’ve been working on for some time and I still can’t find a solution. Thank you for the time you will spend helping me!

And sorry for my English if it’s that bad :slight_smile:

Hi Major,
Welcome to the community! So if I understand your problem correctly you should be able to sum each VM value using the following method

from(bucket: "GreenIT")
  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)
  |> filter(fn: (r) => r["_measurement"] == "ESX")
  |> filter(fn: (r) => r["_field"] == "CpuTotalGhz")
  |> aggregateWindow(every: v.windowPeriod, fn: mean, createEmpty: false)
  |> group(columns: ["_time", "_measurement"])
  |> sum()
  |> group()

Essentially what we are doing is grouping each row by time and measurement. This will essentially put each time interval into there own table. so 12pm -> vm1(24), vm2(20), vm3(21).

Next, we perform a sum. this will perform a total of each row within a given table. In our case 12pm -> vm1 + vm2 +vm3. Now we perform an ungroup (group()) to combine the time grouped tables into one table.