diff --git a/go.mod b/go.mod index 3eb0253..9768566 100644 --- a/go.mod +++ b/go.mod @@ -2,7 +2,10 @@ module github.com/lingcoder/prometheus-notifier go 1.21 -require github.com/gogf/gf/v2 v2.5.5 +require ( + github.com/gogf/gf/v2 v2.5.6 + github.com/larksuite/oapi-sdk-go/v3 v3.0.30 +) require ( github.com/BurntSushi/toml v1.3.2 // indirect @@ -14,7 +17,6 @@ require ( github.com/gorilla/websocket v1.5.0 // indirect github.com/grokify/html-strip-tags-go v0.0.1 // indirect github.com/kr/pretty v0.3.1 // indirect - github.com/larksuite/oapi-sdk-go/v3 v3.0.30 // indirect github.com/magiconair/properties v1.8.7 // indirect github.com/mattn/go-colorable v0.1.13 // indirect github.com/mattn/go-isatty v0.0.20 // indirect diff --git a/go.sum b/go.sum index a1b5b8e..ab05dd8 100644 --- a/go.sum +++ b/go.sum @@ -14,8 +14,8 @@ github.com/go-logr/logr v1.2.4 h1:g01GSCwiDw2xSZfjJ2/T9M+S6pFdcNtFYsp+Y43HYDQ= github.com/go-logr/logr v1.2.4/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= -github.com/gogf/gf/v2 v2.5.5 h1:av3xMltrJiZWs4lW5KUTTDh45qg3wUV33W5OebE+pYo= -github.com/gogf/gf/v2 v2.5.5/go.mod h1:17K/gBYrp0bHGC3XYC7bSPoywmZ6MrZHrZakTfh4eIQ= +github.com/gogf/gf/v2 v2.5.6 h1:a1UK1yUP3s+l+vPxmV91+8gTarAP9b1IEOw0W7LNl6E= +github.com/gogf/gf/v2 v2.5.6/go.mod h1:17K/gBYrp0bHGC3XYC7bSPoywmZ6MrZHrZakTfh4eIQ= github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc= diff --git a/i18n/en/alert_template.toml b/i18n/en/alert_template.toml index 05eca96..8ef0cd6 100644 --- a/i18n/en/alert_template.toml +++ b/i18n/en/alert_template.toml @@ -2,6 +2,7 @@ alert-notification = "Alert Notification" alert-level-status = "Level Status" alert-rule-name = "Rule Name" alert-rule-notes = "Rule Notes" +alert-rule-description = "Rule Description" alert-monitoring-metrics = "Monitoring Metrics" alert-trigger-time = "Trigger Time" alert-trigger-value = "Trigger Value" diff --git a/i18n/zh-CN/alert_template.toml b/i18n/zh-CN/alert_template.toml index e42abbd..dd426b3 100644 --- a/i18n/zh-CN/alert_template.toml +++ b/i18n/zh-CN/alert_template.toml @@ -2,6 +2,7 @@ alert-notification = "告警通知" alert-level-status = "级别状态" alert-rule-name = "规则名称" alert-rule-notes = "规则备注" +alert-rule-description = "规则描述" alert-monitoring-metrics = "监控指标" alert-trigger-time = "触发时间" alert-trigger-value = "触发时值" diff --git a/i18n/zh-TW/alert_template.toml b/i18n/zh-TW/alert_template.toml index 0dd8466..f82c64d 100644 --- a/i18n/zh-TW/alert_template.toml +++ b/i18n/zh-TW/alert_template.toml @@ -2,6 +2,7 @@ alert-notification = "警報通知" alert-level-status = "等級狀態" alert-rule-name = "規則名稱" alert-rule-notes = "規則備註" +alert-rule-description = "規則描述" alert-monitoring-metrics = "監控指標" alert-trigger-time = "觸發時間" alert-trigger-value = "觸發時值" diff --git a/internal/cmd/router.go b/internal/cmd/router.go index fb9f3ba..a652433 100644 --- a/internal/cmd/router.go +++ b/internal/cmd/router.go @@ -36,5 +36,3 @@ func WrapperOpenAPI(s *ghttp.Server) { api.Config.CommonResponseDataField = "Data" api.Config.IgnorePkgPath = true } - -var users = make(map[string]*ghttp.WebSocket, 0) diff --git a/internal/logic/feishu/feishu.go b/internal/logic/feishu/feishu.go index 4800038..656e44f 100644 --- a/internal/logic/feishu/feishu.go +++ b/internal/logic/feishu/feishu.go @@ -2,8 +2,6 @@ package feishu import ( "context" - "fmt" - "github.com/gogf/gf/v2/encoding/gjson" "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/util/gconv" larkcard "github.com/larksuite/oapi-sdk-go/v3/card" @@ -38,15 +36,13 @@ func (u *sFeishu) Send(ctx context.Context, req *v1.FeishuReq) error { SendingTime: time.Now().Format(time.RFC3339), } - encodeString := gjson.MustEncodeString(req) - fmt.Println(encodeString) - for i := 0; i < len(alerts); i++ { alert := alerts[i] webhookAlert.Severity = alert.Labels["severity"] webhookAlert.RuleName = alert.Labels["alertname"] webhookAlert.RuleNotes = alert.Annotations["summary"] + webhookAlert.Description = alert.Annotations["description"] webhookAlert.TriggerTime = alert.StartsAt.Format(time.RFC3339) webhookAlert.LastEvalTime = alert.EndsAt.Format(time.RFC3339) webhookAlert.TriggerValue = alert.Annotations["value"] diff --git a/internal/model/template.go b/internal/model/template.go index 08ab266..f9fc496 100644 --- a/internal/model/template.go +++ b/internal/model/template.go @@ -5,6 +5,7 @@ type WebhookAlert struct { IsRecovered bool RuleName string RuleNotes string + Description string TagsJSON string LastEvalTime string TriggerTime string