monitor.check() function

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

*Function type: Transformation*

  1. import "influxdata/influxdb/monitor"
  2. monitor.check(
  3. crit: (r) => r._value > 90.0,
  4. warn: (r) => r._value > 80.0,
  5. info: (r) => r._value > 60.0,
  6. ok: (r) => r._value <= 20.0,
  7. messageFn: (r) => "The current level is ${r._level}",
  8. data: {}
  9. )

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

Parameters

crit

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

*Data type: Function*

warn

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

*Data type: Function*

info

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

*Data type: Function*

ok

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

*Data type: Function*

messageFn

A function that constructs a message to append to each row. The message is stored in the _message column.

*Data type: Function*

data

Meta data used to identify this check.

InfluxDB populates check data.

*Data type: Record*

Examples

Monitor disk usage

  1. import "influxdata/influxdb/monitor"
  2. from(bucket: "telegraf")
  3. |> range(start: -1h)
  4. |> filter(fn: (r) =>
  5. r._measurement == "disk" and
  6. r._field = "used_percent"
  7. )
  8. |> group(columns: ["_measurement"])
  9. |> monitor.check(
  10. crit: (r) => r._value > 90.0,
  11. warn: (r) => r._value > 80.0,
  12. info: (r) => r._value > 70.0,
  13. ok: (r) => r._value <= 60.0,
  14. messageFn: (r) =>
  15. if r._level == "crit" then "Critical alert!! Disk usage is at ${r._value}%!"
  16. else if r._level == "warn" then "Warning! Disk usage is at ${r._value}%."
  17. else if r._level == "info" then "Disk usage is at ${r._value}%."
  18. else "Things are looking good.",
  19. data: {
  20. _check_name: "Disk Utilization (Used Percentage)",
  21. _check_id: "disk_used_percent",
  22. _type: "threshold",
  23. tags: {}
  24. }
  25. )