Question on grouping fields from influxdb

Hello all,

I have an InfluxDB with data from my inverter. Every time I restart my docker stack, a new filed “host” is added. For example data up until this point has the host value “a” (just an example, the actual value is longer), after the reboot its “b”.

This results in two gauges where only should be one (one for before the restart, the other one after) or in bar chars which are splitted.

for gauges where i show the current value I added a “group()” at the end of the query and that helped. but this doesn’t work with query where I sum up values over a certain time frame. Example: The following query should show the production of my solar panels for today:

from(bucket: “powermeter”)
|> range(start: today())
|> filter(fn: (r) => r[“_field”] == “P_PV”)
|> aggregateWindow(every: 1d, fn: integral)
|> map(fn: (r) => ({r with _value: r._value / 3600000.0, host: r.host})) // Include the “host” field in the mapping
|> group(columns: [“host”]) // Group by the “host” field

but I still see three gauges (as I restarted three times today).

Questions:

  • Can I get rid of the “host” field completely?
  • if not, how can I change the query above so that there is just one value returned?

Thanks in advance!
Bruno

Hi @brunoz and welcome to the Grafana forum.

Does repositioning the group() function change the output in Grafana? For example:

from(bucket: "powermeter")
|> range(start: today())
|> filter(fn: (r) => r["_field"] == "P_PV")
|> group(columns: ["host"]) // Group by the "host" field
|> aggregateWindow(every: 1d, fn: integral)
|> map(fn: (r) => ({r with _value: r._value / 3600000.0, host: r.host})) // Include the "host" field in the mapping

Hello @grant2 , thank you for your fast reply!

I still see multiple gauges, what changes is the text above them. It changes from “_value f3193d76646f” to “f3193d76646f”. “f3193d76646f” is an example of an before mentioned “host” entries.

I found a solution. It’s not related to grouping, but I was able to not generate the “host” field. It’s part of the telegraf configuration.

1 Like