From 8f47b2742ed518d3c42e258c98b5f7137ea78f73 Mon Sep 17 00:00:00 2001 From: Ashish Gaurav Date: Fri, 11 Mar 2022 14:13:03 +0530 Subject: [PATCH 1/3] fix #52 : allow dash variable to be wildcards Took 40 minutes --- libs/overview.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/overview.go b/libs/overview.go index 503b1ee..44cdda7 100644 --- a/libs/overview.go +++ b/libs/overview.go @@ -31,7 +31,7 @@ func giveWhereClause(dashVars []string) string { var clauses []string for _, v := range dashVars { - clauses = append(clauses, fmt.Sprintf("(\"{{%s}}\"=\"*\" or %s=\"{{%s}}\")", v, v, v)) + clauses = append(clauses, fmt.Sprintf(`( %s matches "{{%s}}" )`, v, v)) } wherePart := "| where " + strings.Join(clauses, " and ") From 6f9cba247d8ba212219dd8d5eeb1015679cbe5bb Mon Sep 17 00:00:00 2001 From: Ashish Gaurav Date: Fri, 11 Mar 2022 14:14:50 +0530 Subject: [PATCH 2/3] fix #53 : use timezone field in the yaml for monitor notifications Took 2 minutes --- README.md | 1 + libs/monitor.go | 12 ++++++++++++ libs/templates/terra/monitor.tf.gotf | 2 +- samples/logs/drift-calculation.yaml | 1 + samples/logs/ingest-lag-timeslice-budgeting.yaml | 1 + samples/logs/trend-calculation.yaml | 2 ++ samples/tracing/checkout-latency.yaml | 1 + 7 files changed, 19 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index bac4726..4afc086 100644 --- a/README.md +++ b/README.md @@ -58,6 +58,7 @@ alerts: notifications: # one or more notification channels - connectionType: 'Email' recipients: 'youremailid@email.com' + timeZone: 'PST' triggerFor: - Warning - ResolvedWarning diff --git a/libs/monitor.go b/libs/monitor.go index 37129e8..51ffdf4 100644 --- a/libs/monitor.go +++ b/libs/monitor.go @@ -4,6 +4,7 @@ import ( "bytes" "sort" "text/template" + "time" ) type SLOMonitorConfig struct { @@ -125,6 +126,7 @@ func MonitorConfigFromOpenSLO(sloConf SLO) (*SLOMonitorConfig, error) { for _, alert := range alertTmplParams { sortedNotifs := make([]Notification, len(alert.Notifications)) + copy(sortedNotifs, alert.Notifications) sort.Slice(sortedNotifs, func(i, j int) bool { return GiveStructCompare(sortedNotifs[i], sortedNotifs[j]) @@ -175,3 +177,13 @@ func ConvertToBurnRateTmplParams(alerts []BurnRate, target, timesliceTarget floa return tmplAlertsParams } + +func giveLocalTimeZone() string { + loc, err := time.LoadLocation("Local") + + if err != nil { + log.Fatal(err) + } + + return loc.String() +} diff --git a/libs/templates/terra/monitor.tf.gotf b/libs/templates/terra/monitor.tf.gotf index 6d1ff61..b48f435 100644 --- a/libs/templates/terra/monitor.tf.gotf +++ b/libs/templates/terra/monitor.tf.gotf @@ -55,7 +55,7 @@ QUERY {{end}} ] subject = "SLO breach alert: {{$.Service}} - {{$.Name}}" - time_zone = "PST" + time_zone = {{if neq $n.TimeZone "" }}"{{$n.TimeZone}}"{{else}}"PST"{{end}} message_body = "{{`{{Description}} \n Result : {{ResultsJson}}\n Alert: {{AlertResponseURL}}`}}" {{else}} connection_id = "{{$n.ConnectionID}}" diff --git a/samples/logs/drift-calculation.yaml b/samples/logs/drift-calculation.yaml index 47bfc5b..ca2af2e 100644 --- a/samples/logs/drift-calculation.yaml +++ b/samples/logs/drift-calculation.yaml @@ -36,6 +36,7 @@ alerts: - connectionType: 'Email' recipients: - 'agaurav@sumologic.com' + timeZone: 'PST' triggerFor: - Warning - ResolvedWarning diff --git a/samples/logs/ingest-lag-timeslice-budgeting.yaml b/samples/logs/ingest-lag-timeslice-budgeting.yaml index fb0f00a..600d647 100644 --- a/samples/logs/ingest-lag-timeslice-budgeting.yaml +++ b/samples/logs/ingest-lag-timeslice-budgeting.yaml @@ -45,6 +45,7 @@ alerts: - connectionType: 'Email' recipients: - 'agaurav@sumologic.com' + timeZone: 'PST' triggerFor: - Warning - ResolvedWarning diff --git a/samples/logs/trend-calculation.yaml b/samples/logs/trend-calculation.yaml index cff3d31..8edbb15 100644 --- a/samples/logs/trend-calculation.yaml +++ b/samples/logs/trend-calculation.yaml @@ -40,6 +40,7 @@ alerts: - connectionType: 'Email' recipients: - 'agaurav@sumologic.com' + timeZone: 'PST' triggerFor: - Warning - ResolvedWarning @@ -51,6 +52,7 @@ alerts: - connectionType: 'Email' recipients: - 'agaurav@sumologic.com' + timeZone: 'PST' triggerFor: - Warning - ResolvedWarning diff --git a/samples/tracing/checkout-latency.yaml b/samples/tracing/checkout-latency.yaml index a03a12c..14ebb1d 100644 --- a/samples/tracing/checkout-latency.yaml +++ b/samples/tracing/checkout-latency.yaml @@ -50,6 +50,7 @@ alerts: - connectionType: 'Email' recipients: - 'agaurav@sumologic.com' + timeZone: 'PST' triggerFor: - Warning - ResolvedWarning From 80b6e169c6b23c7bdab7cf85918b78a15c62df6e Mon Sep 17 00:00:00 2001 From: Ashish Gaurav Date: Fri, 11 Mar 2022 14:16:36 +0530 Subject: [PATCH 3/3] fix #53 : use timezone field in the yaml for monitor notifications Took 2 minutes --- libs/templates/terra/monitor.tf.gotf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/templates/terra/monitor.tf.gotf b/libs/templates/terra/monitor.tf.gotf index b48f435..83c7695 100644 --- a/libs/templates/terra/monitor.tf.gotf +++ b/libs/templates/terra/monitor.tf.gotf @@ -55,7 +55,7 @@ QUERY {{end}} ] subject = "SLO breach alert: {{$.Service}} - {{$.Name}}" - time_zone = {{if neq $n.TimeZone "" }}"{{$n.TimeZone}}"{{else}}"PST"{{end}} + time_zone = {{if ne $n.TimeZone "" }}"{{$n.TimeZone}}"{{else}}"PST"{{end}} message_body = "{{`{{Description}} \n Result : {{ResultsJson}}\n Alert: {{AlertResponseURL}}`}}" {{else}} connection_id = "{{$n.ConnectionID}}"