InfluxDb
cheat sheet / examples https://www.sqlpac.com/en/documents/influxdb-flux-language-advanced-features.html#influxdb-v2-quick-reminders
https://www.influxdata.com/blog/top-5-hurdles-for-flux-beginners-and-resources-for-learning-to-use-flux/
influxdb 3
from(bucket: "bucket") |> range(start: -2h) |> filter(fn: (r) => exists r.nas_name) // |> group(columns: ["nas_name","_measurment"]) |>last() |> yield(name: "unique")
Influxdb queries
import "influxdata/influxdb/schema" FROM(bucket: "sensors") // |> range(START: v.timeRangeStart, stop: v.timeRangeStop) |> range(START: 2024-02-20T01:00:00Z, stop: 2024-02-20T02:00:00Z) |> FILTER(fn: (r) => r["_measurement"] == "netflow") |> FILTER(fn: (r) => r["host"] == "gorkii21") |> FILTER(fn: (r) => r._field == "direction" OR r._field == "dst" OR r._field == "in_bytes") |> schema.fieldsAsCols() |> FILTER(fn: (r) => r["direction"] == "ingress") |> FILTER(fn: (r) => r["dst"] == "192.168.114.109") |> duplicate(COLUMN: "in_bytes", AS: "_value") |> duplicate(COLUMN: "dst", AS: "_measurement") |> GROUP(COLUMNS: ["_measurement","_start"]) |> aggregateWindow(every: 5m, fn: SUM, createEmpty: FALSE) // // |> GROUP(COLUMNS: ["dst"]) // // |>SUM() // // |> SUM() // |> yield() // // |> DROP(COLUMNS: ["host"]) // |> aggregateWindow(every: v.windowPeriod, fn: LAST, createEmpty: FALSE)