You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
resource"grafana_rule_group""recording_rules" {
name="Every 5 Minutes"folder_uid=var.recording_rule_folder_uidinterval_seconds=300rule {
name="Time:AmericaNewYork:IsNowDuringDST"condition="A"data {
ref_id="A"relative_time_range {
from=300to=0
}
datasource_uid="grafanacloud-prom"
model = "{\"editorMode\":\"code\",\"expr\":\"# This determines if the current time is in Daylight Saving Time (for the America/New_York timezone)\\n# Returns 1 for true and 0 for false\\n\\n(vector(1) and (month() > 3 and month() < 11)) # True if month is April through October, which are always in DST\\n or\\n (vector(1) and (month() == 3 and ((day_of_month() - day_of_week()) - 7) >= 0 and (((day_of_month() - day_of_week()) - 14) > 0 or absent(day_of_week() == 0)))) # True if it is the second Sunday or after in March\\n or\\n (vector(1) and (month() == 11 and (day_of_month() - day_of_week()) < 0 and (absent(day_of_week() == 0))))\\n or # True if it is before the first Sunday in November\\n (\\n vector(1)\\n and\\n (\\n (month() == 3 and hour() >= 6 and (((day_of_month() - day_of_week()) - 7) >= 0 and ((day_of_month() - day_of_week()) - 14) <= 0)) # True if it is spring forward day after the time change\\n or\\n (month() == 11 and hour() < 5 and ((day_of_month() - day_of_week()) - 7) < 0) # True if it is fall back day before the time change\\n )\\n and\\n (day_of_week() == 0)\\n )\\n or\\n vector(0) # If none of the other conditions evaluated True, return False\",\"instant\":true,\"intervalMs\":1000,\"legendFormat\":\"__auto\",\"maxDataPoints\":43200,\"range\":false,\"refId\":\"A\"}"
}
is_paused=falserecord {
metric="Time:AmericaNewYork:IsNowDuringDST"from="A"
}
}
rule {
name="Time:AmericaNewYork:Is1wAgoDuringDST"condition="A"data {
ref_id="A"relative_time_range {
from=605100to=604800
}
datasource_uid="grafanacloud-prom"
model = "{\"editorMode\":\"code\",\"expr\":\"# This determines if the time 1 week ago was in Daylight Saving Time (for the America/New_York timezone)\\n# Returns 1 for true and 0 for false\\n\\n(vector(1) and (month() > 3 and month() < 11)) # True if month is April through October, which are always in DST\\n or\\n (vector(1) and (month() == 3 and ((day_of_month() - day_of_week()) - 7) >= 0 and (((day_of_month() - day_of_week()) - 14) > 0 or absent(day_of_week() == 0)))) # True if it is the second Sunday or after in March\\n or\\n (vector(1) and (month() == 11 and (day_of_month() - day_of_week()) < 0 and (absent(day_of_week() == 0))))\\n or # True if it is before the first Sunday in November\\n (\\n vector(1)\\n and\\n (\\n (month() == 3 and hour() >= 6 and (((day_of_month() - day_of_week()) - 7) >= 0 and ((day_of_month() - day_of_week()) - 14) <= 0)) # True if it is spring forward day after the time change\\n or\\n (month() == 11 and hour() < 5 and ((day_of_month() - day_of_week()) - 7) < 0) # True if it is fall back day before the time change\\n )\\n and\\n (day_of_week() == 0)\\n )\\n or\\n vector(0) # If none of the other conditions evaluated True, return False\",\"instant\":true,\"intervalMs\":1000,\"legendFormat\":\"__auto\",\"maxDataPoints\":43200,\"range\":false,\"refId\":\"A\"}"
}
is_paused=falserecord {
metric="Time:AmericaNewYork:Is1wAgoDuringDST"from="A"
}
}
rule {
name="Time:AmericaNewYork:Is2wAgoDuringDST"condition="A"data {
ref_id="A"relative_time_range {
from=1209900to=1209600
}
datasource_uid="grafanacloud-prom"
model = "{\"editorMode\":\"code\",\"expr\":\"# This determines if the time 2 weeks ago was in Daylight Saving Time (for the America/New_York timezone)\\n# Returns 1 for true and 0 for false\\n\\n(vector(1) and (month() > 3 and month() < 11)) # True if month is April through October, which are always in DST\\n or\\n (vector(1) and (month() == 3 and ((day_of_month() - day_of_week()) - 7) >= 0 and (((day_of_month() - day_of_week()) - 14) > 0 or absent(day_of_week() == 0)))) # True if it is the second Sunday or after in March\\n or\\n (vector(1) and (month() == 11 and (day_of_month() - day_of_week()) < 0 and (absent(day_of_week() == 0))))\\n or # True if it is before the first Sunday in November\\n (\\n vector(1)\\n and\\n (\\n (month() == 3 and hour() >= 6 and (((day_of_month() - day_of_week()) - 7) >= 0 and ((day_of_month() - day_of_week()) - 14) <= 0)) # True if it is spring forward day after the time change\\n or\\n (month() == 11 and hour() < 5 and ((day_of_month() - day_of_week()) - 7) < 0) # True if it is fall back day before the time change\\n )\\n and\\n (day_of_week() == 0)\\n )\\n or\\n vector(0) # If none of the other conditions evaluated True, return False\",\"instant\":true,\"intervalMs\":1000,\"legendFormat\":\"__auto\",\"maxDataPoints\":43200,\"range\":false,\"refId\":\"A\"}"
}
is_paused=falserecord {
metric="Time:AmericaNewYork:Is2wAgoDuringDST"from="A"
}
}
rule {
name="Time:AmericaNewYork:Is3wAgoDuringDST"condition="A"data {
ref_id="A"relative_time_range {
from=1814700to=1814400
}
datasource_uid="grafanacloud-prom"
model = "{\"editorMode\":\"code\",\"expr\":\"# This determines if the time 3 weeks ago was in Daylight Saving Time (for the America/New_York timezone)\\n# Returns 1 for true and 0 for false\\n\\n(vector(1) and (month() > 3 and month() < 11)) # True if month is April through October, which are always in DST\\n or\\n (vector(1) and (month() == 3 and ((day_of_month() - day_of_week()) - 7) >= 0 and (((day_of_month() - day_of_week()) - 14) > 0 or absent(day_of_week() == 0)))) # True if it is the second Sunday or after in March\\n or\\n (vector(1) and (month() == 11 and (day_of_month() - day_of_week()) < 0 and (absent(day_of_week() == 0))))\\n or # True if it is before the first Sunday in November\\n (\\n vector(1)\\n and\\n (\\n (month() == 3 and hour() >= 6 and (((day_of_month() - day_of_week()) - 7) >= 0 and ((day_of_month() - day_of_week()) - 14) <= 0)) # True if it is spring forward day after the time change\\n or\\n (month() == 11 and hour() < 5 and ((day_of_month() - day_of_week()) - 7) < 0) # True if it is fall back day before the time change\\n )\\n and\\n (day_of_week() == 0)\\n )\\n or\\n vector(0) # If none of the other conditions evaluated True, return False\",\"instant\":true,\"intervalMs\":1000,\"legendFormat\":\"__auto\",\"maxDataPoints\":43200,\"range\":false,\"refId\":\"A\"}"
}
is_paused=falserecord {
metric="Time:AmericaNewYork:Is3wAgoDuringDST"from="A"
}
}
rule {
name="Time:AmericaNewYork:Is4wAgoDuringDST"condition="A"data {
ref_id="A"relative_time_range {
from=2419500to=2419200
}
datasource_uid="grafanacloud-prom"
model = "{\"editorMode\":\"code\",\"expr\":\"# This determines if the time 4 weeks ago was in Daylight Saving Time (for the America/New_York timezone)\\n# Returns 1 for true and 0 for false\\n\\n(vector(1) and (month() > 3 and month() < 11)) # True if month is April through October, which are always in DST\\n or\\n (vector(1) and (month() == 3 and ((day_of_month() - day_of_week()) - 7) >= 0 and (((day_of_month() - day_of_week()) - 14) > 0 or absent(day_of_week() == 0)))) # True if it is the second Sunday or after in March\\n or\\n (vector(1) and (month() == 11 and (day_of_month() - day_of_week()) < 0 and (absent(day_of_week() == 0))))\\n or # True if it is before the first Sunday in November\\n (\\n vector(1)\\n and\\n (\\n (month() == 3 and hour() >= 6 and (((day_of_month() - day_of_week()) - 7) >= 0 and ((day_of_month() - day_of_week()) - 14) <= 0)) # True if it is spring forward day after the time change\\n or\\n (month() == 11 and hour() < 5 and ((day_of_month() - day_of_week()) - 7) < 0) # True if it is fall back day before the time change\\n )\\n and\\n (day_of_week() == 0)\\n )\\n or\\n vector(0) # If none of the other conditions evaluated True, return False\",\"instant\":true,\"intervalMs\":1000,\"legendFormat\":\"__auto\",\"maxDataPoints\":43200,\"range\":false,\"refId\":\"A\"}"
}
is_paused=falserecord {
metric="Time:AmericaNewYork:Is4wAgoDuringDST"from="A"
}
}
rule {
name="Time:AmericaNewYork:Is5wAgoDuringDST"condition="A"data {
ref_id="A"relative_time_range {
from=3024300to=3024000
}
datasource_uid="grafanacloud-prom"
model = "{\"editorMode\":\"code\",\"expr\":\"# This determines if the time 5 weeks ago was in Daylight Saving Time (for the America/New_York timezone)\\n# Returns 1 for true and 0 for false\\n\\n(vector(1) and (month() > 3 and month() < 11)) # True if month is April through October, which are always in DST\\n or\\n (vector(1) and (month() == 3 and ((day_of_month() - day_of_week()) - 7) >= 0 and (((day_of_month() - day_of_week()) - 14) > 0 or absent(day_of_week() == 0)))) # True if it is the second Sunday or after in March\\n or\\n (vector(1) and (month() == 11 and (day_of_month() - day_of_week()) < 0 and (absent(day_of_week() == 0))))\\n or # True if it is before the first Sunday in November\\n (\\n vector(1)\\n and\\n (\\n (month() == 3 and hour() >= 6 and (((day_of_month() - day_of_week()) - 7) >= 0 and ((day_of_month() - day_of_week()) - 14) <= 0)) # True if it is spring forward day after the time change\\n or\\n (month() == 11 and hour() < 5 and ((day_of_month() - day_of_week()) - 7) < 0) # True if it is fall back day before the time change\\n )\\n and\\n (day_of_week() == 0)\\n )\\n or\\n vector(0) # If none of the other conditions evaluated True, return False\",\"instant\":true,\"intervalMs\":1000,\"legendFormat\":\"__auto\",\"maxDataPoints\":43200,\"range\":false,\"refId\":\"A\"}"
}
is_paused=falserecord {
metric="Time:AmericaNewYork:Is5wAgoDuringDST"from="A"
}
}
rule {
name="Time:AmericaNewYork:Is6wAgoDuringDST"condition="A"data {
ref_id="A"relative_time_range {
from=3629100to=3628800
}
datasource_uid="grafanacloud-prom"
model = "{\"editorMode\":\"code\",\"expr\":\"# This determines if the time 6 weeks ago was in Daylight Saving Time (for the America/New_York timezone)\\n# Returns 1 for true and 0 for false\\n\\n(vector(1) and (month() > 3 and month() < 11)) # True if month is April through October, which are always in DST\\n or\\n (vector(1) and (month() == 3 and ((day_of_month() - day_of_week()) - 7) >= 0 and (((day_of_month() - day_of_week()) - 14) > 0 or absent(day_of_week() == 0)))) # True if it is the second Sunday or after in March\\n or\\n (vector(1) and (month() == 11 and (day_of_month() - day_of_week()) < 0 and (absent(day_of_week() == 0))))\\n or # True if it is before the first Sunday in November\\n (\\n vector(1)\\n and\\n (\\n (month() == 3 and hour() >= 6 and (((day_of_month() - day_of_week()) - 7) >= 0 and ((day_of_month() - day_of_week()) - 14) <= 0)) # True if it is spring forward day after the time change\\n or\\n (month() == 11 and hour() < 5 and ((day_of_month() - day_of_week()) - 7) < 0) # True if it is fall back day before the time change\\n )\\n and\\n (day_of_week() == 0)\\n )\\n or\\n vector(0) # If none of the other conditions evaluated True, return False\",\"instant\":true,\"intervalMs\":1000,\"legendFormat\":\"__auto\",\"maxDataPoints\":43200,\"range\":false,\"refId\":\"A\"}"
}
is_paused=falserecord {
metric="Time:AmericaNewYork:Is6wAgoDuringDST"from="A"
}
}
rule {
name="Time:AmericaNewYork:Is7wAgoDuringDST"condition="A"data {
ref_id="A"relative_time_range {
from=4233900to=4233600
}
datasource_uid="grafanacloud-prom"
model = "{\"editorMode\":\"code\",\"expr\":\"# This determines if the time 7 weeks ago was in Daylight Saving Time (for the America/New_York timezone)\\n# Returns 1 for true and 0 for false\\n\\n(vector(1) and (month() > 3 and month() < 11)) # True if month is April through October, which are always in DST\\n or\\n (vector(1) and (month() == 3 and ((day_of_month() - day_of_week()) - 7) >= 0 and (((day_of_month() - day_of_week()) - 14) > 0 or absent(day_of_week() == 0)))) # True if it is the second Sunday or after in March\\n or\\n (vector(1) and (month() == 11 and (day_of_month() - day_of_week()) < 0 and (absent(day_of_week() == 0))))\\n or # True if it is before the first Sunday in November\\n (\\n vector(1)\\n and\\n (\\n (month() == 3 and hour() >= 6 and (((day_of_month() - day_of_week()) - 7) >= 0 and ((day_of_month() - day_of_week()) - 14) <= 0)) # True if it is spring forward day after the time change\\n or\\n (month() == 11 and hour() < 5 and ((day_of_month() - day_of_week()) - 7) < 0) # True if it is fall back day before the time change\\n )\\n and\\n (day_of_week() == 0)\\n )\\n or\\n vector(0) # If none of the other conditions evaluated True, return False\",\"instant\":true,\"intervalMs\":1000,\"legendFormat\":\"__auto\",\"maxDataPoints\":43200,\"range\":false,\"refId\":\"A\"}"
}
is_paused=falserecord {
metric="Time:AmericaNewYork:Is7wAgoDuringDST"from="A"
}
}
rule {
name="Time:AmericaNewYork:Is8wAgoDuringDST"condition="A"data {
ref_id="A"relative_time_range {
from=4838700to=4838400
}
datasource_uid="grafanacloud-prom"
model = "{\"editorMode\":\"code\",\"expr\":\"# This determines if the time 8 weeks ago was in Daylight Saving Time (for the America/New_York timezone)\\n# Returns 1 for true and 0 for false\\n\\n(vector(1) and (month() > 3 and month() < 11)) # True if month is April through October, which are always in DST\\n or\\n (vector(1) and (month() == 3 and ((day_of_month() - day_of_week()) - 7) >= 0 and (((day_of_month() - day_of_week()) - 14) > 0 or absent(day_of_week() == 0)))) # True if it is the second Sunday or after in March\\n or\\n (vector(1) and (month() == 11 and (day_of_month() - day_of_week()) < 0 and (absent(day_of_week() == 0))))\\n or # True if it is before the first Sunday in November\\n (\\n vector(1)\\n and\\n (\\n (month() == 3 and hour() >= 6 and (((day_of_month() - day_of_week()) - 7) >= 0 and ((day_of_month() - day_of_week()) - 14) <= 0)) # True if it is spring forward day after the time change\\n or\\n (month() == 11 and hour() < 5 and ((day_of_month() - day_of_week()) - 7) < 0) # True if it is fall back day before the time change\\n )\\n and\\n (day_of_week() == 0)\\n )\\n or\\n vector(0) # If none of the other conditions evaluated True, return False\",\"instant\":true,\"intervalMs\":1000,\"legendFormat\":\"__auto\",\"maxDataPoints\":43200,\"range\":false,\"refId\":\"A\"}"
}
is_paused=falserecord {
metric="Time:AmericaNewYork:Is8wAgoDuringDST"from="A"
}
}
rule {
name="Time:AmericaNewYork:Is9wAgoDuringDST"condition="A"data {
ref_id="A"relative_time_range {
from=5443500to=5443200
}
datasource_uid="grafanacloud-prom"
model = "{\"editorMode\":\"code\",\"expr\":\"# This determines if the time 9 weeks ago was in Daylight Saving Time (for the America/New_York timezone)\\n# Returns 1 for true and 0 for false\\n\\n(vector(1) and (month() > 3 and month() < 11)) # True if month is April through October, which are always in DST\\n or\\n (vector(1) and (month() == 3 and ((day_of_month() - day_of_week()) - 7) >= 0 and (((day_of_month() - day_of_week()) - 14) > 0 or absent(day_of_week() == 0)))) # True if it is the second Sunday or after in March\\n or\\n (vector(1) and (month() == 11 and (day_of_month() - day_of_week()) < 0 and (absent(day_of_week() == 0))))\\n or # True if it is before the first Sunday in November\\n (\\n vector(1)\\n and\\n (\\n (month() == 3 and hour() >= 6 and (((day_of_month() - day_of_week()) - 7) >= 0 and ((day_of_month() - day_of_week()) - 14) <= 0)) # True if it is spring forward day after the time change\\n or\\n (month() == 11 and hour() < 5 and ((day_of_month() - day_of_week()) - 7) < 0) # True if it is fall back day before the time change\\n )\\n and\\n (day_of_week() == 0)\\n )\\n or\\n vector(0) # If none of the other conditions evaluated True, return False\",\"instant\":true,\"intervalMs\":1000,\"legendFormat\":\"__auto\",\"maxDataPoints\":43200,\"range\":false,\"refId\":\"A\"}"
}
is_paused=falserecord {
metric="Time:AmericaNewYork:Is9wAgoDuringDST"from="A"
}
}
rule {
name="Time:AmericaNewYork:Is10wAgoDuringDST"condition="A"data {
ref_id="A"relative_time_range {
from=6048300to=6048000
}
datasource_uid="grafanacloud-prom"
model = "{\"editorMode\":\"code\",\"expr\":\"# This determines if the time 10 weeks ago was in Daylight Saving Time (for the America/New_York timezone)\\n# Returns 1 for true and 0 for false\\n\\n(vector(1) and (month() > 3 and month() < 11)) # True if month is April through October, which are always in DST\\n or\\n (vector(1) and (month() == 3 and ((day_of_month() - day_of_week()) - 7) >= 0 and (((day_of_month() - day_of_week()) - 14) > 0 or absent(day_of_week() == 0)))) # True if it is the second Sunday or after in March\\n or\\n (vector(1) and (month() == 11 and (day_of_month() - day_of_week()) < 0 and (absent(day_of_week() == 0))))\\n or # True if it is before the first Sunday in November\\n (\\n vector(1)\\n and\\n (\\n (month() == 3 and hour() >= 6 and (((day_of_month() - day_of_week()) - 7) >= 0 and ((day_of_month() - day_of_week()) - 14) <= 0)) # True if it is spring forward day after the time change\\n or\\n (month() == 11 and hour() < 5 and ((day_of_month() - day_of_week()) - 7) < 0) # True if it is fall back day before the time change\\n )\\n and\\n (day_of_week() == 0)\\n )\\n or\\n vector(0) # If none of the other conditions evaluated True, return False\",\"instant\":true,\"intervalMs\":1000,\"legendFormat\":\"__auto\",\"maxDataPoints\":43200,\"range\":false,\"refId\":\"A\"}"
}
is_paused=falserecord {
metric="Time:AmericaNewYork:Is10wAgoDuringDST"from="A"
}
}
}
Expected Behavior
terraform plan should only show updates for things that have actually changed in the TF config since last time it was run.
Actual Behavior
terraform plan shows changes for every recording rule every time it is run. See below for output:
Terraform used the selected providers to generate the following execution
plan. Resource actions are indicated with the following symbols:
~ update in-place
Terraform will perform the following actions:
# module.grafana_alertmanager_alerts.grafana_rule_group.recording_rules_cus["applies_to_env"] will be updated in-place
~ resource "grafana_rule_group" "recording_rules_cus" {
id = "1:ee5xed645t4aod:Every 5 Minutes (CUS Only)"
name = "Every 5 Minutes (CUS Only)"
# (4 unchanged attributes hidden)
~ rule {
+ condition = "A"
+ exec_err_state = "Alerting"
name = "Time:AmericaNewYork:IsNowDuringDST"
+ no_data_state = "NoData"
# (5 unchanged attributes hidden)
# (2 unchanged blocks hidden)
}
~ rule {
+ condition = "A"
+ exec_err_state = "Alerting"
name = "Time:AmericaNewYork:Is1wAgoDuringDST"
+ no_data_state = "NoData"
# (5 unchanged attributes hidden)
# (2 unchanged blocks hidden)
}
~ rule {
+ condition = "A"
+ exec_err_state = "Alerting"
name = "Time:AmericaNewYork:Is2wAgoDuringDST"
+ no_data_state = "NoData"
# (5 unchanged attributes hidden)
# (2 unchanged blocks hidden)
}
~ rule {
+ condition = "A"
+ exec_err_state = "Alerting"
name = "Time:AmericaNewYork:Is3wAgoDuringDST"
+ no_data_state = "NoData"
# (5 unchanged attributes hidden)
# (2 unchanged blocks hidden)
}
~ rule {
+ condition = "A"
+ exec_err_state = "Alerting"
name = "Time:AmericaNewYork:Is4wAgoDuringDST"
+ no_data_state = "NoData"
# (5 unchanged attributes hidden)
# (2 unchanged blocks hidden)
}
~ rule {
+ condition = "A"
+ exec_err_state = "Alerting"
name = "Time:AmericaNewYork:Is5wAgoDuringDST"
+ no_data_state = "NoData"
# (5 unchanged attributes hidden)
# (2 unchanged blocks hidden)
}
~ rule {
+ condition = "A"
+ exec_err_state = "Alerting"
name = "Time:AmericaNewYork:Is6wAgoDuringDST"
+ no_data_state = "NoData"
# (5 unchanged attributes hidden)
# (2 unchanged blocks hidden)
}
~ rule {
+ condition = "A"
+ exec_err_state = "Alerting"
name = "Time:AmericaNewYork:Is7wAgoDuringDST"
+ no_data_state = "NoData"
# (5 unchanged attributes hidden)
# (2 unchanged blocks hidden)
}
~ rule {
+ condition = "A"
+ exec_err_state = "Alerting"
name = "Time:AmericaNewYork:Is8wAgoDuringDST"
+ no_data_state = "NoData"
# (5 unchanged attributes hidden)
# (2 unchanged blocks hidden)
}
~ rule {
+ condition = "A"
+ exec_err_state = "Alerting"
name = "Time:AmericaNewYork:Is9wAgoDuringDST"
+ no_data_state = "NoData"
# (5 unchanged attributes hidden)
# (2 unchanged blocks hidden)
}
~ rule {
+ condition = "A"
+ exec_err_state = "Alerting"
name = "Time:AmericaNewYork:Is10wAgoDuringDST"
+ no_data_state = "NoData"
# (5 unchanged attributes hidden)
# (2 unchanged blocks hidden)
}
}
Plan: 0 to add, 1 to change, 0 to destroy.
Steps to Reproduce
Plan and apply any recording rule.
Run plan again with no changes to config.
Important Factoids
exec_error_state and no_data_state are not set in the TF config, and I don't believe they are even relevant for recording rules.
condition is set in the TF config, but that is only because the provider requires it to be set for every rule, and I feel like perhaps it shouldn't be required for recording rules? It's not included when you export a recording rule as HCL from Grafana itself.
References
No response
The text was updated successfully, but these errors were encountered:
Terraform Version
1.10.2
Terraform Grafana Provider Version
3.15.3
Grafana Version
Cloud
Affected Resource(s)
grafana_rule_group
Terraform Configuration Files
Expected Behavior
terraform plan
should only show updates for things that have actually changed in the TF config since last time it was run.Actual Behavior
terraform plan
shows changes for every recording rule every time it is run. See below for output:Steps to Reproduce
Important Factoids
exec_error_state
andno_data_state
are not set in the TF config, and I don't believe they are even relevant for recording rules.condition
is set in the TF config, but that is only because the provider requires it to be set for every rule, and I feel like perhaps it shouldn't be required for recording rules? It's not included when you export a recording rule as HCL from Grafana itself.References
No response
The text was updated successfully, but these errors were encountered: