Datadog Terraform Provider Version
v3.46.0
Terraform Version
v1.9.7
What resources or data sources are affected?
resource_datadog_monitor
Terraform Configuration Files
The below config is stripped of identifying info, so don't be surprised if the main and tfvars don't match up here. The code runs and creates the resources.
main.tf
locals {
monitors = flatten([
for interface_name, interface_data in var.interfaces : [
for query_name, query_data in interface_data.queries : {
interface_name = interface_name
query_name = query_name
scope = interface_data.scope
timezone = interface_data.timezone
file_query = interface_data.file_query
extra_query = query_data.extra_query
rrule = query_data.rrule
}
]
])
}
resource "datadog_monitor" "main" {
for_each = {
for idx, monitor in local.monitors : format("%s - %s", monitor.interface_name, monitor.query_name) => monitor
}
name = format("%s - %s", each.value.interface_name, each.value.query_name)
type = "log alert"
message = each.value.message
query = each.value.query
groupby_simple_monitor = false
include_tags = false
scheduling_options {
evaluation_window {
day_starts = "00:00"
}
custom_schedule {
recurrence {
rrule = each.value["rrule"]
timezone = each.value["timezone"]
start = format("2024-10-11T%s:%s:00", regex("BYHOUR=([0-9]+)", each.value["rrule"])[0], regex("BYMINUTE=([0-9]+)", each.value["rrule"])[0])
}
}
}
monitor_thresholds {
critical = 0
}
tags = []
}
terraform.tfvars sample
interfaces = {
"MW E2Open AUS - DMD Unit (OUT)" = {
day_starts = "00:00"
timezone = "Australia/Sydney"
file_query = "*file*"
scope = "scope"
queries = {
Creation = {
extra_query = "@action:create"
rrule = "FREQ=DAILY;BYDAY=SU,MO,TU,WE,TH,FR;BYHOUR=18;BYMINUTE=45"
}
Transfer = {
extra_query = "@action:transfer"
rrule = "FREQ=DAILY;BYDAY=SU,MO,TU,WE,TH,FR;BYHOUR=19;BYMINUTE=00"
}
}
}
Relevant debug or panic output
Sample monitor created, as you can see options.scheduling_options.evaluation_window.timezone is set to UTC:
{
"id": 775746,
"name": "MW E2Open AUS - Exception Reports - Transfer",
"type": "log alert",
"query": "logs(\"myquery\").index(\"*\").rollup(\"count\").current(\"1d\") == 0",
"message": "my message",
"tags": [],
"options": {
"thresholds": {
"critical": 0
},
"enable_logs_sample": false,
"notify_audit": false,
"on_missing_data": "default",
"include_tags": false,
"require_full_window": false,
"scheduling_options": {
"custom_schedule": {
"recurrences": [
{
"rrule": "FREQ=DAILY;INTERVAL=1;BYHOUR=04;BYMINUTE=30",
"timezone": "Australia/Sydney"
}
]
},
"evaluation_window": {
"day_starts": "00:00",
"timezone": "UTC"
}
},
"silenced": {}
},
"priority": null,
"restriction_policy": {
"bindings": []
}
}
Expected Behavior
I would expect the monitor to inherit the timezone parameter from the recurrence block since there is no timezone parameter within evaluation_window
Actual Behavior
Timezone is getting set to UTC every time.
Steps to Reproduce
terraform init
terraform plan
terraform apply -auto-approve
Important Factoids
No response
References
No response
Datadog Terraform Provider Version
v3.46.0
Terraform Version
v1.9.7
What resources or data sources are affected?
resource_datadog_monitor
Terraform Configuration Files
The below config is stripped of identifying info, so don't be surprised if the main and tfvars don't match up here. The code runs and creates the resources.
main.tf
terraform.tfvars sample
Relevant debug or panic output
Sample monitor created, as you can see
options.scheduling_options.evaluation_window.timezoneis set to UTC:Expected Behavior
I would expect the monitor to inherit the timezone parameter from the recurrence block since there is no
timezoneparameter withinevaluation_windowActual Behavior
Timezone is getting set to UTC every time.
Steps to Reproduce
terraform initterraform planterraform apply -auto-approveImportant Factoids
No response
References
No response