Documentation

tickscript.alert() function

The tickscript.alert() function is a user-contributed function maintained by the package author and can be updated or removed at any time.

The tickscript.alert() function identifies events of varying severity levels and writes them to the statuses measurement in the InfluxDB _monitoring system bucket.

This function is comparable to the Kapacitor AlertNode.

import "contrib/bonitoo-io/tickscript"

tickscript.alert(
    check,
    id: (r) => "${r._check_id}",
    details: (r) => "",
    message: (r) => "Threshold Check: ${r._check_name} is: ${r._level}",
    crit: (r) => false,
    warn: (r) => false,
    info: (r) => false,
    ok: (r) => true,
    topic: ""
)

Parameters

check

(Required) InfluxDB check data. See tickscript.defineCheck().

Data type: Record

id

Function that returns the InfluxDB check ID provided by the check record. Default is (r) => "${r._check_id}".

Data type: Function

details

Function to return the InfluxDB check details using data from input rows. Default is (r) => "".

Data type: Function

message

Function to return the InfluxDB check message using data from input rows. Default is (r) => "Threshold Check: ${r._check_name} is: ${r._level}".

Data type: Function

crit

Predicate function to determine crit status. Default is (r) => false

Data type: Function

warn

Predicate function to determine warn status. Default is (r) => false

Data type: Function

info

Predicate function to determine info status. Default is (r) => false

Data type: Function

ok

Predicate function to determine ok status. Default is (r) => true

Data type: Function

topic

Check topic. Default is ""

Data type: String

Examples

Store alert statuses for error counts
import "contrib/bonitoo-io/tickscript"

option task = {name: "Example task", every: 1m;}

from(bucket: "example-bucket")
  |> range(start: -task.every)
  |> filter(fn: (r) => r._measurement == "errors" and r._field == "value")
  |> count()
  |> tickscript.alert(
    check: tickscript.defineCheck(id: "000000000000", name: "task/${r.service}"),
    message: "${r._check_name} is ${r._level} value: ${r._value}",
    crit: (r) => r._value > 30,
    warn: (r) => r._value > 20,
    info: (r) => r._value > 10    
  )
data = batch
  |query('SELECT count(value) from errors')
    .every(1m)

data
  |alert()
    .id('kapacitor/{{ index .Tags "service" }}')
    .message('{{ .ID }} is {{ .Level }} value:{{ index .Fields "value" }}')
    .info(lambda: "value" > 10)
    .warn(lambda: "value" > 20)
    .crit(lambda: "value" > 30)

Package author and maintainer

Github: @bonitoo-io, @alespour
InfluxDB Slack: @Ales Pour


Select your region

Upgrade to InfluxDB Cloud or InfluxDB 2.0!

InfluxDB Cloud and InfluxDB OSS 2.0 ready for production.