Quantcast
Channel: InfluxDB - Grafana Labs Community Forums
Viewing all articles
Browse latest Browse all 199

InfluxDB sum of all values

$
0
0

Hi, I’ve got this influxDB query

from(bucket: "bucket1")
  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)
  |> filter(fn: (r) => r["_measurement"] == "Cisco-IOS-XR-sysadmin-fretta-envmon-ui:environment/oper/power/location/pem_attributes")
  |> filter(fn: (r) => r["_field"] == "system_power_input")
  |> group(columns: ["source"])
  |> aggregateWindow(every: v.windowPeriod, fn: sum, createEmpty: false)
  |> yield(name: "sum")

And it works as expected, showing two devices, and apparently one is using 321W of power and the other 320W.

My goal is to put them together and output just one value that’s sum of all the values that were found. So I’d expect to get another graph with single line at 641W.

To achieve this, instead of grouping by source, I tried grouping by time.

from(bucket: "bucket1")
  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)
  |> filter(fn: (r) => r["_measurement"] == "Cisco-IOS-XR-sysadmin-fretta-envmon-ui:environment/oper/power/location/pem_attributes")
  |> filter(fn: (r) => r["_field"] == "system_power_input")
  |> group(columns: ["_time"])
  |> aggregateWindow(every: v.windowPeriod, fn: sum, createEmpty: false)
  |> yield(name: "sum")

Instead of a single line at 641, I got this.

If I try grouping by anything else, like for example “_measurement” I get something like this.

Here’s the query:

from(bucket: "bucket1")
  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)
  |> filter(fn: (r) => r["_measurement"] == "Cisco-IOS-XR-sysadmin-fretta-envmon-ui:environment/oper/power/location/pem_attributes")
  |> filter(fn: (r) => r["_field"] == "system_power_input")
  |> group(columns: ["_measurement"])
  |> aggregateWindow(every: v.windowPeriod, fn: sum, createEmpty: false)
  |> yield(name: "sum")

I’ve searched around and tried many different ways to create the sum, including data transformation in grafana itself, but usually got similar results to this, which makes me think that maybe there isn’t a problem with the query but with the data itself?
But how would I even investigate that, what could cause something like this? Is the data for certain times simply missing for one of the devices? And if so, would there be a way to compensate for it?

Or is there something obvious I’m missing and the graphs are behaving as they should?

Thanks for any help

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 199

Trending Articles