-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Adding Webhooks to Index Rate Alert
adding the ability to add webhooks for Index Rate Alerts Ref:[LOG-9667](https://mezmo.atlassian.net/browse/LOG-9667)
- Loading branch information
Showing
6 changed files
with
231 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -164,6 +164,42 @@ func TestIndexRateAlert_ErrorChannels(t *testing.T) { | |
}) | ||
} | ||
|
||
func TestIndexRateAlert_ErrorInvalidTokenWebhookBodyTemplate(t *testing.T) { | ||
iraArgs := map[string]string{ | ||
"max_lines": `3`, | ||
"max_z_score": `3`, | ||
"threshold_alert": `"separate"`, | ||
"frequency": `"hourly"`, | ||
"enabled": `false`, | ||
} | ||
|
||
chArgs := map[string]map[string]string{ | ||
"channels": { | ||
"email": `["[email protected]"]`, | ||
}, | ||
"webhook_channel": { | ||
"url": `"https://something.com"`, | ||
"method": `"POST"`, | ||
"headers": `{ | ||
field2 = "value2" | ||
}`, | ||
"bodytemplate": `jsonencode({ | ||
something = "{{maxLines}}" | ||
})`, | ||
}, | ||
} | ||
|
||
resource.Test(t, resource.TestCase{ | ||
Providers: testAccProviders, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: fmtTestConfigResource("index_rate_alert", "test_config", globalPcArgs, iraArgs, chArgs, nilLst), | ||
ExpectError: regexp.MustCompile("Invalid bodyTemplate: {{maxLines}} is not a valid token"), | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func TestIndexRateAlert_Basic(t *testing.T) { | ||
iraArgs := map[string]string{ | ||
"max_lines": `3`, | ||
|
@@ -179,6 +215,16 @@ func TestIndexRateAlert_Basic(t *testing.T) { | |
"slack": `["https://hooks.slack.com/KEY"]`, | ||
"pagerduty": `["ndt3k75rsw520d8t55dv35decdyt3mkcb3r"]`, | ||
}, | ||
"webhook_channel": { | ||
"url" : `"https://something.com"`, | ||
"method": `"POST"`, | ||
"headers" : `{ | ||
field2 = "value2" | ||
}`, | ||
"bodytemplate" :`jsonencode({ | ||
something = "something" | ||
})`, | ||
}, | ||
} | ||
|
||
iraUpdArgs := map[string]string{ | ||
|
@@ -195,6 +241,16 @@ func TestIndexRateAlert_Basic(t *testing.T) { | |
"slack": `["https://hooks.slack.com/UPDATED_KEY", "https://hooks.slack.com/KEY_2"]`, | ||
"pagerduty": `["new3k75rsw520d8t55dv35decdyt3mkcnew"]`, | ||
}, | ||
"webhook_channel": { | ||
"url" : `"https://something.com"`, | ||
"method": `"PUT"`, | ||
"headers" : `{ | ||
field2 = "value2" | ||
}`, | ||
"bodytemplate" :`jsonencode({ | ||
something = "!something" | ||
})`, | ||
}, | ||
} | ||
|
||
createdEmails := strings.Split( | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters