Skip to content

Commit f6a49e1

Browse files
committed
Merge remote-tracking branch 'origin/master' into release-2.17.0-2
2 parents 73fc7b5 + 9eec023 commit f6a49e1

File tree

5 files changed

+81
-52
lines changed

5 files changed

+81
-52
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
FEATURES:
66
* **New Resource:** sumologic_cse_entity_entity_group_configuration (GH-376)
77
* **New Resource:** sumologic_cse_inventory_entity_group_configuration (GH-376)
8+
* Add new optional `notification_group_fields` field to resource/sumologic_monitor (GH-403)
89
* Add new optional `obj_permission` set to resource/sumologic_monitor for Fine Grain Permission (FGP) support (GH-397)
910
* Add use_versioned_api parameter for s3 source (GH-401)
1011

sumologic/resource_sumologic_monitors_library_monitor.go

Lines changed: 39 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,13 @@ func resourceSumologicMonitorsLibraryMonitor() *schema.Resource {
353353
Optional: true,
354354
ValidateFunc: validation.StringLenBetween(1, 512),
355355
},
356-
356+
"notification_group_fields": {
357+
Type: schema.TypeList,
358+
Optional: true,
359+
Elem: &schema.Schema{
360+
Type: schema.TypeString,
361+
},
362+
},
357363
"obj_permission": GetCmfFgpObjPermSetSchema(),
358364
},
359365
}
@@ -632,6 +638,7 @@ func resourceSumologicMonitorsLibraryMonitorRead(d *schema.ResourceData, meta in
632638
d.Set("playbook", monitor.Playbook)
633639
d.Set("alert_name", monitor.AlertName)
634640
d.Set("slo_id", monitor.SloID)
641+
d.Set("notification_group_fields", monitor.NotificationGroupFields)
635642
// set notifications
636643
notifications := make([]interface{}, len(monitor.Notifications))
637644
for i, n := range monitor.Notifications {
@@ -1332,33 +1339,39 @@ func resourceToMonitorsLibraryMonitor(d *schema.ResourceData) MonitorsLibraryMon
13321339
for i := range rawStatus {
13331340
status[i] = rawStatus[i].(string)
13341341
}
1342+
rawGroupFields := d.Get("notification_group_fields").([]interface{})
1343+
notificationGroupFields := make([]string, len(rawGroupFields))
1344+
for i := range rawGroupFields {
1345+
notificationGroupFields[i] = rawGroupFields[i].(string)
1346+
}
13351347

13361348
return MonitorsLibraryMonitor{
1337-
CreatedBy: d.Get("created_by").(string),
1338-
Name: d.Get("name").(string),
1339-
ID: d.Id(),
1340-
CreatedAt: d.Get("created_at").(string),
1341-
MonitorType: d.Get("monitor_type").(string),
1342-
Description: d.Get("description").(string),
1343-
EvaluationDelay: d.Get("evaluation_delay").(string),
1344-
Queries: queries,
1345-
ModifiedBy: d.Get("modified_by").(string),
1346-
IsMutable: d.Get("is_mutable").(bool),
1347-
Version: d.Get("version").(int),
1348-
Notifications: notifications,
1349-
Type: d.Get("type").(string),
1350-
ParentID: d.Get("parent_id").(string),
1351-
ModifiedAt: d.Get("modified_at").(string),
1352-
Triggers: triggers,
1353-
ContentType: d.Get("content_type").(string),
1354-
IsLocked: d.Get("is_locked").(bool),
1355-
IsSystem: d.Get("is_system").(bool),
1356-
IsDisabled: d.Get("is_disabled").(bool),
1357-
Status: status,
1358-
GroupNotifications: d.Get("group_notifications").(bool),
1359-
Playbook: d.Get("playbook").(string),
1360-
AlertName: d.Get("alert_name").(string),
1361-
SloID: d.Get("slo_id").(string),
1349+
CreatedBy: d.Get("created_by").(string),
1350+
Name: d.Get("name").(string),
1351+
ID: d.Id(),
1352+
CreatedAt: d.Get("created_at").(string),
1353+
MonitorType: d.Get("monitor_type").(string),
1354+
Description: d.Get("description").(string),
1355+
EvaluationDelay: d.Get("evaluation_delay").(string),
1356+
Queries: queries,
1357+
ModifiedBy: d.Get("modified_by").(string),
1358+
IsMutable: d.Get("is_mutable").(bool),
1359+
Version: d.Get("version").(int),
1360+
Notifications: notifications,
1361+
Type: d.Get("type").(string),
1362+
ParentID: d.Get("parent_id").(string),
1363+
ModifiedAt: d.Get("modified_at").(string),
1364+
Triggers: triggers,
1365+
ContentType: d.Get("content_type").(string),
1366+
IsLocked: d.Get("is_locked").(bool),
1367+
IsSystem: d.Get("is_system").(bool),
1368+
IsDisabled: d.Get("is_disabled").(bool),
1369+
Status: status,
1370+
GroupNotifications: d.Get("group_notifications").(bool),
1371+
Playbook: d.Get("playbook").(string),
1372+
AlertName: d.Get("alert_name").(string),
1373+
SloID: d.Get("slo_id").(string),
1374+
NotificationGroupFields: notificationGroupFields,
13621375
}
13631376
}
13641377

sumologic/resource_sumologic_monitors_library_monitor_test.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ func TestAccSumologicMonitorsLibraryMonitor_create(t *testing.T) {
189189
},
190190
}
191191
testAlertName := "Alert from {{Name}}"
192+
testGroupFields := [2]string{"groupingField1", "groupingField2"}
192193

