Grafana InfluxDB CumulativeSum does not work

Hello,

I’m using Grafana latest version 9.

I’m using influxDB to query the data and I’m trying to use cumulativeSum() on it but it does not work, here is the code:

from(bucket: "Sewan") 
  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)
  |> toString()
  |> map(fn: (r) => ({ r with _measurement: r.client }))
  |> group(columns: ["_measurement"])
  |> filter(fn: (r) => r._field == "phones")
  |> cumulativeSum(columns: ["_value"])

and the output :

Does anyone know what I do wrong ?

Thank you for your help =) !

I was thinking maybe I can achieve my goal with the transform section of Grafana, but I can only manage to do calculations inside a row, it does not take in consideration every row of the columns, so it looks like it is a dead end from this side…

Hi @sachajoubert

I do not have much time at the moment, so very briefly…

What happens when you replace the last line with these two lines?

|> rename(columns: {_value: "something"})
|> cumulativeSum(columns: ["something"])

The way Grafana parses the result from InfluxDB is that if a _value column is found, it is assumed to be a time-series. The quick workaround is to add the following:

|> rename(columns: {_value: “something”})

Hello @grant2

Thank you for your answer

The way Grafana parses the result from InfluxDB is that if a _value column is found, it is assumed to be a time-series.

Wow I did not know that, I renamed the column as you suggested but it is still not working …

OK I figured it out thanks to you @grant2 !

It was the toString() that was an issue with cumulativeSum + the name of the column !

1 Like