Skip to content

Commit 2c2c91c

Browse files
Update Monitoring Alert Policy SQL Condition Documentation (#13214) (#21679)
[upstream:516920334b5775456396b9916dc1be6dc606873f] Signed-off-by: Modular Magician <magic-modules@google.com>
1 parent 10e3c1f commit 2c2c91c

File tree

3 files changed

+38
-15
lines changed

3 files changed

+38
-15
lines changed

.changelog/13214.txt

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:none
2+
Added examples of monitoring alert policy sql conditions. Corrected field labels to reflect their intended behavior.
3+
```

google/services/monitoring/resource_monitoring_alert_policy.go

+8-9
Original file line numberDiff line numberDiff line change
@@ -474,18 +474,17 @@ to filter the input so that the query receives all rows received
474474
since the last time the query was run.`,
475475
},
476476
"boolean_test": {
477-
Type: schema.TypeList,
478-
Optional: true,
479-
Description: `The start date and time of the query. If left unspecified, then the
480-
query will start immediately.`,
481-
MaxItems: 1,
477+
Type: schema.TypeList,
478+
Optional: true,
479+
Description: `A test that uses an alerting result in a boolean column produced by the SQL query.`,
480+
MaxItems: 1,
482481
Elem: &schema.Resource{
483482
Schema: map[string]*schema.Schema{
484483
"column": {
485484
Type: schema.TypeString,
486485
Required: true,
487-
Description: `The name of the column containing the boolean value. If the value
488-
in a row is NULL, that row is ignored.`,
486+
Description: `The name of the column containing the boolean value. If the value in a row is
487+
NULL, that row is ignored.`,
489488
},
490489
},
491490
},
@@ -591,7 +590,7 @@ equal to 5 minutes and less than or equal to 1440 minutes.`,
591590
"row_count_test": {
592591
Type: schema.TypeList,
593592
Optional: true,
594-
Description: `Test the row count against a threshold.`,
593+
Description: `A test that checks if the number of rows in the result set violates some threshold.`,
595594
MaxItems: 1,
596595
Elem: &schema.Resource{
597596
Schema: map[string]*schema.Schema{
@@ -611,7 +610,7 @@ COMPARISON_GT are supported currently. Possible values: ["COMPARISON_GT", "COMPA
611610
"threshold": {
612611
Type: schema.TypeInt,
613612
Required: true,
614-
Description: `Test the boolean value in the indicated column.`,
613+
Description: `The value against which to compare the row count.`,
615614
},
616615
},
617616
},

website/docs/r/monitoring_alert_policy.html.markdown

+27-6
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,28 @@ resource "google_monitoring_alert_policy" "alert_policy" {
136136
}
137137
}
138138
```
139+
## Example Usage - Monitoring Alert Policy Sql Condition
140+
141+
142+
```hcl
143+
resource "google_monitoring_alert_policy" "alert_policy" {
144+
display_name = "My Alert Policy"
145+
combiner = "OR"
146+
conditions {
147+
display_name = "minutes row count"
148+
condition_sql {
149+
query = "SELECT severity, resource FROM my_project.global._Default._AllLogs WHERE severity IS NOT NULL"
150+
minutes {
151+
periodicity = 600
152+
}
153+
row_count_test {
154+
comparison = "COMPARISON_GT"
155+
threshold = "0"
156+
}
157+
}
158+
}
159+
}
160+
```
139161

140162
## Argument Reference
141163

@@ -879,13 +901,12 @@ The following arguments are supported:
879901

880902
* `row_count_test` -
881903
(Optional)
882-
Test the row count against a threshold.
904+
A test that checks if the number of rows in the result set violates some threshold.
883905
Structure is [documented below](#nested_conditions_conditions_condition_sql_row_count_test).
884906

885907
* `boolean_test` -
886908
(Optional)
887-
The start date and time of the query. If left unspecified, then the
888-
query will start immediately.
909+
A test that uses an alerting result in a boolean column produced by the SQL query.
889910
Structure is [documented below](#nested_conditions_conditions_condition_sql_boolean_test).
890911

891912

@@ -965,14 +986,14 @@ The following arguments are supported:
965986

966987
* `threshold` -
967988
(Required)
968-
Test the boolean value in the indicated column.
989+
The value against which to compare the row count.
969990

970991
<a name="nested_conditions_conditions_condition_sql_boolean_test"></a>The `boolean_test` block supports:
971992

972993
* `column` -
973994
(Required)
974-
The name of the column containing the boolean value. If the value
975-
in a row is NULL, that row is ignored.
995+
The name of the column containing the boolean value. If the value in a row is
996+
NULL, that row is ignored.
976997

977998
- - -
978999

0 commit comments

Comments
 (0)