Documentation

monitor.stateChanges() function

The monitor.stateChanges() function detects state changes in a stream of data with a _level column and outputs records that change from fromLevel to toLevel.

import "influxdata/influxdb/monitor"

monitor.stateChanges(
    fromLevel: "any",
    toLevel: "any",
)

Parameters

fromLevel

The level to detect a change from. Defaults to "any".

toLevel

The level to detect a change to. The function output records that change to this level. Defaults to "any".

tables

Input data. Default is piped-forward data (<-).

Examples

Detect when the state changes to critical
import "influxdata/influxdb/monitor"

monitor.from(start: -1h)
    |> monitor.stateChanges(toLevel: "crit")
Example input data
_time _level
2021-01-01T00:00:00Z ok
2021-01-01T00:10:00Z ok
2021-01-01T00:20:00Z warn
2021-01-01T00:30:00Z crit
Example output data
_time _level
2021-01-01T00:30:00Z crit

Upgrade to InfluxDB Cloud or InfluxDB 2.0!

InfluxDB Cloud and InfluxDB OSS 2.0 ready for production.