Documentation

alerta.alert() 函数

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

alerta.alert()Alerta 发送警报。

函数类型签名
(
    apiKey: string,
    attributes: A,
    event: B,
    resource: C,
    severity: D,
    url: string,
    ?environment: E,
    ?group: F,
    ?origin: G,
    ?service: H,
    ?tags: I,
    ?text: J,
    ?timestamp: K,
    ?type: L,
    ?value: M,
) => int

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

参数

url

(必需) (Required) Alerta URL。

apiKey

(必需) (Required) Alerta API 密钥。

resource

(必需) (Required) 与警报关联的资源。

event

(必需) (Required) 事件名称。

environment

Alerta 环境。有效值:“Production”、“Development”或空字符串(默认)。

severity

(必需) (Required) 事件严重性。请参阅 Alerta 严重级别

service

受影响服务的列表。默认为 []

group

Alerta 事件组。默认为 ""

value

事件值。默认为 ""

text

Alerta 文本描述。默认为 ""

tags

事件标签列表。默认为 []

attributes

(必需) (Required) 警报属性。

origin

监控组件。

type

事件类型。默认为 ""

timestamp

生成警报的时间。默认为 now()

示例

将最后报告的值和状态发送到 Alerta

import "contrib/bonitoo-io/alerta"
import "influxdata/influxdb/secrets"

apiKey = secrets.get(key: "ALERTA_API_KEY")

lastReported =
    from(bucket: "example-bucket")
        |> range(start: -1m)
        |> filter(fn: (r) => r._measurement == "example-measurement" and r._field == "level")
        |> last()
        |> findRecord(fn: (key) => true, idx: 0)

severity = if lastReported._value > 50 then "warning" else "ok"

alerta.alert(
    url: "https://alerta.io:8080/alert",
    apiKey: apiKey,
    resource: "example-resource",
    event: "Example event",
    environment: "Production",
    severity: severity,
    service: ["example-service"],
    group: "example-group",
    value: string(v: lastReported._value),
    text: "Service is ${severity}. The last reported value was ${string(v: lastReported._value)}.",
    tags: ["ex1", "ex2"],
    attributes: {},
    origin: "InfluxDB",
    type: "exampleAlertType",
    timestamp: now(),
)

此页是否对您有帮助?

感谢您的反馈!


Flux 的未来

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

阅读更多

现已全面上市

InfluxDB 3 Core 和 Enterprise

快速启动。更快扩展。

获取更新

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

有关更多信息,请查看