Skip to content

Commit

Permalink
fix(alerts): fix operator for form based prometheus alerts (#537)
Browse files Browse the repository at this point in the history
  • Loading branch information
dbonf authored Jul 29, 2024
1 parent 6787bc6 commit 1be676c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func resourceSysdigMonitorAlertV2FormBasedPrometheus() *schema.Resource {
"operator": {
Type: schema.TypeString,
Required: true,
ValidateFunc: validation.StringInSlice([]string{">", ">=", "<", "<=", "=", "!="}, false),
ValidateFunc: validation.StringInSlice([]string{">", ">=", "<", "<=", "==", "!="}, false),
},
"threshold": {
Type: schema.TypeFloat,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ func TestAccAlertV2FormBasedPrometheusTest(t *testing.T) {
{
Config: alertV2FormBasedPrometheusTest(rText()),
},
{
Config: alertV2FormBasedPrometheusWithEqualOperatorTest(rText()),
},
{
Config: alertV2FormBasedPrometheusTestWithNoData(rText()),
},
Expand Down Expand Up @@ -77,6 +80,17 @@ resource "sysdig_monitor_alert_v2_form_based_prometheus" "sample" {
`, name)
}

func alertV2FormBasedPrometheusWithEqualOperatorTest(name string) string {
return fmt.Sprintf(`
resource "sysdig_monitor_alert_v2_form_based_prometheus" "sample" {
name = "TERRAFORM TEST - FORM BASED PROMETHEUS %s"
query = "avg_over_time(sysdig_container_cpu_used_percent{container_name=\"test\"}[59s])"
operator = "=="
threshold = 50
}
`, name)
}

func alertV2FormBasedPrometheusTestWithNoData(name string) string {
return fmt.Sprintf(`
resource "sysdig_monitor_alert_v2_form_based_prometheus" "sample" {
Expand Down
2 changes: 1 addition & 1 deletion website/docs/r/monitor_alert_v2_form_based_prometheus.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ By defining this field, the user can add link to notifications.
### Form Based Prometheus alert arguments

* `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])`.
* `operator` - (Required) Operator for the condition to alert on. It can be `>`, `>=`, `<`, `<=`, `=` or `!=`.
* `operator` - (Required) Operator for the condition to alert on. It can be `>`, `>=`, `<`, `<=`, `==` or `!=`.
* `threshold` - (Required) Threshold used together with `op` to trigger the alert if crossed.
* `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`.
* `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`.
Expand Down

0 comments on commit 1be676c

Please sign in to comment.