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

InFluxDB2 Field not found (because no data was written to it yet today)

$
0
0

Hi everyone!

I have an element in grafana that shows me the total Energy (kWh) that was sent to the Battery today.

The problem is that until my solar inverter begins to charge the battery, the field does not exists for a “today” query.
And so I get a “field not found” until the inverter begins to charge the battery.

Is there a way to “create” the E_STORAGE_CHARGE field with a 0 if it does not exist? :slight_smile:

import "timezone"
import "date"

option location = timezone.location(name: "Europe/Vienna")
  from(bucket: "fronius_aktuell")
  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)
  |> filter(fn: (r) => r._measurement == "actual")
  |> filter(fn: (r) => r._field == "E_STORAGE_CHARGE")
  |> difference()
  |> sum()
  |> group(columns: ["_field"])
  |> pivot(rowKey: ["_start"], columnKey: ["_field"], valueColumn: "_value")
  |> map(fn: (r) => ({r with E_Speicher_Ladung: r.E_STORAGE_CHARGE}))
  |> keep(columns: ["_start", "E_Speicher_Ladung"])

6 posts - 2 participants

Read full topic


Viewing all articles
Browse latest Browse all 199

Trending Articles