Skip to content

Commit 940ba27

Browse files
feat: CLOUDP-380505 Update Alert Configuration Resource (#1585)
Co-authored-by: Rakhul S Prakash <rakhul.s.prakash@peerislands.io>
1 parent 605cda5 commit 940ba27

12 files changed

Lines changed: 231 additions & 10 deletions

.github/workflows/contract-testing.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ jobs:
206206
cd cfn-resources/alert-configuration
207207
make create-test-resources
208208
209-
cat inputs/inputs_1_create.json
209+
cat inputs/*
210210
211211
make run-contract-testing
212212
make delete-test-resources

cfn-resources/alert-configuration/README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,8 @@ See the [resource docs](docs/README.md).
1515

1616
## CloudFormation Examples
1717

18-
See the examples [CFN Template](/examples/alert-configuration/alert-configuration.json) for example resource.
18+
See the example CFN templates in the [examples directory](/examples/alert-configuration/):
19+
20+
- [alert-configuration-email.json](/examples/alert-configuration/alert-configuration-email.json) - Email alert for host metrics
21+
- [alert-configuration-microsoft-teams.json](/examples/alert-configuration/alert-configuration-microsoft-teams.json) - Microsoft Teams alert for host metrics
22+
- [alert-configuration-stream-processor.json](/examples/alert-configuration/alert-configuration-stream-processor.json) - Email alert for Stream Processor metrics

cfn-resources/alert-configuration/cmd/resource/model.go

Lines changed: 5 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cfn-resources/alert-configuration/cmd/resource/resource.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -291,9 +291,11 @@ func expandAlertConfigurationThreshold(threshold *IntegerThresholdView) *admin.S
291291
return nil
292292
}
293293
return &admin.StreamProcessorMetricThreshold{
294-
Operator: threshold.Operator,
295-
Threshold: threshold.Threshold,
296-
Units: threshold.Units,
294+
MetricName: threshold.MetricName,
295+
Mode: threshold.Mode,
296+
Operator: threshold.Operator,
297+
Threshold: threshold.Threshold,
298+
Units: threshold.Units,
297299
}
298300
}
299301

cfn-resources/alert-configuration/docs/integerthresholdview.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ To declare this entity in your AWS CloudFormation template, use the following sy
88

99
<pre>
1010
{
11+
"<a href="#metricname" title="MetricName">MetricName</a>" : <i>String</i>,
12+
"<a href="#mode" title="Mode">Mode</a>" : <i>String</i>,
1113
"<a href="#operator" title="Operator">Operator</a>" : <i>String</i>,
1214
"<a href="#threshold" title="Threshold">Threshold</a>" : <i>Double</i>,
1315
"<a href="#units" title="Units">Units</a>" : <i>String</i>
@@ -17,13 +19,35 @@ To declare this entity in your AWS CloudFormation template, use the following sy
1719
### YAML
1820

1921
<pre>
22+
<a href="#metricname" title="MetricName">MetricName</a>: <i>String</i>
23+
<a href="#mode" title="Mode">Mode</a>: <i>String</i>
2024
<a href="#operator" title="Operator">Operator</a>: <i>String</i>
2125
<a href="#threshold" title="Threshold">Threshold</a>: <i>Double</i>
2226
<a href="#units" title="Units">Units</a>: <i>String</i>
2327
</pre>
2428

2529
## Properties
2630

31+
#### MetricName
32+
33+
Human-readable label that identifies the metric against which MongoDB Cloud checks the configured threshold.
34+
35+
_Required_: No
36+
37+
_Type_: String
38+
39+
_Update requires_: [No interruption](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-update-behaviors.html#update-no-interrupt)
40+
41+
#### Mode
42+
43+
Indicates how MongoDB Cloud computes the current metric value (e.g., AVERAGE).
44+
45+
_Required_: No
46+
47+
_Type_: String
48+
49+
_Update requires_: [No interruption](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-update-behaviors.html#update-no-interrupt)
50+
2751
#### Operator
2852

2953
Comparison operator to apply when checking the current metric value.

cfn-resources/alert-configuration/mongodb-atlas-alertconfiguration.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,14 @@
194194
"IntegerThresholdView": {
195195
"type": "object",
196196
"properties": {
197+
"MetricName": {
198+
"type": "string",
199+
"description": "Human-readable label that identifies the metric against which MongoDB Cloud checks the configured threshold."
200+
},
201+
"Mode": {
202+
"type": "string",
203+
"description": "Indicates how MongoDB Cloud computes the current metric value (e.g., AVERAGE)."
204+
},
197205
"Operator": {
198206
"type": "string",
199207
"description": "Comparison operator to apply when checking the current metric value.",

cfn-resources/alert-configuration/test/cfn-test-create-inputs.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,14 @@ jq --arg group_id "$projectId" \
4949
'.ProjectId?|=$group_id | .Profile?|=$profile' \
5050
"$(dirname "$0")/inputs_1_update.template.json" >"inputs/inputs_1_update.json"
5151

52+
jq --arg group_id "$projectId" \
53+
--arg profile "$profile" \
54+
'.ProjectId?|=$group_id | .Profile?|=$profile' \
55+
"$(dirname "$0")/inputs_2_create.template.json" >"inputs/inputs_2_create.json"
56+
57+
jq --arg group_id "$projectId" \
58+
--arg profile "$profile" \
59+
'.ProjectId?|=$group_id | .Profile?|=$profile' \
60+
"$(dirname "$0")/inputs_2_update.template.json" >"inputs/inputs_2_update.json"
61+
5262
ls -l inputs

cfn-resources/alert-configuration/test/inputs_1_create.template.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"Profile": "default",
33
"ProjectId": "",
4-
"Enabled": true,
4+
"Enabled": "true",
55
"EventTypeName": "OUTSIDE_METRIC_THRESHOLD",
66
"SeverityOverride": "WARNING",
77
"MetricThreshold": {

cfn-resources/alert-configuration/test/inputs_1_update.template.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"Profile": "default",
33
"ProjectId": "",
4-
"Enabled": true,
4+
"Enabled": "false",
55
"EventTypeName": "OUTSIDE_METRIC_THRESHOLD",
66
"SeverityOverride": "WARNING",
77
"MetricThreshold": {
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"Profile": "default",
3+
"ProjectId": "",
4+
"Enabled": "true",
5+
"EventTypeName": "OUTSIDE_STREAM_PROCESSOR_METRIC_THRESHOLD",
6+
"SeverityOverride": "WARNING",
7+
"Threshold": {
8+
"MetricName": "STREAM_PROCESSOR_KAFKA_LAG",
9+
"Mode": "AVERAGE",
10+
"Operator": "LESS_THAN",
11+
"Threshold": "42",
12+
"Units": "RAW"
13+
},
14+
"Matchers": [
15+
{
16+
"FieldName": "INSTANCE_NAME",
17+
"Operator": "EQUALS",
18+
"Value": "event-replica-set"
19+
}
20+
],
21+
"Notifications": [
22+
{
23+
"TypeName": "EMAIL",
24+
"DelayMin": "0",
25+
"EmailAddress": "test@example.com",
26+
"IntervalMin": "15"
27+
}
28+
]
29+
}

0 commit comments

Comments
 (0)