文档文档

victorops.alert() 函数

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

victorops.alert() 向 VictorOps 发送警报。

函数类型签名
(
    messageType: A,
    url: string,
    ?entityDisplayName: B,
    ?entityID: C,
    ?monitoringTool: D,
    ?stateMessage: E,
    ?timestamp: F,
) => int

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

参数

url

(必需) VictorOps REST 端点集成 URL。

示例:https://alert.victorops.com/integrations/generic/00000000/alert/<api_key>/<routing_key><api_key><routing_key> 替换为有效的 VictorOps API 和路由密钥。

monitoringTool

监控代理名称。默认为 ""

messageType

(必需) VictorOps 消息类型(警报行为)。

有效值:

  • CRITICAL
  • WARNING
  • INFO

entityID

事件 ID。默认为 ""

entityDisplayName

事件显示名称或摘要。默认为 ""

stateMessage

详细事件消息。默认为 ""

timestamp

事件开始时间。默认为 now()

示例

向 VictorOps 发送最后报告的值和事件类型

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

apiKey = secrets.get(key: "VICTOROPS_API_KEY")
routingKey = secrets.get(key: "VICTOROPS_ROUTING_KEY")

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

victorops.alert(
    url: "https://alert.victorops.com/integrations/generic/00000000/alert/${apiKey}/${routingKey}",
    messageType:
        if lastReported._value < 1.0 then
            "CRITICAL"
        else if lastReported._value < 5.0 then
            "WARNING"
        else
            "INFO",
    entityID: "example-alert-1",
    entityDisplayName: "Example Alert 1",
    stateMessage: "Last reported cpu_idle was ${string(v: r._value)}.",
)

此页面是否对您有帮助?

感谢您的反馈!


Flux 的未来

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

阅读更多

现已全面上市

InfluxDB 3 Core 和 Enterprise

快速启动。更快扩展。

获取更新

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

有关更多信息,请查看