I have a a database in InfluxDB version running on a Google Cloud VM instance - version g1-small (1 vCPU, 1.7 GB memory).
I use the data from this database in Grafana. This works very well when I use one by one measurement. Have several measurements in the panels - all working well.
I wanted to try to do calculation by measurements in Grafana based on the InfluxDB, and the first step was to do the following;
- Enable the InfluxDB for FLUX in the config file.
- Installed InfluxDB Chronograf
- Did a test Flux Script (FLUXTEST01 - see below) to see if I did get some result in Chronograf. This worked well, and both Table and Graphing was possible in Chronograf.
- Used my Cloud version of Grafana enabled a Database Source based on Flux (InfluxDB) (BETA). The Database Souce Connected.
- Made a simple dashboard in Grafana and pasted in the FLUXTEST01 query. I get result in the text box, but not in the panel. See "Picture of FLUXTEXT01 in Grafana below.
- Adjusted the query to just one measurement, see FLUXTEXT02. This work fine, and the result is shown on the Grafana panel. See picture below.
I really want to be able to do the alculation on measurement, and I have a lot of use cases that is relevant in our business - but we need to see it works before expanding the use of these tools.
Does anyone see what I am doing wrong ?
** FLUXTEST01 start **
Stemp = from(bucket: “naxosvilla/autogen”)
|> range($range)
|> filter(fn: (r) => r._measurement == “device.ZWayVDev_zway_8-0-49-1” and (r._field == “level”))
|> fill(column: “_value”, usePrevious: true)
|> aggregateWindow(every: 1800s, fn: mean)
|> fill(column: “_value”, value: 0.0)
|> keep(columns: [“_value”, “_time”])
Rtemp = from(bucket: “naxosvilla/autogen”)
|> range($range)
|> filter(fn: (r) => r._measurement == “device.OpenWeather_16” and (r._field == “level”))
|> fill(column: “_value”, usePrevious: true)
|> aggregateWindow(every: 1800s, fn: mean)
|> fill(column: “_value”, value: 0.0)
|> keep(columns: [“_value”, “_time”])
first_join = join(tables: {Stemp: Stemp, Rtemp: Rtemp}, on: [“_time”])
|> fill(column: “_value_Stemp”, usePrevious: true)
|> fill(column: “_value_Rtemp”,usePrevious: true)
CO2corr = first_join
|> map(fn: (r) => ({“_time”: r._time, “Act”: r._value_Stemp / r._value_Rtemp * 100.5}))
|> yield()
** FLUXTEST01 end**
** FLUXTEST02 start **
Stemp = from(bucket: “naxosvilla/autogen”)
|> range($range)
|> filter(fn: (r) => r._measurement == “device.ZWayVDev_zway_8-0-49-1” and (r._field == “level”))
|> fill(column: “_value”, usePrevious: true)
|> aggregateWindow(every: 1800s, fn: mean)
|> fill(column: “_value”, value: 0.0)
|> keep(columns: [“_value”, “_time”])
|> yield()
** FLUXTEST02 end **
Picture of FLUXTEST01 in Grafana
Picture of FLUXTEXT02 in Grafana