gpt4 book ai didi

Bosun 通过 json post body 发送警报特定数据

转载 作者:行者123 更新时间:2023-12-01 13:50:32 24 4
gpt4 key购买 nike

使用 Bosun 时,您可以使用带有指定 json 正文的警报​​通知发送 HTTP POST 请求,如下所示:

post = myurl
body = {"foo": "bar"}

我有一个外部应用程序,它监听 myurl 并根据帖子正文的上下文发送和发送电子邮件。有没有一种方法可以对帖子正文进行通用模板化以表示触发的警报详细信息。

理想情况下是这样的(语法只是为了举例):

 post = myurl
body = {"body": "Alert.name, Alert.host, ..."}

最佳答案

您想要的是在通知 的定义中使用post action。您还可以通过在通知中使用 body 指令来覆盖默认的帖子正文。然后,您可以使用 json 模板函数和 contentType 将其设置为 JSON。

下面是两个示例,来自 notification documentation .特别是,我认为第二个例子就是你所追求的。

# post to a slack.com chatroom 
notification slack{
post = https://company.slack.com/services/hooks/incoming-webhook?token=TOKEN
body = payload={"username": "bosun", "text": {{.|json}}, "icon_url": "http://stackexchange.github.io/bosun/public/bosun-logo-mark.svg"}
}

#post json
notification json{
post = https://someurl.com/submit
body = {"text": {{.|json}}, apiKey="2847abc23"}
contentType = application/json
}

关于Bosun 通过 json post body 发送警报特定数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32074463/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com