文档文档

tickscript.alert() 函数

tickscript.alert() 是用户贡献的函数,由包作者维护。

tickscript.alert() 识别不同严重程度级别的事件,并将它们写入 InfluxDB _monitoring 系统存储桶中的 statuses 测量。

此函数与 TICKscript alert() 相当。

函数类型签名
(
    <-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

有关更多信息,请参阅函数类型签名

参数

check

必需)InfluxDB 检查数据。 请参阅 tickscript.defineCheck()

id

返回检查记录提供的 InfluxDB 检查 ID 的函数。 默认为 (r) => "${r._check_id}"

details

使用输入行中的数据返回 InfluxDB 检查详细信息的函数。 默认为 (r) => ""

message

使用输入行中的数据返回 InfluxDB 检查消息的函数。 默认为 (r) => "阈值检查:${r._check_name} 为:${r._level}"

crit

确定 crit 状态的谓词函数。 默认为 (r) => false

warn

确定 warn 状态的谓词函数。 默认为 (r) => false

info

确定 info 状态的谓词函数。 默认为 (r) => false

ok

确定 ok 状态的谓词函数。 默认为 (r) => true

topic

检查主题。 默认为 ""

tables

输入数据。 默认为管道转发数据 (<-)。

示例

存储错误计数的警报状态

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,
    )

此页面是否有帮助?

感谢您的反馈!


Flux 的未来

Flux 即将进入维护模式。 您可以继续像现在一样使用它,而无需对代码进行任何更改。

阅读更多

现已全面上市

InfluxDB 3 Core 和 Enterprise

快速启动。 更快扩展。

获取更新

InfluxDB 3 Core 是一款开源、高速、最新数据引擎,可实时收集和处理数据,并将其持久化到本地磁盘或对象存储。 InfluxDB 3 Enterprise 构建在 Core 的基础上,增加了高可用性、只读副本、增强的安全性以及数据压缩,从而实现更快的查询和优化的存储。 InfluxDB 3 Enterprise 的免费层可供非商业家庭或业余爱好者使用。

有关更多信息,请查看