Skip to content

Commit 1be676c

Browse files
authored
fix(alerts): fix operator for form based prometheus alerts (#537)
1 parent 6787bc6 commit 1be676c

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

sysdig/resource_sysdig_monitor_alert_v2_form_based_prometheus.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ func resourceSysdigMonitorAlertV2FormBasedPrometheus() *schema.Resource {
3636
"operator": {
3737
Type: schema.TypeString,
3838
Required: true,
39-
ValidateFunc: validation.StringInSlice([]string{">", ">=", "<", "<=", "=", "!="}, false),
39+
ValidateFunc: validation.StringInSlice([]string{">", ">=", "<", "<=", "==", "!="}, false),
4040
},
4141
"threshold": {
4242
Type: schema.TypeFloat,

sysdig/resource_sysdig_monitor_alert_v2_form_based_prometheus_test.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ func TestAccAlertV2FormBasedPrometheusTest(t *testing.T) {
2727
{
2828
Config: alertV2FormBasedPrometheusTest(rText()),
2929
},
30+
{
31+
Config: alertV2FormBasedPrometheusWithEqualOperatorTest(rText()),
32+
},
3033
{
3134
Config: alertV2FormBasedPrometheusTestWithNoData(rText()),
3235
},
@@ -77,6 +80,17 @@ resource "sysdig_monitor_alert_v2_form_based_prometheus" "sample" {
7780
`, name)
7881
}
7982

83+
func alertV2FormBasedPrometheusWithEqualOperatorTest(name string) string {
84+
return fmt.Sprintf(`
85+
resource "sysdig_monitor_alert_v2_form_based_prometheus" "sample" {
86+
name = "TERRAFORM TEST - FORM BASED PROMETHEUS %s"
87+
query = "avg_over_time(sysdig_container_cpu_used_percent{container_name=\"test\"}[59s])"
88+
operator = "=="
89+
threshold = 50
90+
}
91+
`, name)
92+
}
93+
8094
func alertV2FormBasedPrometheusTestWithNoData(name string) string {
8195
return fmt.Sprintf(`
8296
resource "sysdig_monitor_alert_v2_form_based_prometheus" "sample" {

website/docs/r/monitor_alert_v2_form_based_prometheus.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ By defining this field, the user can add link to notifications.
7474
### Form Based Prometheus alert arguments
7575

7676
* `query` - (Required) PromQL-based metric expression to alert on. Example: `sysdig_host_memory_available_bytes / sysdig_host_memory_total_bytes * 100` or `avg_over_time(sysdig_container_cpu_used_percent{}[59s])`.
77-
* `operator` - (Required) Operator for the condition to alert on. It can be `>`, `>=`, `<`, `<=`, `=` or `!=`.
77+
* `operator` - (Required) Operator for the condition to alert on. It can be `>`, `>=`, `<`, `<=`, `==` or `!=`.
7878
* `threshold` - (Required) Threshold used together with `op` to trigger the alert if crossed.
7979
* `warning_threshold` - (Optional) Warning threshold used together with `op` to trigger the alert if crossed. Must be a number that triggers the alert before reaching the main `threshold`.
8080
* `no_data_behaviour` - (Optional) behaviour in case of missing data. Can be `DO_NOTHING`, i.e. ignore, or `TRIGGER`, i.e. notify on main threshold. Default: `DO_NOTHING`.

0 commit comments

Comments
 (0)