SumoLogic / terraform-provider-sumologic

Terraform provider for Sumo Logic
https://www.terraform.io/docs/providers/sumologic/
Mozilla Public License 2.0
38 stars 55 forks source link

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

Open vinodjv3 opened 2 years ago

vinodjv3 commented 2 years ago

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.

tarunk2 commented 2 years ago

@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

captainfalcon23 commented 1 year ago

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!

papaharry commented 1 year ago

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.

captainfalcon23 commented 1 year ago

@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.

papaharry commented 1 year ago

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:

captainfalcon23 commented 1 year ago

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.

papaharry commented 1 year ago

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