1.8 KiB
1.8 KiB
title | description | aliases | menu | weight | flux/v0.x/tags | introduced | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
monitor.stateChanges() function | The `monitor.stateChanges()` function detects state changes in a stream of tables and outputs records that change from `fromLevel` to `toLevel`. |
|
|
202 |
|
0.42.0 |
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")
{{< flex >}} {{% flex-content %}}
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 |
{{% /flex-content %}} | |
{{% flex-content %}} |
Example output data
_time | _level |
---|---|
2021-01-01T00:30:00Z | crit |
{{% /flex-content %}} | |
{{< /flex >}} |