http发布通知未发送到服务器

时间:2015-12-17 07:16:11

标签: http notifications http-post bosun

我正在尝试从bosun(使用docker image)获取警报通知,当我在客户端vm使用bosun的UI时cpu使用率很高时,它显示出危急情况但没有发送通知,也找到了调试配置文件的方法。 我的配置文件包含 -

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
}

我的日志文件&#34; ./ var / log / supervisor / bosun-stderr --- supervisor-nhXZKo.log&#34;包含 -

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 个答案:

答案 0 :(得分:0)

似乎人们没有得到任何通知的两个最常见的原因是:

  1. Bosun以安静模式运行,禁止所有通知。当使用#include <cstdint> #include <iostream> #include <utility> template<typename Class> struct hasRead { private: template<typename T> static constexpr auto check(T *) -> typename std::is_same< decltype(std::declval<T>().read(std::declval<uint16_t>())), uint8_t>::type; template<typename> static constexpr std::false_type check(...); typedef decltype(check<Class>(0)) type; public: static constexpr bool value = type::value; }; struct X { uint8_t read(uint16_t x) { return 3; } }; struct Y { uint8_t read(uint8_t x) { return 3; } }; struct Z { uint8_t read(int64_t x) { return 3; } }; static_assert(hasRead<X>, ""); static_assert(hasRead<Y>, ""); static_assert(hasRead<Z>, ""); 开关运行bosun时就是这种情况。
  2. 误解了博森的警报工作流程。在其生命周期中一直很严重的事件(尚未关闭)将不会重新通知(请参阅事件的生命周期](http://bosun.org/usage#the-lifetime-of-an-incident)部分文档。