193194
resource.Test(t, resource.TestCase{
194195
PreCheck: func() { testAccPreCheck(t) },
@@ -212,6 +213,8 @@ func TestAccSumologicMonitorsLibraryMonitor_create(t *testing.T) {
212213
resource.TestCheckResourceAttr("sumologic_monitor.test", "triggers.0.time_range", testTriggers[0].TimeRange),
213214
resource.TestCheckResourceAttr("sumologic_monitor.test", "notifications.0.notification.0.connection_type", testNotifications[0].Notification.(EmailNotification).ConnectionType),
214215
resource.TestCheckResourceAttr("sumologic_monitor.test", "alert_name", testAlertName),
216+
resource.TestCheckResourceAttr("sumologic_monitor.test", "notification_group_fields.0", testGroupFields[0]),
217+
resource.TestCheckResourceAttr("sumologic_monitor.test", "notification_group_fields.1", testGroupFields[1]),
215218
resource.TestCheckResourceAttr("sumologic_monitor.test", "obj_permission.#", "2"),
216219
testAccCheckMonitorsLibraryMonitorFGPBackend("sumologic_monitor.test", t, genExpectedPermStmtsMonitor),
217220
),
@@ -308,6 +311,7 @@ func TestAccSumologicMonitorsLibraryMonitor_update(t *testing.T) {
308311
},
309312
}
310313
testAlertName := "Alert from {{Name}}"
314+
testGroupFields := [2]string{"groupingField1", "groupingField2"}
311315

312316
// updated fields
313317
testUpdatedName := "terraform_test_monitor_" + testNameSuffix
@@ -368,6 +372,7 @@ func TestAccSumologicMonitorsLibraryMonitor_update(t *testing.T) {
368372
},
369373
}
370374
testUpdatedAlertName := "Updated Alert from {{Name}}"
375+
testUpdatedGroupFields := [2]string{"groupingField3", "groupingField4"}
371376

