To retrieve only the increasing values in InfluxDB using Flux query, you can use the difference()
function. The difference()
function is used to compute the difference between subsequent non-null records in a column.
Here's an example Flux query that retrieves only the increasing values:
from(bucket: "my-bucket")
|> range(start: -1h)
|> filter(fn: (r) => r._measurement == "my-measurement")
|> difference(columns: ["value"])
|> filter(fn: (r) => r._value > 0.0)
In this query, we first select the relevant data from the my-bucket
bucket using the range()
function. We then filter the data to only include the my-measurement
measurement using the filter()
function.
Next, we apply the difference()
function to the value
column to compute the difference between subsequent non-null records in the column. This effectively calculates the rate of change of the value
field.
Finally, we filter out any records where the rate of change is less than or equal to zero, leaving us with only the increasing values.
Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss
Asked: 2021-09-15 11:00:00 +0000
Seen: 12 times
Last updated: Apr 04 '22
How can I convert the dates in string format from my InfluxDB query to ascending order?
What is the purpose of the "unit" parameter in the influxDB integral function?
What is the method for calculating the number of events occurring every minute in influxdb?
What is the Grafana InfluxQL Datasource used for with InfluxDB cloud?
Why is InfluxDB not receiving any data from Telegraf?
What is the method to specify the bucket and API token for InfluxDB by utilizing a JSON file?
How can I deal with Expression.Error related to a column in Power Query?