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

v1.0.4 #6

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
4 changes: 2 additions & 2 deletions common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,13 @@ func NewConfig() *Config {
ignoreSlackText := getEnvWithFallback("IGNORE_SLACK_TEXT", strconv.FormatBool(*ignoreSlackTextFlag))
ignoreSlackTextBool, err := strconv.ParseBool(ignoreSlackText)
if err != nil {
klog.Fatal("Invalid value for IGNORE_SLACK_TEXT")
klog.Fatal("Invalid value for IGNORE_SLACK_TEXT: ", err.Error())
}

ignoreSlackTitle := getEnvWithFallback("IGNORE_SLACK_TITLE", strconv.FormatBool(*ignoreSlackTitleFlag))
ignoreSlackTitleBool, err := strconv.ParseBool(ignoreSlackTitle)
if err != nil {
klog.Fatal("Invalid value for IGNORE_SLACK_TITLE")
klog.Fatal("Invalid value for IGNORE_SLACK_TITLE", err.Error())
}

// api token is mandatory
Expand Down
27 changes: 20 additions & 7 deletions logzio_alerts_client/logzio_alerts_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,14 @@ import (
)

const (
refIdA = "A"
refIdB = "B"
expressionString = "__expr__"
queryType = "query"
alertFolder = "prometheus-alerts"
randomStringLength = 5
grafanaDefaultReceiver = "default-email"
refIdA = "A"
refIdB = "B"
expressionString = "__expr__"
queryType = "query"
alertFolder = "prometheus-alerts"
randomStringLength = 5
grafanaDefaultReceiver = "default-email"
alertManagerConfigSizeLimitBytes = 66560
)

// ReduceQueryModel represents a reduce query for time series data
Expand Down Expand Up @@ -150,6 +151,18 @@ func (l *LogzioGrafanaAlertsClient) SetNotificationPolicyTreeFromRouteTree(route
existingContactPoints[contactPoint.Name] = true
}
notificationPolicyTree := l.convertRouteTreeToNotificationPolicyTree(routeTree, existingContactPoints)
// Serialize notificationPolicyTree to JSON to check if it exceeds `alertManagerConfigSizeLimitBytes`
notificationPolicyTreeJSON, err := json.Marshal(notificationPolicyTree)
if err != nil {
klog.Errorf("Failed to serialize notification policy tree: %v", err)
return
}
// Check if serialized notificationPolicyTree exceeds 65KB
if len(notificationPolicyTreeJSON) > alertManagerConfigSizeLimitBytes {
klog.Errorf("Serialized notification policy tree exceeds 65KB limit, size: %d bytes", len(notificationPolicyTreeJSON))
return
}

err = l.logzioNotificationPolicyClient.SetupGrafanaNotificationPolicyTree(notificationPolicyTree)
if err != nil {
klog.Errorf("Failed to create notification policy tree: %v", err)
Expand Down
Loading