372377
resource.Test(t, resource.TestCase{
373378
PreCheck: func() { testAccPreCheck(t) },
@@ -392,6 +397,8 @@ func TestAccSumologicMonitorsLibraryMonitor_update(t *testing.T) {
392397
resource.TestCheckResourceAttr("sumologic_monitor.test", "notifications.0.notification.0.connection_type", testNotifications[0].Notification.(EmailNotification).ConnectionType),
393398
resource.TestCheckResourceAttr("sumologic_monitor.test", "playbook", testPlaybook),
394399
resource.TestCheckResourceAttr("sumologic_monitor.test", "alert_name", testAlertName),
400+
resource.TestCheckResourceAttr("sumologic_monitor.test", "notification_group_fields.0", testGroupFields[0]),
401+
resource.TestCheckResourceAttr("sumologic_monitor.test", "notification_group_fields.1", testGroupFields[1]),
395402
resource.TestCheckResourceAttr("sumologic_monitor.test", "obj_permission.#", "2"),
396403
testAccCheckMonitorsLibraryMonitorFGPBackend("sumologic_monitor.test", t, genExpectedPermStmtsMonitor),
397404
),
@@ -412,6 +419,8 @@ func TestAccSumologicMonitorsLibraryMonitor_update(t *testing.T) {
412419
resource.TestCheckResourceAttr("sumologic_monitor.test", "notifications.0.notification.0.connection_type", testUpdatedNotifications[0].Notification.(EmailNotification).ConnectionType),
413420
resource.TestCheckResourceAttr("sumologic_monitor.test", "playbook", testUpdatedPlaybook),
414421
resource.TestCheckResourceAttr("sumologic_monitor.test", "alert_name", testUpdatedAlertName),
422+
resource.TestCheckResourceAttr("sumologic_monitor.test", "notification_group_fields.0", testUpdatedGroupFields[0]),
423+
resource.TestCheckResourceAttr("sumologic_monitor.test", "notification_group_fields.1", testUpdatedGroupFields[1]),
415424
resource.TestCheckResourceAttr("sumologic_monitor.test", "obj_permission.#", "1"),
416425
// 1, instead of 2
417426
testAccCheckMonitorsLibraryMonitorFGPBackend("sumologic_monitor.test", t, genExpectedPermStmtsForMonitorUpdate),
@@ -582,6 +591,7 @@ resource "sumologic_monitor" "test" {
582591
}
583592
playbook = "This is a test playbook"
584593
alert_name = "Alert from {{Name}}"
594+
notification_group_fields = ["groupingField1", "groupingField2"]
585595
obj_permission {
586596
subject_type = "role"
587597
subject_id = sumologic_role.tf_test_role_01.id
@@ -666,6 +676,7 @@ resource "sumologic_monitor" "test" {
666676
}
667677
playbook = "This is an updated test playbook"
668678
alert_name = "Updated Alert from {{Name}}"
679+
notification_group_fields = ["groupingField3", "groupingField4"]
669680
obj_permission {
670681
subject_type = "role"
671682
subject_id = sumologic_role.tf_test_role_01.id

sumologic/sumologic_monitors_library_monitor.go

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -115,31 +115,32 @@ func (s *Client) MoveMonitorsLibraryMonitor(monitorsLibraryMonitor MonitorsLibra
115115

116116
// ---------- TYPES ----------
117117
type MonitorsLibraryMonitor struct {
118-
ID string `json:"id,omitempty"`
119-
IsSystem bool `json:"isSystem"`
120-
Type string `json:"type"`
121-
Queries []MonitorQuery `json:"queries,omitempty"`
122-
ParentID string `json:"parentId"`
123-
Name string `json:"name"`
124-
IsMutable bool `json:"isMutable"`
125-
Version int `json:"version"`
126-
Notifications []MonitorNotification `json:"notifications,omitempty"`
127-
CreatedBy string `json:"createdBy"`
128-
MonitorType string `json:"monitorType"`
129-
EvaluationDelay string `json:"evaluationDelay,omitempty"`
130-
IsLocked bool `json:"isLocked"`
131-
Description string `json:"description"`
132-
CreatedAt string `json:"createdAt"`
133-
Triggers []TriggerCondition `json:"triggers,omitempty"`
134-
ModifiedAt string `json:"modifiedAt"`
135-
ContentType string `json:"contentType"`
136-
ModifiedBy string `json:"modifiedBy"`
137-
IsDisabled bool `json:"isDisabled"`
138-
Status []string `json:"status"`
139-
GroupNotifications bool `json:"groupNotifications"`
140-
Playbook string `json:"playbook,omitempty"`
141-
AlertName string `json:"alertName,omitempty"`
142-
SloID string `json:"sloId,omitempty"`
118+
ID string `json:"id,omitempty"`
119+
IsSystem bool `json:"isSystem"`
120+
Type string `json:"type"`
121+
Queries []MonitorQuery `json:"queries,omitempty"`
122+
ParentID string `json:"parentId"`
123+
Name string `json:"name"`
124+
IsMutable bool `json:"isMutable"`
125+
Version int `json:"version"`
126+
Notifications []MonitorNotification `json:"notifications,omitempty"`
127+
CreatedBy string `json:"createdBy"`
128+
MonitorType string `json:"monitorType"`
129+
EvaluationDelay string `json:"evaluationDelay,omitempty"`
130+
IsLocked bool `json:"isLocked"`
131+
Description string `json:"description"`
132+
CreatedAt string `json:"createdAt"`
133+
Triggers []TriggerCondition `json:"triggers,omitempty"`
134+
ModifiedAt string `json:"modifiedAt"`
135+
ContentType string `json:"contentType"`
136+
ModifiedBy string `json:"modifiedBy"`
137+
IsDisabled bool `json:"isDisabled"`
138+
Status []string `json:"status"`
139+
GroupNotifications bool `json:"groupNotifications"`
140+
Playbook string `json:"playbook,omitempty"`
141+
AlertName string `json:"alertName,omitempty"`
142+
SloID string `json:"sloId,omitempty"`
143+
NotificationGroupFields []string `json:"notificationGroupFields,omitempty"`
143144
}
144145

145146
type MonitorQuery struct {

website/docs/r/monitor.html.markdown

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ resource "sumologic_monitor" "tf_logs_monitor_1" {
8585
}
8686
playbook = "{{Name}} should be fixed in 24 hours when {{TriggerType}} is triggered."
8787
alert_name = "Alert {{ResultJson.my_field}} from {{Name}}"
88+
notification_group_fields = ["_sourceHost"]
8889
obj_permission {
8990
subject_type = "role"
9091
subject_id = sumologic_role.tf_test_role_01.id
@@ -112,7 +113,7 @@ resource "sumologic_monitor" "tf_metrics_monitor_1" {
112113
113114
queries {
114115
row_id = "A"
115-
query = "metric=CPU_Idle _sourceCategory=event-action"
116+
query = "metric=CPU* _sourceCategory=event-action"
116117
}
117118
118119
trigger_conditions {
@@ -142,6 +143,7 @@ resource "sumologic_monitor" "tf_metrics_monitor_1" {
142143
run_for_trigger_types = ["Critical", "ResolvedCritical"]
143144
}
144145
playbook = "test playbook"
146+
notification_group_fields = ["metric"]
145147
}
146148
```
147149

@@ -320,6 +322,7 @@ The following arguments are supported:
320322
- `group_notifications` - (Optional) Whether or not to group notifications for individual items that meet the trigger condition. Defaults to true.
321323
- `playbook` - (Optional - Beta) Notes such as links and instruction to help you resolve alerts triggered by this monitor. {{Markdown}} supported. It will be enabled only if available for your organization. Please contact your Sumo Logic account team to learn more.
322324
- `alert_name` - (Optional) The display name when creating alerts. Monitor name will be used if `alert_name` is not provided. All template variables can be used in `alert_name` except `{{AlertName}}` and `{{ResultsJson}}`.
325+
- `notification_group_fields` - (Optional - Beta) The set of fields to be used to group alerts and notifications for a monitor. The value of this field will be considered only when 'groupNotifications' is true.
323326
- `obj_permission` - (Optional) `obj_permission` construct represents a Permission Statement associated with this Monitor. A set of `obj_permission` constructs can be specified under a Monitor. An `obj_permission` construct can be used to control permissions Explicitly associated with a Monitor. But, it cannot be used to control permissions Inherited from a Parent / Ancestor. Default FGP would be still set to the Monitor upon creation (e.g. the creating user would have full permission), even if no `obj_permission` construct is specified at a Monitor and the FGP feature is enabled at the account.
324327
- `subject_type` - (Required) Valid values:
325328
- `role`

0 commit comments

Comments
 (0)