Documentation

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

有关更多信息,请参见 Function type signatures

参数

检查

(必填) InfluxDB 检查数据。 查看 tickscript.defineCheck()

身份标识

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

详情

函数返回使用输入行数据的InfluxDB检查详情。 默认值是 (r) => ""

消息

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

危害

谓词函数以确定 crit 状态。默认值是 (r) => false

警告

谓词函数用于确定 warn 状态。默认值是 (r) => false

信息

谓词函数用于确定 info 状态。默认值是 (r) => false

好的

谓词函数用于确定 ok 状态。默认值是 (r) => true

主题

检查主题。默认值是 ""

表格

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

示例

存储错误计数的警报状态

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 开源版本现已公开Alpha测试

InfluxDB 3 Open Source is now available for alpha testing, licensed under MIT or Apache 2 licensing.

我们将发布两个产品作为测试版的一部分。

InfluxDB 3 核心,是我们新的开源产品。 它是一个用于时间序列和事件数据的实时数据引擎。 InfluxDB 3 企业版是建立在核心基础之上的商业版本,增加了历史查询能力、读取副本、高可用性、可扩展性和细粒度安全性。

有关如何开始的更多信息,请查看: