Documentation

monitor.check() function

monitor.check() checks input data and assigns a level (ok, info, warn, or crit) to each row based on predicate functions.

monitor.check() stores statuses in the _level column and writes results to the statuses measurement in the _monitoring bucket.

Function type signature
(
    <-tables: stream[J],
    data: {A with tags: E, _type: D, _check_name: C, _check_id: B},
    messageFn: (
        r: {
            F with
            _type: D,
            _time: H,
            _time: time,
            _source_timestamp: int,
            _source_measurement: G,
            _measurement: G,
            _measurement: string,
            _level: string,
            _check_name: C,
            _check_id: B,
        },
    ) => I,
    ?crit: (r: {F with _time: H, _measurement: G}) => bool,
    ?info: (r: {F with _time: H, _measurement: G}) => bool,
    ?ok: (r: {F with _time: H, _measurement: G}) => bool,
    ?warn: (r: {F with _time: H, _measurement: G}) => bool,
) => stream[{
    F with
    _type: D,
    _time: H,
    _time: time,
    _source_timestamp: int,
    _source_measurement: G,
    _message: I,
    _measurement: G,
    _measurement: string,
    _level: string,
    _check_name: C,
    _check_id: B,
}] where E: Record, J: Record
For more information, see Function type signatures.

Parameters

crit

Predicate function that determines crit status. Default is (r) => false.

warn

Predicate function that determines warn status. Default is (r) => false.

info

Predicate function that determines info status. Default is (r) => false.

ok

Predicate function that determines ok status. Default is (r) => true.

messageFn

(Required) Predicate function that constructs a message to append to each row.

The message is stored in the _message column.

data

(Required) Check data to append to output used to identify this check.

This data specifies which notification rule and notification endpoint to associate with the sent notification. The data record must contain the following properties:

  • _check_id: check ID (string)
  • _check_name: check name (string)
  • _type: check type (threshold, deadman, or custom) (string)
  • tags: Custom tags to append to output rows (record) The InfluxDB monitoring and alerting system uses monitor.check() to check statuses and automatically assigns these values. If writing a custom check task, we recommend using unique arbitrary values for data record properties.

tables

Input data. Default is piped-forward data (<-).

Examples

Monitor InfluxDB disk usage collected by Telegraf

import "influxdata/influxdb/monitor"

from(bucket: "telegraf")
    |> range(start: -1h)
    |> filter(fn: (r) => r._measurement == "disk" and r._field == "used_percent")
    |> monitor.check(
        crit: (r) => r._value > 90.0,
        warn: (r) => r._value > 80.0,
        info: (r) => r._value > 70.0,
        ok: (r) => r._value <= 60.0,
        messageFn: (r) =>
            if r._level == "crit" then
                "Critical alert!! Disk usage is at ${r._value}%!"
            else if r._level == "warn" then
                "Warning! Disk usage is at ${r._value}%."
            else if r._level == "info" then
                "Disk usage is at ${r._value}%."
            else
                "Things are looking good.",
        data: {
            _check_name: "Disk Utilization (Used Percentage)",
            _check_id: "disk_used_percent",
            _type: "threshold",
            tags: {},
        },
    )

Was this page helpful?

Thank you for your feedback!


Linux Package Signing Key Rotation

All signed InfluxData Linux packages have been resigned with an updated key. If using Linux, you may need to update your package configuration to continue to download and verify InfluxData software packages.

For more information, see the Linux Package Signing Key Rotation blog post.

InfluxDB Cloud backed by InfluxDB IOx

All InfluxDB Cloud organizations created on or after January 31, 2023 are backed by the new InfluxDB IOx storage engine. Check the right column of your InfluxDB Cloud organization homepage to see which InfluxDB storage engine you’re using.

If powered by IOx, this is the correct documentation.

If powered by TSM, see the TSM-based InfluxDB Cloud documentation.

InfluxDB Cloud backed by InfluxDB TSM

All InfluxDB Cloud organizations created on or after January 31, 2023 are backed by the new InfluxDB IOx storage engine which enables nearly unlimited series cardinality and SQL query support. Check the right column of your InfluxDB Cloud organization homepage to see which InfluxDB storage engine you’re using.

If powered by TSM, this is the correct documentation.

If powered by IOx, see the IOx-based InfluxDB Cloud documentation.

State of the InfluxDB Cloud (IOx) documentation

The new documentation for InfluxDB Cloud backed by InfluxDB IOx is a work in progress. We are adding new information and content almost daily. Thank you for your patience!

If there is specific information you’re looking for, please submit a documentation issue.