From f419aeb74210584fa1196a582153d31630b99587 Mon Sep 17 00:00:00 2001 From: "taekyu.kang" Date: Tue, 30 Apr 2024 09:59:00 +0900 Subject: [PATCH] trivial. add debug log for policyNotification --- internal/delivery/http/system-notification.go | 20 +++++++++---------- pkg/domain/system-notification.go | 2 ++ 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/internal/delivery/http/system-notification.go b/internal/delivery/http/system-notification.go index 1df9eea4..150af690 100644 --- a/internal/delivery/http/system-notification.go +++ b/internal/delivery/http/system-notification.go @@ -1,6 +1,7 @@ package http import ( + "bytes" "fmt" "io" "net/http" @@ -47,19 +48,18 @@ func (h *SystemNotificationHandler) CreateSystemNotification(w http.ResponseWrit INFO[2023-04-26 18:14:11] {"receiver":"webhook-systemNotification","status":"firing","systemNotifications":[{"status":"firing","labels":{"systemNotificationname":"TestSystemNotification1"},"annotations":{},"startsAt":"2023-04-26T09:14:01.489894015Z","endsAt":"0001-01-01T00:00:00Z","generatorURL":"","fingerprint":"0dafe30dffce9487"}],"groupLabels":{"systemNotificationname":"TestSystemNotification1"},"commonLabels":{"systemNotificationname":"TestSystemNotification1"},"commonAnnotations":{},"externalURL":"http://lma-systemNotificationmanager.lma:9093","version":"4","groupKey":"{}:{systemNotificationname=\"TestSystemNotification1\"}","truncatedSystemNotifications":0} */ - /* - // webhook 으로 부터 받은 body parse - bodyBytes, err := io.ReadAll(r.Body) - if err != nil { - log.Error(r.Context(),err) - } - bodyString := string(bodyBytes) - log.Info(r.Context(),bodyString) - */ + // webhook 으로 부터 받은 body parse + bodyBytes, err := io.ReadAll(r.Body) + if err != nil { + log.Error(r.Context(), err) + } + r.Body = io.NopCloser(bytes.NewBuffer(bodyBytes)) + bodyString := string(bodyBytes) + log.Info(r.Context(), bodyString) // 외부로부터(systemNotification manager) 오는 데이터이므로, dto 변환없이 by-pass 처리한다. input := domain.CreateSystemNotificationRequest{} - err := UnmarshalRequestInput(r, &input) + err = UnmarshalRequestInput(r, &input) if err != nil { ErrorJSON(w, r, err) return diff --git a/pkg/domain/system-notification.go b/pkg/domain/system-notification.go index 27d9dc5b..8ba0f1e8 100644 --- a/pkg/domain/system-notification.go +++ b/pkg/domain/system-notification.go @@ -60,6 +60,8 @@ type SystemNotificationRequest struct { Discriminative string `json:"discriminative"` AlertType string `json:"alertType"` SystemNotificationRuleId string `json:"systemNotificationRuleId"` + PolicyName string `json:"policyName"` + PolicyTemplate string `json:"policyTemplate"` } `json:"annotations"` }