Same field names in FLUX

Hey,
I use InfluxDB 2.5 as OPENHAB persistence service.
OPENHAB saves every data with two columns:
“_measurement” where name of item is saved
“_fileld” where it is always “value”.

So now in Grafana when I want to have two measurements shown on one graph I have two queries:

from(bucket: "openhab_db")
  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)
  |> filter(fn: (r) => r._measurement == "pompa_moc")
  |> filter(fn: (r) => r._field == "value")
  |> aggregateWindow(every: v.windowPeriod, fn: mean, createEmpty: false)
  |> keep(columns: ["_time", "_value"])
  |> sort(columns: ["_time"])

and

from(bucket: "openhab_db")
  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)
    |> filter(fn: (r) => r._measurement == "pompa_dzis")
  |> filter(fn: (r) => r._field == "value")
  |> filter(fn: (r) => r.item == "pompa_dzis")
  |> aggregateWindow(every: v.windowPeriod, fn: mean, createEmpty: false)
  |> keep(columns: ["_time", "_value"])
  |> sort(columns: ["_time"])

As You can see they have same r._field . And this is big problem. Because now I cannot make any overrides for one of this two queries. When I want to make any overrides I can make it for fields with names, and all fields have the same names…

Any idea how to override it?

In one of your queries, try adding this before the keep() function

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

it is not working. everything disappears.

Can you try changing the last 3 lines (of one of the queries) to this?

 |> rename(columns: {_value: "something"}) 
 |> keep(columns: ["_time", "something"])
 |> sort(columns: ["_time"])
1 Like

And now it works;)

Thank You very much!:wink:

Świetnie! Cieszę się

1 Like