Need help converting InfluxQL query to InfluxDB 2

Hello, I’m trying to figure out how to convert a rather simple influxql query to influxdb 2 but I just can’t find the correct way. This is the query:

SELECT NON_NEGATIVE_DERIVATIVE(MEAN(transmit), 10s) as transmit, NON_NEGATIVE_DERIVATIVE(MEAN(receive), 10s) as receive
FROM nics
WHERE (host = ‘somethost’)
AND time >= ‘3600s’
GROUP BY time(600s), host fill(none)

Can someone help me with this please?

Anyone? I really can’t find a correct way to solve this with the usual documentation.

If I understand your query correctly…I think this is what you want, although I am uncertain about the time portion of your where clause. You can adjust the range portion to meet your needs:

from(bucket: “your_bucket”)
|> range(start: dashboardTime)
|> filter(fn: (r) => r._measurement == “nics”)
|> filter(fn: (r) => r._field == “transmit” or r._field == “receive”)
|> filter(fn: (r) => == “somehost”)
|> aggregateWindow(every: 5m, fn: mean)
|> derivative(unit: 10s, nonNegative: true, columns: ["_value"], timeColumn: “_time”)

This selects your two fields trasmit and receive, performs a 5m mean, then applies the derivative (non-negative)…with the 10s unit.

1 Like