文档文档

opsgenie.sendAlert() 函数

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

opsgenie.sendAlert() 发送警报消息到 Opsgenie。

函数类型签名
(
    apiKey: string,
    message: string,
    ?actions: A,
    ?alias: string,
    ?description: string,
    ?details: B,
    ?entity: string,
    ?priority: string,
    ?responders: [string],
    ?tags: C,
    ?url: string,
    ?visibleTo: [string],
) => int where B: Stringable

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

参数

url

Opsgenie API URL。默认为 https://api.opsgenie.com/v2/alerts

apiKey

(必需) (必需)Opsgenie API 授权密钥。

message

(必需) (必需)警报消息文本。130 个字符或更少。

alias

用于去重警报的 Opsgenie 别名。250 个字符或更少。默认为 message

description

警报描述。15000 个字符或更少。

priority

Opsgenie 警报优先级。

有效值包括

  • P1
  • P2
  • P3 (默认)
  • P4
  • P5

responders

响应者团队或用户列表。用户使用 user: 前缀,团队使用 teams: 前缀。

tags

警报标签。

entity

用于指定警报域的警报实体。

actions

警报可用的操作列表。

details

其他警报详细信息。必须是键值字符串对的 JSON 编码映射。

visibleTo

无需发送通知即可查看警报的团队和用户列表。用户使用 user: 前缀,团队使用 teams: 前缀。

示例

发送上次报告的状态到 Opsgenie

import "influxdata/influxdb/secrets"
import "contrib/sranka/opsgenie"

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

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

opsgenie.sendAlert(
    apiKey: apiKey,
    message: "Disk usage is: ${lastReported.status}.",
    alias: "example-disk-usage",
    responders: ["user:john@example.com", "team:itcrowd"],
)

此页面是否对您有帮助?

感谢您的反馈!


Flux 的未来

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

阅读更多

现已全面上市

InfluxDB 3 Core 和 Enterprise

快速启动。更快扩展。

获取更新

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

有关更多信息,请查看