Skip to content

Commit 86aa519

Browse files
authored
Merge pull request #263 from SumoLogic/SUMO-169842-terraform-delay-field
Sumo 169842 terraform delay field
2 parents 01e1b81 + 04772d8 commit 86aa519

File tree

5 files changed

+26
-0
lines changed

5 files changed

+26
-0
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
## 2.9.10 (Unreleased)
22

3+
FEATURES:
4+
5+
* Add a new optional field `evaluation_delay` to resource/sumologic_monitor.
6+
37
## 2.9.9 (August 12, 2021)
48

59
FEATURES:

sumologic/resource_sumologic_monitors_library_monitor.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package sumologic
22

33
import (
44
"log"
5+
"regexp"
56
"strings"
67

78
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
@@ -267,6 +268,13 @@ func resourceSumologicMonitorsLibraryMonitor() *schema.Resource {
267268
ValidateFunc: validation.StringInSlice([]string{"Logs", "Metrics"}, false),
268269
},
269270

271+
"evaluation_delay": {
272+
Type: schema.TypeString,
273+
Optional: true,
274+
Computed: true,
275+
ValidateFunc: validation.StringMatch(regexp.MustCompile(`((\d)+[smh])+`), "This value is not in correct format. Example: 1m30s"),
276+
},
277+
270278
"is_locked": {
271279
Type: schema.TypeBool,
272280
Optional: true,
@@ -504,6 +512,7 @@ func resourceSumologicMonitorsLibraryMonitorRead(d *schema.ResourceData, meta in
504512
d.Set("created_by", monitor.CreatedBy)
505513
d.Set("created_at", monitor.CreatedAt)
506514
d.Set("monitor_type", monitor.MonitorType)
515+
d.Set("evaluation_delay", monitor.EvaluationDelay)
507516
d.Set("modified_by", monitor.ModifiedBy)
508517
d.Set("is_mutable", monitor.IsMutable)
509518
d.Set("version", monitor.Version)
@@ -1084,6 +1093,7 @@ func resourceToMonitorsLibraryMonitor(d *schema.ResourceData) MonitorsLibraryMon
10841093
CreatedAt: d.Get("created_at").(string),
10851094
MonitorType: d.Get("monitor_type").(string),
10861095
Description: d.Get("description").(string),
1096+
EvaluationDelay: d.Get("evaluation_delay").(string),
10871097
Queries: queries,
10881098
ModifiedBy: d.Get("modified_by").(string),
10891099
IsMutable: d.Get("is_mutable").(bool),

sumologic/resource_sumologic_monitors_library_monitor_test.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ func TestAccSumologicMonitorsLibraryMonitor_create(t *testing.T) {
138138
testContentType := "Monitor"
139139
testMonitorType := "Logs"
140140
testIsDisabled := false
141+
testEvaluationDelay := "5m"
141142
testQueries := []MonitorQuery{
142143
{
143144
RowID: "A",
@@ -203,6 +204,7 @@ func TestAccSumologicMonitorsLibraryMonitor_create(t *testing.T) {
203204
resource.TestCheckResourceAttr("sumologic_monitor.test", "name", testName),
204205
resource.TestCheckResourceAttr("sumologic_monitor.test", "type", testType),
205206
resource.TestCheckResourceAttr("sumologic_monitor.test", "description", testDescription),
207+
resource.TestCheckResourceAttr("sumologic_monitor.test", "evaluation_delay", testEvaluationDelay),
206208
resource.TestCheckResourceAttr("sumologic_monitor.test", "content_type", testContentType),
207209
resource.TestCheckResourceAttr("sumologic_monitor.test", "queries.0.row_id", testQueries[0].RowID),
208210
resource.TestCheckResourceAttr("sumologic_monitor.test", "triggers.0.trigger_type", testTriggers[0].TriggerType),
@@ -250,6 +252,7 @@ func TestAccSumologicMonitorsLibraryMonitor_update(t *testing.T) {
250252
testContentType := "Monitor"
251253
testMonitorType := "Logs"
252254
testIsDisabled := false
255+
testEvaluationDelay := "5m"
253256
testQueries := []MonitorQuery{
254257
{
255258
RowID: "A",
@@ -307,6 +310,7 @@ func TestAccSumologicMonitorsLibraryMonitor_update(t *testing.T) {
307310
testUpdatedContentType := "Monitor"
308311
testUpdatedMonitorType := "Logs"
309312
testUpdatedIsDisabled := true
313+
testUpdatedEvaluationDelay := "8m"
310314
testUpdatedQueries := []MonitorQuery{
311315
{
312316
RowID: "A",
@@ -372,6 +376,7 @@ func TestAccSumologicMonitorsLibraryMonitor_update(t *testing.T) {
372376
resource.TestCheckResourceAttr("sumologic_monitor.test", "name", testName),
373377
resource.TestCheckResourceAttr("sumologic_monitor.test", "type", testType),
374378
resource.TestCheckResourceAttr("sumologic_monitor.test", "description", testDescription),
379+
resource.TestCheckResourceAttr("sumologic_monitor.test", "evaluation_delay", testEvaluationDelay),
375380
resource.TestCheckResourceAttr("sumologic_monitor.test", "content_type", testContentType),
376381
resource.TestCheckResourceAttr("sumologic_monitor.test", "queries.0.row_id", testQueries[0].RowID),
377382
resource.TestCheckResourceAttr("sumologic_monitor.test", "triggers.0.trigger_type", testTriggers[0].TriggerType),
@@ -387,6 +392,7 @@ func TestAccSumologicMonitorsLibraryMonitor_update(t *testing.T) {
387392
resource.TestCheckResourceAttr("sumologic_monitor.test", "name", testUpdatedName),
388393
resource.TestCheckResourceAttr("sumologic_monitor.test", "type", testUpdatedType),
389394
resource.TestCheckResourceAttr("sumologic_monitor.test", "description", testUpdatedDescription),
395+
resource.TestCheckResourceAttr("sumologic_monitor.test", "evaluation_delay", testUpdatedEvaluationDelay),
390396
resource.TestCheckResourceAttr("sumologic_monitor.test", "content_type", testUpdatedContentType),
391397
resource.TestCheckResourceAttr("sumologic_monitor.test", "queries.0.row_id", testUpdatedQueries[0].RowID),
392398
resource.TestCheckResourceAttr("sumologic_monitor.test", "triggers.0.trigger_type", testUpdatedTriggers[0].TriggerType),
@@ -446,6 +452,7 @@ func testAccCheckMonitorsLibraryMonitorAttributes(name string) resource.TestChec
446452
resource.TestCheckResourceAttrSet(name, "created_by"),
447453
resource.TestCheckResourceAttrSet(name, "is_locked"),
448454
resource.TestCheckResourceAttrSet(name, "monitor_type"),
455+
resource.TestCheckResourceAttrSet(name, "evaluation_delay"),
449456
resource.TestCheckResourceAttrSet(name, "is_system"),
450457
resource.TestCheckResourceAttrSet(name, "is_disabled"),
451458
resource.TestCheckResourceAttrSet(name, "name"),
@@ -471,6 +478,7 @@ resource "sumologic_monitor" "test" {
471478
is_disabled = false
472479
content_type = "Monitor"
473480
monitor_type = "Logs"
481+
evaluation_delay = "5m"
474482
queries {
475483
row_id = "A"
476484
query = "_sourceCategory=monitor-manager error"
@@ -515,6 +523,7 @@ resource "sumologic_monitor" "test" {
515523
is_disabled = true
516524
content_type = "Monitor"
517525
monitor_type = "Logs"
526+
evaluation_delay = "8m"
518527
queries {
519528
row_id = "A"
520529
query = "_sourceCategory=monitor-manager info"

sumologic/sumologic_monitors_library_monitor.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ type MonitorsLibraryMonitor struct {
126126
Notifications []MonitorNotification `json:"notifications,omitempty"`
127127
CreatedBy string `json:"createdBy"`
128128
MonitorType string `json:"monitorType"`
129+
EvaluationDelay string `json:"evaluationDelay,omitempty"`
129130
IsLocked bool `json:"isLocked"`
130131
Description string `json:"description"`
131132
CreatedAt string `json:"createdAt"`

website/docs/r/monitor.html.markdown

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ resource "sumologic_monitor" "tf_logs_monitor_1" {
1919
is_disabled = false
2020
content_type = "Monitor"
2121
monitor_type = "Logs"
22+
evaluation_delay = "5m"
2223
queries {
2324
row_id = "A"
2425
query = "_sourceCategory=event-action info"
@@ -72,6 +73,7 @@ resource "sumologic_monitor" "tf_metrics_monitor_1" {
7273
is_disabled = false
7374
content_type = "Monitor"
7475
monitor_type = "Metrics"
76+
evaluation_delay = "1m"
7577
queries {
7678
row_id = "A"
7779
query = "metric=CPU_Idle _sourceCategory=event-action"

0 commit comments

Comments
 (0)