Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

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.