Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

trivial. add debug log for policyNotification #450

Merged
merged 1 commit into from
Apr 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions internal/delivery/http/system-notification.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package http

import (
"bytes"
"fmt"
"io"
"net/http"
Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions pkg/domain/system-notification.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
}

Expand Down
Loading