Skip to content

Commit 58bbaed

Browse files
authored
Merge pull request #264 from SumoLogic/sli-SUMO-172431-monitor-playbook
SUM-172431 add monitor playbook support
2 parents 86aa519 + bba0ee0 commit 58bbaed

File tree

5 files changed

+18
-0
lines changed

5 files changed

+18
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
FEATURES:
44

5+
* Add a new optional field `playbook` to resource/sumologic_monitor.
56
* Add a new optional field `evaluation_delay` to resource/sumologic_monitor.
67

78
## 2.9.9 (August 12, 2021)

sumologic/resource_sumologic_monitors_library_monitor.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,13 +311,19 @@ func resourceSumologicMonitorsLibraryMonitor() *schema.Resource {
311311
Type: schema.TypeString,
312312
Required: true,
313313
},
314+
314315
"post_request_map": {
315316
Type: schema.TypeMap,
316317
Optional: true,
317318
Elem: &schema.Schema{
318319
Type: schema.TypeString,
319320
},
320321
},
322+
323+
"playbook": {
324+
Type: schema.TypeString,
325+
Optional: true,
326+
},
321327
},
322328
}
323329
}
@@ -526,6 +532,7 @@ func resourceSumologicMonitorsLibraryMonitorRead(d *schema.ResourceData, meta in
526532
d.Set("is_disabled", monitor.IsDisabled)
527533
d.Set("status", monitor.Status)
528534
d.Set("group_notifications", monitor.GroupNotifications)
535+
d.Set("playbook", monitor.Playbook)
529536
// set notifications
530537
notifications := make([]interface{}, len(monitor.Notifications))
531538
for i, n := range monitor.Notifications {
@@ -1109,6 +1116,7 @@ func resourceToMonitorsLibraryMonitor(d *schema.ResourceData) MonitorsLibraryMon
11091116
IsDisabled: d.Get("is_disabled").(bool),
11101117
Status: status,
11111118
GroupNotifications: d.Get("group_notifications").(bool),
1119+
Playbook: d.Get("playbook").(string),
11121120
}
11131121
}
11141122

sumologic/resource_sumologic_monitors_library_monitor_test.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,7 @@ func TestAccSumologicMonitorsLibraryMonitor_update(t *testing.T) {
251251
testType := "MonitorsLibraryMonitor"
252252
testContentType := "Monitor"
253253
testMonitorType := "Logs"
254+
testPlaybook := "This is a test playbook"
254255
testIsDisabled := false
255256
testEvaluationDelay := "5m"
256257
testQueries := []MonitorQuery{
@@ -309,6 +310,7 @@ func TestAccSumologicMonitorsLibraryMonitor_update(t *testing.T) {
309310
testUpdatedType := "MonitorsLibraryMonitor"
310311
testUpdatedContentType := "Monitor"
311312
testUpdatedMonitorType := "Logs"
313+
testUpdatedPlaybook := "This is an updated test playbook"
312314
testUpdatedIsDisabled := true
313315
testUpdatedEvaluationDelay := "8m"
314316
testUpdatedQueries := []MonitorQuery{
@@ -382,6 +384,7 @@ func TestAccSumologicMonitorsLibraryMonitor_update(t *testing.T) {
382384
resource.TestCheckResourceAttr("sumologic_monitor.test", "triggers.0.trigger_type", testTriggers[0].TriggerType),
383385
resource.TestCheckResourceAttr("sumologic_monitor.test", "triggers.0.time_range", testTriggers[0].TimeRange),
384386
resource.TestCheckResourceAttr("sumologic_monitor.test", "notifications.0.notification.0.connection_type", testNotifications[0].Notification.(EmailNotification).ConnectionType),
387+
resource.TestCheckResourceAttr("sumologic_monitor.test", "playbook", testPlaybook),
385388
),
386389
},
387390
{
@@ -398,6 +401,7 @@ func TestAccSumologicMonitorsLibraryMonitor_update(t *testing.T) {
398401
resource.TestCheckResourceAttr("sumologic_monitor.test", "triggers.0.trigger_type", testUpdatedTriggers[0].TriggerType),
399402
resource.TestCheckResourceAttr("sumologic_monitor.test", "triggers.0.time_range", testUpdatedTriggers[0].TimeRange),
400403
resource.TestCheckResourceAttr("sumologic_monitor.test", "notifications.0.notification.0.connection_type", testUpdatedNotifications[0].Notification.(EmailNotification).ConnectionType),
404+
resource.TestCheckResourceAttr("sumologic_monitor.test", "playbook", testUpdatedPlaybook),
401405
),
402406
},
403407
},
@@ -511,6 +515,7 @@ resource "sumologic_monitor" "test" {
511515
}
512516
run_for_trigger_types = ["Critical", "ResolvedCritical"]
513517
}
518+
playbook = "This is a test playbook"
514519
}`, testName)
515520
}
516521

@@ -556,6 +561,7 @@ resource "sumologic_monitor" "test" {
556561
}
557562
run_for_trigger_types = ["Critical", "ResolvedCritical"]
558563
}
564+
playbook = "This is an updated test playbook"
559565
}`, testName)
560566
}
561567

@@ -591,6 +597,7 @@ resource "sumologic_monitor" "test" {
591597
}
592598
run_for_trigger_types = [%s]
593599
}
600+
playbook = "This is a test playbook"
594601
}`, testName, monitorType, query, trigger, triggerTysStr)
595602
}
596603

sumologic/sumologic_monitors_library_monitor.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ type MonitorsLibraryMonitor struct {
137137
IsDisabled bool `json:"isDisabled"`
138138
Status []string `json:"status"`
139139
GroupNotifications bool `json:"groupNotifications"`
140+
Playbook string `json:"playbook,omitempty"`
140141
}
141142

142143
type MonitorQuery struct {

website/docs/r/monitor.html.markdown

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,7 @@ The following arguments are supported:
219219
- `triggers` - Defines the conditions of when to send notifications.
220220
- `notifications` - (Optional) The notifications the monitor will send when the respective trigger condition is met.
221221
- `group_notifications` - (Optional) Whether or not to group notifications for individual items that meet the trigger condition. Defaults to true.
222+
- `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.
222223

223224
Additional data provided in state:
224225

0 commit comments

Comments
 (0)