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 |
---|---|
0001 | ok |
0002 | ok |
0003 | warn |
0004 | crit |
The following function outputs:
monitor.stateChanges(
toLevel: "crit"
)
_time | _level |
---|---|
0004 | crit |
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)
}
Support and feedback
Thank you for being part of our community! We welcome and encourage your feedback and bug reports for InfluxDB and this documentation. To find support, the following resources are available:
InfluxDB Cloud and InfluxDB Enterprise customers can contact InfluxData Support.