Skip to content

Commit b0b8056

Browse files
authored
Merge pull request #56 from OpenSLO/agaurav-dev
[sumo] add timezone support for alert notifications
2 parents 153a924 + 8cb4751 commit b0b8056

8 files changed

Lines changed: 20 additions & 2 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ alerts:
5858
notifications: # one or more notification channels
5959
- connectionType: 'Email'
6060
recipients: 'youremailid@email.com'
61+
timeZone: 'PST'
6162
triggerFor:
6263
- Warning
6364
- ResolvedWarning

libs/monitor.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"bytes"
55
"sort"
66
"text/template"
7+
"time"
78
)
89

910
type SLOMonitorConfig struct {
@@ -125,6 +126,7 @@ func MonitorConfigFromOpenSLO(sloConf SLO) (*SLOMonitorConfig, error) {
125126
for _, alert := range alertTmplParams {
126127

127128
sortedNotifs := make([]Notification, len(alert.Notifications))
129+
128130
copy(sortedNotifs, alert.Notifications)
129131
sort.Slice(sortedNotifs, func(i, j int) bool {
130132
return GiveStructCompare(sortedNotifs[i], sortedNotifs[j])
@@ -175,3 +177,13 @@ func ConvertToBurnRateTmplParams(alerts []BurnRate, target, timesliceTarget floa
175177

176178
return tmplAlertsParams
177179
}
180+
181+
func giveLocalTimeZone() string {
182+
loc, err := time.LoadLocation("Local")
183+
184+
if err != nil {
185+
log.Fatal(err)
186+
}
187+
188+
return loc.String()
189+
}

libs/overview.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ func giveWhereClause(dashVars []string) string {
3131

3232
var clauses []string
3333
for _, v := range dashVars {
34-
clauses = append(clauses, fmt.Sprintf("(\"{{%s}}\"=\"*\" or %s=\"{{%s}}\")", v, v, v))
34+
clauses = append(clauses, fmt.Sprintf(`( %s matches "{{%s}}" )`, v, v))
3535
}
3636

3737
wherePart := "| where " + strings.Join(clauses, " and ")

libs/templates/terra/monitor.tf.gotf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ QUERY
5555
{{end}}
5656
]
5757
subject = "SLO breach alert: {{$.Service}} - {{$.Name}}"
58-
time_zone = "PST"
58+
time_zone = {{if ne $n.TimeZone "" }}"{{$n.TimeZone}}"{{else}}"PST"{{end}}
5959
message_body = "{{`{{Description}} \n Result : {{ResultsJson}}\n Alert: {{AlertResponseURL}}`}}"
6060
{{else}}
6161
connection_id = "{{$n.ConnectionID}}"

samples/logs/drift-calculation.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ alerts:
3636
- connectionType: 'Email'
3737
recipients:
3838
- 'agaurav@sumologic.com'
39+
timeZone: 'PST'
3940
triggerFor:
4041
- Warning
4142
- ResolvedWarning

samples/logs/ingest-lag-timeslice-budgeting.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ alerts:
4545
- connectionType: 'Email'
4646
recipients:
4747
- 'agaurav@sumologic.com'
48+
timeZone: 'PST'
4849
triggerFor:
4950
- Warning
5051
- ResolvedWarning

samples/logs/trend-calculation.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ alerts:
4040
- connectionType: 'Email'
4141
recipients:
4242
- 'agaurav@sumologic.com'
43+
timeZone: 'PST'
4344
triggerFor:
4445
- Warning
4546
- ResolvedWarning
@@ -51,6 +52,7 @@ alerts:
5152
- connectionType: 'Email'
5253
recipients:
5354
- 'agaurav@sumologic.com'
55+
timeZone: 'PST'
5456
triggerFor:
5557
- Warning
5658
- ResolvedWarning

samples/tracing/checkout-latency.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ alerts:
5050
- connectionType: 'Email'
5151
recipients:
5252
- 'agaurav@sumologic.com'
53+
timeZone: 'PST'
5354
triggerFor:
5455
- Warning
5556
- ResolvedWarning

0 commit comments

Comments
 (0)