Skip to content

Commit 011548e

Browse files
committed
refactor(monitor_alert_v2): remove deprecated trigger_after_minutes field
1 parent 41292b5 commit 011548e

File tree

2 files changed

+1
-20
lines changed

2 files changed

+1
-20
lines changed

sysdig/resource_sysdig_monitor_alert_v2_metric.go

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -33,18 +33,10 @@ func resourceSysdigMonitorAlertV2Metric() *schema.Resource {
3333
},
3434

3535
Schema: createScopedSegmentedAlertV2Schema(createAlertV2Schema(map[string]*schema.Schema{
36-
"trigger_after_minutes": {
37-
Type: schema.TypeInt,
38-
Optional: true,
39-
Computed: true, // computed if range_seconds is defined
40-
Deprecated: "Use range_seconds instead",
41-
ValidateFunc: validation.IntAtLeast(1),
42-
},
4336
"range_seconds": {
4437
Type: schema.TypeInt,
4538
Optional: true,
4639
Computed: true, // computed if trigger_after_minutes is defined
47-
ExactlyOneOf: []string{"trigger_after_minutes"},
4840
ValidateFunc: validation.IntAtLeast(60),
4941
},
5042
"duration_seconds": {
@@ -236,15 +228,6 @@ func buildAlertV2MetricStruct(d *schema.ResourceData) (*v2.AlertV2Metric, error)
236228
config.Range = d.Get("range_seconds").(int)
237229
}
238230

239-
if d.HasChange("trigger_after_minutes") {
240-
// GetOk returns true even if the value is stored only in the state and not in the user config:
241-
// to avoid applying a trigger_after_minutes old value from the state even if the user removed it from the config
242-
// we use HasChange that is true only if the user has changed (or created) it - and so it must be in the config
243-
if attr, ok := d.GetOk("trigger_after_minutes"); ok && attr != nil {
244-
config.Range = minutesToSeconds(d.Get("trigger_after_minutes").(int))
245-
}
246-
}
247-
248231
if attr, ok := d.GetOk("duration_seconds"); ok && attr != nil {
249232
config.Duration = d.Get("duration_seconds").(int)
250233
}
@@ -276,7 +259,6 @@ func updateAlertV2MetricState(d *schema.ResourceData, alert *v2.AlertV2Metric) e
276259
return err
277260
}
278261

279-
_ = d.Set("trigger_after_minutes", secondsToMinutes(alert.Config.Range))
280262
_ = d.Set("range_seconds", alert.Config.Range)
281263
_ = d.Set("duration_seconds", alert.Config.Duration)
282264

website/docs/r/monitor_alert_v2_metric.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,7 @@ These arguments are common to all alerts in Sysdig Monitor.
7373

7474
* `name` - (Required) The name of the alert rule. It must be unique.
7575
* `description` - (Optional) The description of Monitor alert.
76-
* `range_seconds` - (Optional, Required if `trigger_after_minutes` is not defined): The rolling time aggregation period in which the relevant metric data is evaluated.
77-
* `trigger_after_minutes` - (Optional, Deprecated) The rolling time aggregation period in which the relevant metric data is evaluated. Deprecated: use `range_seconds` instead.
76+
* `range_seconds` - (Optional): The rolling time aggregation period in which the relevant metric data is evaluated.
7877
* `duration_seconds` - (Optional) A time interval that defines for how long a condition should be met before an alert occurrence is created.
7978
* `group` - (Optional) Used to group alert rules in the UI. This value must be a lowercase string.
8079
* `severity` - (Optional) Severity of the Monitor alert. It must be `high`, `medium`, `low` or `info`. Default: `low`.

0 commit comments

Comments
 (0)