Skip to content

Commit

Permalink
Merge pull request #586 from SumoLogic/SUMO-199581-timezone-in-monito…
Browse files Browse the repository at this point in the history
…r-def

SUMO-199581: timezone in monitor definition
  • Loading branch information
ndhar-sumo authored Nov 15, 2023
2 parents e41f6cb + 589261c commit 7cda59d
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 2.28.0 (Unreleased)
FEATURES:
* resource/sumologic_monitor: Added support for setting `time_zone` at Monitor level for notifications content (GH-586)

## 2.27.1 (November 14, 2023)
BUG FIXES:
* Fixes `resource_sumologic_cse_match_list` constant change when defining a match list containing a custom column using the custom columns name instead of ID (GH-591)
Expand Down
7 changes: 7 additions & 0 deletions sumologic/resource_sumologic_monitors_library_monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ func getMonitorBaseSchema() map[string]*schema.Schema {
DiffSuppressFunc: SuppressEquivalentTimeDiff(false),
},

"time_zone": {
Type: schema.TypeString,
Optional: true,
},

"alert_name": {
Type: schema.TypeString,
Optional: true,
Expand Down Expand Up @@ -813,6 +818,7 @@ func resourceSumologicMonitorsLibraryMonitorRead(d *schema.ResourceData, meta in
d.Set("slo_id", monitor.SloID)
d.Set("notification_group_fields", monitor.NotificationGroupFields)
d.Set("tags", monitor.Tags)
d.Set("time_zone", monitor.TimeZone)

// set notifications
notifications := make([]interface{}, len(monitor.Notifications))
Expand Down Expand Up @@ -1564,6 +1570,7 @@ func resourceToMonitorsLibraryMonitor(d *schema.ResourceData) MonitorsLibraryMon
ModifiedBy: d.Get("modified_by").(string),
IsMutable: d.Get("is_mutable").(bool),
Version: d.Get("version").(int),
TimeZone: d.Get("time_zone").(string),
Notifications: notifications,
Type: d.Get("type").(string),
ParentID: d.Get("parent_id").(string),
Expand Down
10 changes: 10 additions & 0 deletions sumologic/resource_sumologic_monitors_library_monitor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ func TestAccSumologicMonitorsLibraryMonitor_create(t *testing.T) {
testMonitorType := "Logs"
testIsDisabled := false
canonicalTestEvaluationDelay := "1h"
testTimeZone := "America/New_York"
testQueries := []MonitorQuery{
{
RowID: "A",
Expand Down Expand Up @@ -272,6 +273,7 @@ func TestAccSumologicMonitorsLibraryMonitor_create(t *testing.T) {
resource.TestCheckResourceAttr("sumologic_monitor.test", "type", testType),
resource.TestCheckResourceAttr("sumologic_monitor.test", "description", testDescription),
resource.TestCheckResourceAttr("sumologic_monitor.test", "evaluation_delay", canonicalTestEvaluationDelay),
resource.TestCheckResourceAttr("sumologic_monitor.test", "time_zone", testTimeZone),
resource.TestCheckResourceAttr("sumologic_monitor.test", "content_type", testContentType),
resource.TestCheckResourceAttr("sumologic_monitor.test", "queries.0.row_id", testQueries[0].RowID),
resource.TestCheckResourceAttr("sumologic_monitor.test", "triggers.0.trigger_type", testTriggers[0].TriggerType),
Expand Down Expand Up @@ -372,6 +374,7 @@ func TestAccSumologicMonitorsLibraryMonitor_update(t *testing.T) {
testPlaybook := "This is a test playbook"
testIsDisabled := false
canonicalTestEvaluationDelay := "1h"
testTimeZone := "America/New_York"
testQueries := []MonitorQuery{
{
RowID: "A",
Expand Down Expand Up @@ -434,6 +437,7 @@ func TestAccSumologicMonitorsLibraryMonitor_update(t *testing.T) {
testUpdatedPlaybook := "This is an updated test playbook"
testUpdatedIsDisabled := true
testUpdatedEvaluationDelay := "8m"
testUpdatedTimeZone := "America/Chicago"
testUpdatedQueries := []MonitorQuery{
{
RowID: "A",
Expand Down Expand Up @@ -503,6 +507,7 @@ func TestAccSumologicMonitorsLibraryMonitor_update(t *testing.T) {
resource.TestCheckResourceAttr("sumologic_monitor.test", "type", testType),
resource.TestCheckResourceAttr("sumologic_monitor.test", "description", testDescription),
resource.TestCheckResourceAttr("sumologic_monitor.test", "evaluation_delay", canonicalTestEvaluationDelay),
resource.TestCheckResourceAttr("sumologic_monitor.test", "time_zone", testTimeZone),
resource.TestCheckResourceAttr("sumologic_monitor.test", "content_type", testContentType),
resource.TestCheckResourceAttr("sumologic_monitor.test", "queries.0.row_id", testQueries[0].RowID),
resource.TestCheckResourceAttr("sumologic_monitor.test", "triggers.0.trigger_type", testTriggers[0].TriggerType),
Expand All @@ -527,6 +532,7 @@ func TestAccSumologicMonitorsLibraryMonitor_update(t *testing.T) {
resource.TestCheckResourceAttr("sumologic_monitor.test", "type", testUpdatedType),
resource.TestCheckResourceAttr("sumologic_monitor.test", "description", testUpdatedDescription),
resource.TestCheckResourceAttr("sumologic_monitor.test", "evaluation_delay", testUpdatedEvaluationDelay),
resource.TestCheckResourceAttr("sumologic_monitor.test", "time_zone", testUpdatedTimeZone),
resource.TestCheckResourceAttr("sumologic_monitor.test", "content_type", testUpdatedContentType),
resource.TestCheckResourceAttr("sumologic_monitor.test", "queries.0.row_id", testUpdatedQueries[0].RowID),
resource.TestCheckResourceAttr("sumologic_monitor.test", "triggers.0.trigger_type", testUpdatedTriggers[0].TriggerType),
Expand Down Expand Up @@ -802,6 +808,7 @@ resource "sumologic_monitor" "test" {
content_type = "Monitor"
monitor_type = "Logs"
evaluation_delay = "60m"
time_zone = "America/New_York"
queries {
row_id = "A"
query = "_sourceCategory=monitor-manager error"
Expand Down Expand Up @@ -929,6 +936,7 @@ resource "sumologic_monitor" "test" {
content_type = "Monitor"
monitor_type = "Logs"
evaluation_delay = "8m"
time_zone = "America/Chicago"
queries {
row_id = "A"
query = "_sourceCategory=monitor-manager info"
Expand Down Expand Up @@ -1011,6 +1019,7 @@ resource "sumologic_monitor" "test_monitor_connection" {
content_type = "Monitor"
monitor_type = "Logs"
evaluation_delay = "8m"
time_zone = "Asia/Kolkata"
queries {
row_id = "A"
query = "_sourceCategory=monitor-manager info"
Expand Down Expand Up @@ -1286,6 +1295,7 @@ resource "sumologic_monitor" "test" {
is_disabled = false
content_type = "Monitor"
monitor_type = "Slo"
time_zone = "America/New_York"
slo_id = sumologic_slo.slo_tf_window_metric_ratio.id
trigger_conditions {
%s
Expand Down
1 change: 1 addition & 0 deletions sumologic/sumologic_monitors_library_monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ type MonitorsLibraryMonitor struct {
SloID string `json:"sloId,omitempty"`
NotificationGroupFields []string `json:"notificationGroupFields,omitempty"`
Tags map[string]interface{} `json:"tags"`
TimeZone string `json:"timeZone,omitempty"`
}

type MonitorQuery struct {
Expand Down

0 comments on commit 7cda59d

Please sign in to comment.