0

TDengine 提供了一个名为 alert 的实用程序,通过 AlertManger 提供警报功能。

我很困惑如何添加多个警报规则?

我正在运行如下:

[root@bogon TDengine-alert]# ./alert -cfg alert.cfg
2021-12-01T17:11:35.827+0800 INFO log/log.go:44 upgrading database to version: 0
2021-12-01T17:11:35.854+0800 INFO log/log.go:49 total 0 rules loaded
2021-12-01T17:11:35.855+0800 INFO log/log.go:44 Listening at port: 8100
2021-12-01T17:11:55.281+0800 ERROR log/log.go:64 failed to parse rule: invalid character 'ã' looking for beginning of object key string
github.com/taosdata/alert/utils/log.Error
/home/ubuntu/workroom/jenkins/TDinternal/community/alert/utils/log/log.go:64
github.com/taosdata/alert/app.onUpdateRule
/home/ubuntu/workroom/jenkins/TDinternal/community/alert/app/app.go:78
net/http.HandlerFunc.ServeHTTP
/home/ubuntu/soft/go/src/net/http/server.go:2042
net/http.(*ServeMux).ServeHTTP
/home/ubuntu/soft/go/src/net/http/server.go:2417
main.(*httpHandler).ServeHTTP
/home/ubuntu/workroom/jenkins/TDinternal/community/alert/cmd/alert/main.go:31
net/http.serverHandler.ServeHTTP
/home/ubuntu/soft/go/src/net/http/server.go:2843
net/http.(*conn).serve
/home/ubuntu/soft/go/src/net/http/server.go:1925
2021-12-01T17:11:55.281+0800 DEBUG log/log.go:39 [POST] /api/update-rule 1.113836ms
^C'Ctrl + C' received, exiting...
2021-12-01T17:15:14.736+0800 ERROR log/log.go:64 http: Server closed
github.com/taosdata/alert/utils/log.Error
/home/ubuntu/workroom/jenkins/TDinternal/community/alert/utils/log/log.go:64
main.serveWeb.func1
/home/ubuntu/workroom/jenkins/TDinternal/community/alert/cmd/alert/main.go:45

我添加了一些规则后,它会报告错误。

[root@bogon TDengine-alert]# cat alert.cfg { "port": 8100, "database": "file:alert.db", "tdengine": "root:root@/tcp(127.0.0.1:0) /", "log": { "level": "debug", "path": "" }, "receivers": { "alertManager": "http://127.0.0.1:9093/api/v1/alerts" , "控制台": true } }

[root@bogon ruite]# cat rule.json

{
  "name": "d1001_50",
  "sql": "select avg(tdata) as avgVal from test.d1001 order by ts desc limit 50",
  "expr": "avgVal > 50",
  "for": "10s",
  "period": "1s",
  "labels": {
    "ruleName": "d1001_50"
  },
  "annotations": {
    "summary": "average value among devices: {{$values.avgVal}}"
  }
}

[root@bogon ruite]# curl -d '@rule.json' http://localhost:8100/api/update-rule [root@bogon ruite]# curl http://localhost:8100/api/list-rule null [root@bogon ruite]#

4

0 回答 0