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"],
)
此页面是否对您有帮助?
感谢您的反馈!