gpt4 book ai didi

http post 通知未发送到服务器

转载 作者:可可西里 更新时间:2023-11-01 16:41:28 26 4
gpt4 key购买 nike

我正在尝试从 bosun(使用 docker 图像)获取警报通知,当我的 cpu 使用率在使用 bosun 的 UI 的客户端 vm 上很高时,它显示出临界状态但不发送通知,同时也在寻找调试方法配置文件。我的配置文件包含-

tsdbHost = localhost:4242
stateFile = /data/bosun.state

template test {
body = `Alert definition:
Name: {{.Alert.Name}}
Crit: {{.Alert.Crit}}
Tags:
<table>
{{range $k, $v := .Group}}
<tr><td>{{$k}}</td><td>{{$v}}</td></tr>
{{end}}
</table>`
subject = {{.Last.Status}}: {{.Alert.Name}} on {{.Group.host}}
}

notification json {
post = http://localhost:8080/alert
body = {"text": {{.|json}}}
contentType = application/json
next = json
timeout = 5s
print = true
}

alert test {
template = test
$speed = avg(q("sum:rate{counter,,1}:linux.cpu{host=aaa}", "1h", ""))
crit = $speed>195
warn = $speed>180
critNotification = json
warnNotification = json
}

我的日志文件“./var/log/supervisor/bosun-stderr---supervisor-nhXZKo.log”包含-

2015/12/17 06:27:19 info: search.go:199: Backing up last data to redis
2015/12/17 06:29:20 info: search.go:199: Backing up last data to redis
2015/12/17 06:30:08 info: notify.go:122: Batching and sending unknown notifications
2015/12/17 06:30:08 info: notify.go:152: Done sending unknown notifications
2015/12/17 06:30:13 info: bolt.go:79: wrote notifications: 48.00B
2015/12/17 06:30:13 info: bolt.go:79: wrote silence: 140.00B
2015/12/17 06:30:13 info: bolt.go:79: wrote status: 767.00B
2015/12/17 06:30:13 info: bolt.go:103: save to db complete
2015/12/17 06:31:20 info: search.go:199: Backing up last data to redis
2015/12/17 06:33:21 info: search.go:199: Backing up last data to redis

我的本​​地运行的服务器文件包含-

 package main
import (
"fmt"
"log"
"net/http"
)
func handleAlerts(res http.ResponseWriter, req *http.Request) {
fmt.Print(req.Body)
fmt.Printf("request enjoy")
}
func main() {
http.HandleFunc("/alert", handleAlerts)
fmt.Printf("Starting server on 8080...")
err := http.ListenAndServe(":8080", nil)
if err != nil {
fmt.Println("Alerts: Server Down: ", err)
log.Fatal("Alerts: Server Down: ", err)
}
}

最佳答案

似乎人们收不到任何通知的两个最常见原因是:

  1. Bosun 正在安静模式下运行,该模式禁止所有通知。当使用 -q 开关运行 bosun 时就是这种情况。
  2. 误解了 Bosun 的提醒工作流程。在其生命周期内(尚未关闭)处于严重状态的事件将不会重新通知(请参阅文档的事件生命周期]( http://bosun.org/usage#the-lifetime-of-an-incident )部分。

关于http post 通知未发送到服务器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34328742/

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