opsgenie.endpoint() 函数
opsgenie.endpoint()
是用户贡献的函数,由包作者维护。
opsgenie.endpoint()
使用表行中的数据向 Opsgenie 发送警报消息。
用法
opsgenie.endpoint 是一个工厂函数,输出另一个函数。输出函数需要一个 mapFn
参数。
mapFn
一个构建用于生成 POST 请求的记录的函数。需要一个 r
参数。
mapFn
接受一个表行 (r
) 并返回一个记录,该记录必须包含以下字段
- message
- alias
- description
- priority
- responders
- tags
- actions
- details
- visibleTo
有关更多信息,请参阅 opsgenie.sendAlert
。
函数类型签名
(
apiKey: string,
?entity: string,
?url: string,
) => (
mapFn: (
r: A,
) => {
B with
visibleTo: [string],
tags: E,
responders: [string],
priority: string,
message: string,
details: D,
description: string,
alias: string,
actions: C,
},
) => (<-tables: stream[A]) => stream[{A with _sent: string}] where D: Stringable
有关更多信息,请参阅函数类型签名。
参数
url
Opsgenie API URL。默认为 https://api.opsgenie.com/v2/alerts
。
apiKey
(必需) (必需)Opsgenie API 授权密钥。
entity
用于指定警报域的警报实体。
示例
将严重状态发送到 Opsgenie
import "influxdata/influxdb/secrets"
import "contrib/sranka/opsgenie"
apiKey = secrets.get(key: "OPSGENIE_APIKEY")
endpoint = opsgenie.endpoint(apiKey: apiKey)
crit_statuses =
from(bucket: "example-bucket")
|> range(start: -1m)
|> filter(fn: (r) => r._measurement == "statuses" and status == "crit")
crit_statuses
|> endpoint(
mapFn: (r) =>
({
message: "Great Scott!- Disk usage is: ${r.status}.",
alias: "disk-usage-${r.status}",
description: "",
priority: "P3",
responders: ["user:john@example.com", "team:itcrowd"],
tags: [],
entity: "my-lab",
actions: [],
details: "{}",
visibleTo: [],
}),
)()
此页面是否有帮助?
感谢您的反馈!