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