Skip to content

Commit

Permalink
增加记录开启配置
Browse files Browse the repository at this point in the history
  • Loading branch information
jikun.zhang committed Jul 14, 2021
1 parent 8c23c6c commit 0568995
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 4 deletions.
2 changes: 2 additions & 0 deletions conf/app-example.conf
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ db_driver=sqlite3
#db_user=root
#db_password=root
#db_name=prometheusalert
#是否开启告警记录 0为关闭,1为开启
AlertRecord=0

#---------------------↓webhook-----------------------
#是否开启钉钉告警通道,可同时开始多个通道0为关闭,1为开启
Expand Down
8 changes: 5 additions & 3 deletions controllers/prometheus.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ func SendMessageR(message Prometheus, rwxurl, rddurl, rfsurl, rphone, remail, rg
PhoneCallResolved, _ := beego.AppConfig.Int("phonecallresolved")
Silent, _ := beego.AppConfig.Int("silent")
PCstTime, _ := beego.AppConfig.Int("prometheus_cst_time")
Record:=beego.AppConfig.String("AlertRecord")
var ddtext, wxtext, fstext, MobileMessage, PhoneCallMessage, EmailMessage, titleend, rltext string
//对分组消息进行排序
AlerMessage := message.Alerts
Expand All @@ -124,9 +125,10 @@ func SendMessageR(message Prometheus, rwxurl, rddurl, rfsurl, rphone, remail, rg
// 消息入库
//AtTime, _ := time.ParseInLocation("2006-01-02 15:04:05", At, time.Local)
//EtTime, _ := time.ParseInLocation("2006-01-02 15:04:05", Et, time.Local)
models.AddAlertRecord(RMessage.Labels.SendType, RMessage.Labels.Alertname, RMessage.Labels.Severity, RMessage.Labels.BusinessType, RMessage.Labels.Instance,
At, Et, RMessage.Annotations.Summary, RMessage.Annotations.Description, "", "", "")

if Record == "1" {
models.AddAlertRecord(RMessage.Labels.SendType, RMessage.Labels.Alertname, RMessage.Labels.Severity, RMessage.Labels.BusinessType, RMessage.Labels.Instance,
At, Et, RMessage.Annotations.Summary, RMessage.Annotations.Description, "", "", "")
}
if RMessage.Status == "resolved" {
titleend = "故障恢复信息"
model.AlertsFromCounter.WithLabelValues("prometheus", RMessage.Annotations.Description, RMessage.Labels.Level, RMessage.Labels.Instance, "resolved").Add(1)
Expand Down
2 changes: 2 additions & 0 deletions example/helm/prometheusalert/config/app.conf
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ db_driver=sqlite3
#db_user=root
#db_password=root
#db_name=prometheusalert
#是否开启告警记录 0为关闭,1为开启
AlertRecord=0

#---------------------↓webhook-----------------------
#是否开启钉钉告警通道,可同时开始多个通道0为关闭,1为开启
Expand Down
4 changes: 3 additions & 1 deletion example/kubernetes/PrometheusAlert-Deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ data:
#db_user=root
#db_password=root
#db_name=prometheusalert
#是否开启告警记录 0为关闭,1为开启
AlertRecord=0
#---------------------↓webhook-----------------------
#是否开启钉钉告警通道,可同时开始多个通道0为关闭,1为开启
open-dingding=1
Expand Down
Binary file modified example/linux/PrometheusAlert
Binary file not shown.
2 changes: 2 additions & 0 deletions example/linux/conf/app.conf
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ db_driver=sqlite3
#db_user=root
#db_password=root
#db_name=prometheusalert
#是否开启告警记录 0为关闭,1为开启
AlertRecord=0

#---------------------↓webhook-----------------------
#是否开启钉钉告警通道,可同时开始多个通道0为关闭,1为开启
Expand Down
Binary file modified example/windows/PrometheusAlert.exe
Binary file not shown.
2 changes: 2 additions & 0 deletions example/windows/conf/app.conf
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ db_driver=sqlite3
#db_user=root
#db_password=root
#db_name=prometheusalert
#是否开启告警记录 0为关闭,1为开启
AlertRecord=0

#---------------------↓webhook-----------------------
#是否开启钉钉告警通道,可同时开始多个通道0为关闭,1为开启
Expand Down

0 comments on commit 0568995

Please sign in to comment.