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.

*Function type: Transformation*

  1. import "influxdata/influxdb/monitor"
  2. monitor.stateChanges(
  3. fromLevel: "any",
  4. toLevel: "any"
  5. )

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. Defaults to "any".

*Data type: String*

Examples

Detect when the state changes to critical
  1. import "influxdata/influxdb/monitor"
  2. monitor.from(start: -1h)
  3. |> monitor.stateChanges(toLevel: "crit")

Given the following input:

_time_level
0001ok
0002ok
0003warn
0004crit

The following function outputs:

  1. monitor.stateChanges(
  2. toLevel: "crit"
  3. )
_time_level
0004crit

Function definition

  1. stateChanges = (fromLevel="any", toLevel="any", tables=<-) => {
  2. return
  3. if fromLevel == "any" and toLevel == "any" then tables |> stateChangesOnly()
  4. else tables |> _stateChanges(fromLevel: fromLevel, toLevel: toLevel)
  5. }