Skip to content

Commit 3dddf13

Browse files
committed
Alerting fields should be Elastic durations, not Golang durations
1 parent f4bd9a5 commit 3dddf13

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

internal/kibana/alerting.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ func ResourceAlertingRule() *schema.Resource {
7171
Description: "The check interval, which specifies how frequently the rule conditions are checked. The interval must be specified in seconds, minutes, hours or days.",
7272
Type: schema.TypeString,
7373
Required: true,
74-
ValidateFunc: utils.StringIsDuration,
74+
ValidateFunc: utils.StringIsElasticDuration,
7575
},
7676
"actions": {
7777
Description: "An action that runs under defined conditions.",
@@ -120,7 +120,7 @@ func ResourceAlertingRule() *schema.Resource {
120120
Description: "Defines how often an alert generates repeated actions. This custom action interval must be specified in seconds, minutes, hours, or days. For example, 10m or 1h. This property is applicable only if `notify_when` is `onThrottleInterval`. NOTE: This is a rule level property; if you update the rule in Kibana, it is automatically changed to use action-specific `throttle` values.",
121121
Type: schema.TypeString,
122122
Optional: true,
123-
ValidateFunc: utils.StringIsDuration,
123+
ValidateFunc: utils.StringIsElasticDuration,
124124
},
125125
},
126126
},
@@ -198,7 +198,7 @@ func ResourceAlertingRule() *schema.Resource {
198198
Description: "Deprecated in 8.13.0. Defines how often an alert generates repeated actions. This custom action interval must be specified in seconds, minutes, hours, or days. For example, 10m or 1h. This property is applicable only if `notify_when` is `onThrottleInterval`. NOTE: This is a rule level property; if you update the rule in Kibana, it is automatically changed to use action-specific `throttle` values.",
199199
Type: schema.TypeString,
200200
Optional: true,
201-
ValidateFunc: utils.StringIsDuration,
201+
ValidateFunc: utils.StringIsElasticDuration,
202202
},
203203
"scheduled_task_id": {
204204
Description: "ID of the scheduled task that will execute the alert.",

internal/kibana/alerting_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ func TestAccResourceAlertingRule(t *testing.T) {
5252
resource.TestCheckResourceAttr("elasticstack_kibana_alerting_rule.test_rule", "consumer", "alerts"),
5353
resource.TestCheckResourceAttr("elasticstack_kibana_alerting_rule.test_rule", "notify_when", "onActiveAlert"),
5454
resource.TestCheckResourceAttr("elasticstack_kibana_alerting_rule.test_rule", "rule_type_id", ".index-threshold"),
55-
resource.TestCheckResourceAttr("elasticstack_kibana_alerting_rule.test_rule", "interval", "10m"),
55+
resource.TestCheckResourceAttr("elasticstack_kibana_alerting_rule.test_rule", "interval", "1d"),
5656
resource.TestCheckResourceAttr("elasticstack_kibana_alerting_rule.test_rule", "enabled", "false"),
5757
resource.TestCheckResourceAttr("elasticstack_kibana_alerting_rule.test_rule", "tags.0", "first"),
5858
resource.TestCheckResourceAttr("elasticstack_kibana_alerting_rule.test_rule", "tags.1", "second"),
@@ -244,7 +244,7 @@ resource "elasticstack_kibana_alerting_rule" "test_rule" {
244244
termField = "name"
245245
})
246246
rule_type_id = ".index-threshold"
247-
interval = "10m"
247+
interval = "1d"
248248
enabled = false
249249
tags = ["first", "second"]
250250
}
@@ -439,7 +439,7 @@ resource "elasticstack_kibana_alerting_rule" "test_rule" {
439439
days = [1,2,3]
440440
timezone = "Africa/Accra"
441441
hours_start = "01:00"
442-
hours_end = "07:00"
442+
hours_end = "07:00"
443443
}
444444
}
445445
}
@@ -514,7 +514,7 @@ resource "elasticstack_kibana_alerting_rule" "test_rule" {
514514
days = [7]
515515
timezone = "Pacific/Honolulu"
516516
hours_start = "02:00"
517-
hours_end = "03:00"
517+
hours_end = "03:00"
518518
}
519519
}
520520
}

0 commit comments

Comments
 (0)