docs-v2/content/v2.0/reference/flux/functions/monitor/statechanges.md

1.1 KiB

title description menu weight cloud_all
monitor.stateChanges() function The `monitor.stateChanges()` function detects state changes in a stream of data and outputs records that change from `fromLevel` to `toLevel`.
v2_0_ref
name parent
monitor.stateChanges InfluxDB Monitor
202 true

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

{{% note %}} monitor.stateChanges operates on data in the statuses measurement and requires a _level column . {{% /note %}}

Function type: Transformation

import "influxdata/influxdb/monitor"

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

Parameters

fromLevel

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

Data type: String

toLevel

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

Data type: String

Examples

Detect when the state changes to critical

import "influxdata/influxdb/monitor"

monitor.from(start: -1h)
  |> monitor.stateChanges(toLevel: "crit")