romanl
1
Hello everyone,
currently, I am trying to query data over multiple measurements and visualize it with grafana.
The following works for now:
SELECT count("myField") FROM /^\d{4}$/ GROUP BY time(1w)
But this gives me a count for each measurement per week. Is it possible to combine all results?
I thought about something like this, but it is not working:
SELECT sum("count") FROM (SELECT count("myField") FROM /^\d{4}$/) GROUP BY time(1w)
Anyone got an idea what could solve my problem?
Thanks in advance.
Anaisdg
2
Hello @romanl,
Welcome! I recommend using v1.7.6+ or v2.x so that you can have access to Flux and join() to perform math across measurements.
I believe it would look something like:
table1 = from(bucket: "default")
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r._measurement == "disk")
|> filter(fn: (r) => r._field == "free")
table2 = from(bucket: "default")
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r._measurement == "cpu")
|> filter(fn: (r) => r.cpu == "cpu-total" and r._field == "usage_system")
joined = join(tables: {disk: table1, cpu: table2}, on: ["_time"], method: "inner")
|> count(column: "_value")