This is an automated email from the ASF dual-hosted git repository.

zhongxjian pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/dubbo-kubernetes.git


The following commit(s) were added to refs/heads/master by this push:
     new d71e5b2f Fix dingtalk (#326)
d71e5b2f is described below

commit d71e5b2f760f7aa49e39dd05bb677e8fd6305771
Author: mfordjody <[email protected]>
AuthorDate: Sat Sep 7 19:31:55 2024 +0800

    Fix dingtalk (#326)
    
    * [horus] Add alarm framework
    
    Add License Check
    
    * [horus] fix dingtalk alert
---
 app/horus/core/alert/dingtalk.go | 42 ++++++++++++++++++++--------------------
 deploy/horus/horus.yaml          |  6 +++---
 2 files changed, 24 insertions(+), 24 deletions(-)

diff --git a/app/horus/core/alert/dingtalk.go b/app/horus/core/alert/dingtalk.go
index 75b16e5b..099a00ee 100644
--- a/app/horus/core/alert/dingtalk.go
+++ b/app/horus/core/alert/dingtalk.go
@@ -26,20 +26,6 @@ import (
 
 const Title = "钉钉机器人"
 
-type content struct {
-       Content string `json:"content"`
-}
-
-type at struct {
-       AtMobiles []string `json:"atMobiles"`
-}
-
-type Message struct {
-       MessageType string  `json:"messageType"`
-       Text        content `json:"text"`
-       At          at      `json:"at"`
-}
-
 type T struct {
        At struct {
                AtMobiles []string `json:"atMobiles"`
@@ -52,23 +38,37 @@ type T struct {
        Msgtype string `json:"msgtype"`
 }
 
+type content struct {
+       Content string `json:"content"`
+}
+
+type at struct {
+       AtMobiles []string `json:"atMobiles"`
+}
+
+type Message struct {
+       MsgType string  `json:"msgtype"`
+       Text    content `json:"text"`
+       At      at      `json:"at"`
+}
+
 func DingTalkSend(dk *config.DingTalkConfiguration, msg string) {
-       dtm := Message{MessageType: "text"}
+       dtm := Message{MsgType: "text"}
        dtm.Text.Content = fmt.Sprintf("%s\n"+
-               "【日志详细信息:%s】", Title, msg)
+               "【日志:%s】", Title, msg)
        dtm.At.AtMobiles = dk.AtMobiles
        bs, err := json.Marshal(dtm)
        if err != nil {
-               klog.Errorf("dingTalk json marshal err:%v\n msg:%v\n", err, msg)
+               klog.Errorf("dingTalk json marshal err:%v\n dtm:%v\n", err, dtm)
                return
        }
        res, err := http.Post(dk.WebhookUrl, "application/json", 
bytes.NewBuffer(bs))
        if err != nil {
-               klog.Errorf("push dingTalk err:%v\n msg:%v\n", err, msg)
+               klog.Errorf("send dingTalk err:%v\n msg:%v\n", err, msg)
        }
-       if res.StatusCode != 200 && res != nil {
-               klog.Errorf("push dingTalk status code err:%v\n code:%v\n 
msg:%v\n", err, res.StatusCode, msg)
+       if res != nil && res.StatusCode != 200 {
+               klog.Errorf("send dingTalk status code err:%v\n code:%v\n 
msg:%v\n", err, res.StatusCode, msg)
                return
        }
-       klog.Infof("push dingTalk success code:%v\n msg:%v\n", res.StatusCode, 
msg)
+       klog.Infof("send dingTalk success code:%v\n msg:%v\n", res.StatusCode, 
msg)
 }
diff --git a/deploy/horus/horus.yaml b/deploy/horus/horus.yaml
index 12c4ee80..533565f0 100644
--- a/deploy/horus/horus.yaml
+++ b/deploy/horus/horus.yaml
@@ -21,10 +21,10 @@ mysql:
   debug: false
 
 dingTalk:
-  webhookUrl: 
"https://oapi.dingtalk.com/robot/send?access_token=aa2f3f74d7a2504653ca89b7a673707ba1d04b6d9d320c3572e5464d8f81471e";
-  title: "工单通知处理"
+  webhookUrl: ~
+  title: ~
   atMobiles:
-    - 1500000000
+  - 1500000000
 
 slack:
   webhookUrl: ~

Reply via email to