terraform-provider-sumologic icon indicating copy to clipboard operation
terraform-provider-sumologic copied to clipboard

Unable to change Timezone in "sumologic_monitor" resource for Webhook Notifications

Open vinodjv3 opened this issue 3 years ago • 7 comments

Hello Team, Am creating monitor using terraform and wanted to change the timezone that the alert notifies. Notification is sent to slack. Below is my code

resource "sumologic_monitor" "logsMonitor" {
  count                   = length(var.sumologic_connection_name) > 0 ? 1 : 0
  provider                = sumologic.sumo
  name                    = var.sumologic_monitor_name
  description             = "Lambda logs monitor"
  type                    = "MonitorsLibraryMonitor"
  parent_id               = sumologic_monitor_folder.orlTeamRootFolder[count.index].id
  is_disabled             = false
  content_type            = "Monitor"
  monitor_type            = "Logs"
  evaluation_delay        = "5m"
  queries {
    row_id                = "A"
    query                 = var.sumologic_monitor_query
  }
  trigger_conditions {
    logs_static_condition {
      critical {
        time_range        = "10m"
        alert {
          threshold       = 0.0
          threshold_type  = "GreaterThan"
        }
        resolution {
          threshold       = 0.0
          threshold_type  = "LessThanOrEqual"
        }
      }
    }
  }
  notifications {
    notification {
      connection_type     = "Webhook"
      connection_id       = sumologic_connection.slack[count.index].id
      **time_zone           = "GMT"**
    }
    run_for_trigger_types = ["Critical"]
  }
  playbook                = "{{Name}} should be fixed soon when {{TriggerType}} is triggered."
}

Under notification block am specifying the timezone as GMT but the alert shows me the timezone as PST

Time Range 12/07/2021 11:45:07 PM PST to 12/07/2021 11:55:07 PM PST

Please let me know if there is any solution.

vinodjv3 avatar Dec 08 '21 10:12 vinodjv3

@vinodjv3 thanks for reporting the issue. time_zone field is not supported for webhook connections. We plan to add timezone as a top-level field under the root directly in the future. For now, webhooks pick time zone from the user settings of the user whose credentials are used in Terraform. You can change the time zone in user settings under preferences for now (see the screenshot below). image

tarunk2 avatar Dec 09 '21 06:12 tarunk2

This seems to be partially supported. Today I noticed all my slack webhooks were using PDT as the timezone, regardless of what the API users' preference is set to.

What I did was add "time_zone = "UTC"" to the notification block and apply, and now the notifications are correctly being created using the timezone of the API user (AEDT in this case).

So it seems reapplying all of the monitors fixed it...really unsure!

captainfalcon23 avatar Mar 31 '23 01:03 captainfalcon23

We have the same problem here. I am trying to set it up in the notification block (as per the documentation) but it still sends all notifications in PDT. Every time we run the apply command, it marks it as a change and wants to add the time_zone, but nothing really changes.

papaharry avatar Jul 26 '23 10:07 papaharry

@papaharry try what I mentioned in my previous comment. I can't remember if I deleted and recreated all the monitors or just applied on top. Also make sure you've set the A{I users' timezone correctly in the UI before you do the above.

captainfalcon23 avatar Jul 26 '23 11:07 captainfalcon23

Thank you @captainfalcon23. I tried that but still no luck. We manage everything via terraform so I deleted everything and rebuilt it, but it still sends the alerts in PDT timezone. I have opened a ticket for now. Hopefully it will be an easy fix. :crossed_fingers:

papaharry avatar Jul 27 '23 15:07 papaharry

Please let me know what they say @papaharry. One other thing to try, add the add "time_zone = "UTC"" to the notification block, apply on top of whats there, then remove it and apply again and see.

captainfalcon23 avatar Jul 27 '23 23:07 captainfalcon23

Still nothing. The alerts are still on the wrong timezone and every time I apply/re-apply it is as if timezone was never set

      ~ notifications {
            # (1 unchanged attribute hidden)

          ~ notification {
              + time_zone       = "UTC"
                # (4 unchanged attributes hidden)
            }
        }

I'll wait for the support team to get back to me. I'll update here if/once there is a solution in case others are facing the same issue

papaharry avatar Jul 28 '23 08:07 papaharry