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.

Function type: Transformation

import "influxdata/influxdb/monitor"

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

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
import "influxdata/influxdb/monitor"

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

Given the following input:

_time_level
0001ok
0002ok
0003warn
0004crit

The following function outputs:

monitor.stateChanges(
  toLevel: "crit"
)
_time_level
0004crit

Function definition

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

New! Cloud or OSS?

InfluxDB OSS 2.0 now generally available!

InfluxDB OSS 2.0 is now generally available and ready for production use. See the InfluxDB OSS 2.0 release notes.

For information about upgrading to InfluxDB OSS 2.0, see: