Documentation

tickscript.alert() function

tickscript.alert() is a user-contributed function maintained by the package author.

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

This function is comparable to TICKscript alert().

Function type signature
(
    <-tables: stream[M],
    check: {A with tags: E, _type: D, _check_name: C, _check_id: B},
    ?crit: (r: {F with _time: H, _measurement: G}) => bool,
    ?details: (r: {I with id: J, _check_name: C, _check_id: B}) => K,
    ?id: (r: {I with _check_name: C, _check_id: B}) => J,
    ?info: (r: {F with _time: H, _measurement: G}) => bool,
    ?message: (
        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,
        },
    ) => L,
    ?ok: (r: {F with _time: H, _measurement: G}) => bool,
    ?topic: string,
    ?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: L,
    _measurement: G,
    _measurement: string,
    _level: string,
    _check_name: C,
    _check_id: B,
}] where E: Record, I: Record, M: Record
For more information, see Function type signatures.

Parameters

check

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

id

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

details

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

message

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

crit

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

warn

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

info

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

ok

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

topic

Check topic. Default is "".

tables

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

Examples

Store alert statuses for error counts

import "contrib/bonitoo-io/tickscript"

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

check = tickscript.defineCheck(id: "000000000000", name: "Errors", type: "threshold")

from(bucket: "example-bucket")
    |> range(start: -task.every)
    |> filter(fn: (r) => r._measurement == "errors" and r._field == "value")
    |> count()
    |> tickscript.alert(
        check: {check with _check_id: "task/${r.service}"},
        message: "task/${r.service} is ${r._level} value: ${r._value}",
        crit: (r) => r._value > 30,
        warn: (r) => r._value > 20,
        info: (r) => r._value > 10,
    )

Was this page helpful?

Thank you for your feedback!


Introducing InfluxDB Clustered

A highly available InfluxDB 3.0 cluster on your own infrastructure.

InfluxDB Clustered is a highly available InfluxDB 3.0 cluster built for high write and query workloads on your own infrastructure.

InfluxDB Clustered is currently in limited availability and is only available to a limited group of InfluxData customers. If interested in being part of the limited access group, please contact the InfluxData Sales team.

Learn more
Contact InfluxData Sales

The future of Flux

Flux is going into maintenance mode. You can continue using it as you currently are without any changes to your code.

Flux is going into maintenance mode and will not be supported in InfluxDB 3.0. This was a decision based on the broad demand for SQL and the continued growth and adoption of InfluxQL. We are continuing to support Flux for users in 1.x and 2.x so you can continue using it with no changes to your code. If you are interested in transitioning to InfluxDB 3.0 and want to future-proof your code, we suggest using InfluxQL.

For information about the future of Flux, see the following:

State of the InfluxDB Cloud Serverless documentation

InfluxDB Cloud Serverless documentation is a work in progress.

The new documentation for InfluxDB Cloud Serverless 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.