Skip to content

Commit 3555895

Browse files
authored
Merge pull request #267 from SumoLogic/avijit-release-trigger-conditions-and-deprecate-triggers
Avijit release trigger conditions and deprecate triggers
2 parents 93e440b + 165de28 commit 3555895

File tree

3 files changed

+108
-55
lines changed

3 files changed

+108
-55
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
FEATURES:
44

55
* **New Resource:** sumologic_hierarchy (GH-260)
6+
DEPRECATIONS:
7+
8+
* resource/sumologic_monitor: Deprecated `triggers` in favor of `trigger_conditions` (GH-267)
69

710
## 2.9.10 (August 24, 2021)
811

sumologic/resource_sumologic_monitors_library_monitor.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,9 @@ func resourceSumologicMonitorsLibraryMonitor() *schema.Resource {
8585
},
8686

8787
"triggers": {
88-
Type: schema.TypeList,
89-
Optional: true,
88+
Type: schema.TypeList,
89+
Optional: true,
90+
Deprecated: "The field `triggers` is deprecated and will be removed in a future release of the provider -- please use `trigger_conditions` instead.",
9091
Elem: &schema.Resource{
9192
Schema: map[string]*schema.Schema{
9293
"trigger_type": {

website/docs/r/monitor.html.markdown

Lines changed: 102 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -24,23 +24,21 @@ resource "sumologic_monitor" "tf_logs_monitor_1" {
2424
row_id = "A"
2525
query = "_sourceCategory=event-action info"
2626
}
27-
triggers {
28-
threshold_type = "GreaterThan"
29-
threshold = 40.0
30-
time_range = "15m"
31-
occurrence_type = "ResultCount"
32-
trigger_source = "AllResults"
33-
trigger_type = "Critical"
34-
detection_method = "StaticCondition"
27+
trigger_conditions {
28+
logs_static_condition {
29+
critical {
30+
time_range = "15m"
31+
alert {
32+
threshold = 40.0
33+
threshold_type = "GreaterThan"
34+
}
35+
resolution {
36+
threshold = 40.0
37+
threshold_type = "LessThanOrEqual"
38+
}
39+
}
40+
}
3541
}
36-
triggers {
37-
threshold_type = "LessThanOrEqual"
38-
threshold = 40.0
39-
time_range = "15m"
40-
occurrence_type = "ResultCount"
41-
trigger_source = "AllResults"
42-
trigger_type = "ResolvedCritical"
43-
detection_method = "StaticCondition" }
4442
notifications {
4543
notification {
4644
connection_type = "Email"
@@ -78,23 +76,21 @@ resource "sumologic_monitor" "tf_metrics_monitor_1" {
7876
row_id = "A"
7977
query = "metric=CPU_Idle _sourceCategory=event-action"
8078
}
81-
triggers {
82-
threshold_type = "GreaterThan"
83-
threshold = 40.0
84-
time_range = "15m"
85-
occurrence_type = "ResultCount"
86-
trigger_source = "AllResults"
87-
trigger_type = "Critical"
88-
detection_method = "StaticCondition"
89-
}
90-
triggers {
91-
threshold_type = "LessThanOrEqual"
92-
threshold = 40.0
93-
time_range = "15m"
94-
occurrence_type = "ResultCount"
95-
trigger_source = "AllResults"
96-
trigger_type = "ResolvedCritical"
97-
detection_method = "StaticCondition"
79+
trigger_conditions {
80+
metrics_static_condition {
81+
critical {
82+
time_range = "15m"
83+
occurrence_type = "AtLeastOnce"
84+
alert {
85+
threshold = 40.0
86+
threshold_type = "GreaterThan"
87+
}
88+
resolution {
89+
threshold = 40.0
90+
threshold_type = "LessThanOrEqual"
91+
}
92+
}
93+
}
9894
}
9995
notifications {
10096
notification {
@@ -146,23 +142,20 @@ resource "sumologic_monitor" "tf_logs_monitor_2" {
146142
row_id = "A"
147143
query = "_sourceCategory=event-action info"
148144
}
149-
triggers {
150-
threshold_type = "GreaterThan"
151-
threshold = 40.0
152-
time_range = "15m"
153-
occurrence_type = "ResultCount"
154-
trigger_source = "AllResults"
155-
trigger_type = "Critical"
156-
detection_method = "StaticCondition"
157-
}
158-
triggers {
159-
threshold_type = "LessThanOrEqual"
160-
threshold = 40.0
161-
time_range = "15m"
162-
occurrence_type = "ResultCount"
163-
trigger_source = "AllResults"
164-
trigger_type = "ResolvedCritical"
165-
detection_method = "StaticCondition"
145+
trigger_conditions {
146+
logs_static_condition {
147+
critical {
148+
time_range = "15m"
149+
alert {
150+
threshold = 40.0
151+
threshold_type = "GreaterThan"
152+
}
153+
resolution {
154+
threshold = 40.0
155+
threshold_type = "LessThanOrEqual"
156+
}
157+
}
158+
}
166159
}
167160
notifications {
168161
notification {
@@ -215,8 +208,8 @@ The following arguments are supported:
215208
- `Logs`: A logs query monitor.
216209
- `Metrics`: A metrics query monitor.
217210
- `queries` - (Required) All queries from the monitor.
218-
- `trigger_conditions` - (Beta) (Required if not using `triggers`) Defines the conditions of when to send notifications. NOTE: `trigger_conditions` supplants the `triggers` argument.
219-
- `triggers` - Defines the conditions of when to send notifications.
211+
- `trigger_conditions` - (Required if not using `triggers`) Defines the conditions of when to send notifications. NOTE: `trigger_conditions` supplants the `triggers` argument.
212+
- `triggers` - (Deprecated) Defines the conditions of when to send notifications.
220213
- `notifications` - (Optional) The notifications the monitor will send when the respective trigger condition is met.
221214
- `group_notifications` - (Optional) Whether or not to group notifications for individual items that meet the trigger condition. Defaults to true.
222215
- `playbook` - (Optional - Beta) Notes such as links and instruction to help you resolve alerts triggered by this monitor. {{Markdown}} supported. It will be enabled only if available for your organization. Please contact your Sumo Logic account team to learn more.
@@ -231,7 +224,7 @@ Additional data provided in state:
231224
- `Normal`
232225
- `Disabled`
233226

234-
## The `trigger_conditions` block (Beta)
227+
## The `trigger_conditions` block
235228
A `trigger_conditions` block configures conditions for sending notifications.
236229
### Example
237230
```hcl
@@ -340,6 +333,62 @@ Here is a summary of arguments for each condition type (fields which are not mar
340333
- `time_range` (Required)
341334
- `trigger_source` (Required)
342335

336+
## The `triggers` block
337+
The `triggers` block is deprecated. Please use `trigger_conditions` to specify notification conditions.
338+
339+
Here's an example logs monitor that uses `triggers` to specify trigger conditions:
340+
```hcl
341+
resource "sumologic_monitor" "tf_logs_monitor_1" {
342+
name = "Terraform Logs Monitor"
343+
description = "tf logs monitor"
344+
type = "MonitorsLibraryMonitor"
345+
is_disabled = false
346+
content_type = "Monitor"
347+
monitor_type = "Logs"
348+
queries {
349+
row_id = "A"
350+
query = "_sourceCategory=event-action info"
351+
}
352+
triggers {
353+
threshold_type = "GreaterThan"
354+
threshold = 40.0
355+
time_range = "15m"
356+
occurrence_type = "ResultCount"
357+
trigger_source = "AllResults"
358+
trigger_type = "Critical"
359+
detection_method = "StaticCondition"
360+
}
361+
triggers {
362+
threshold_type = "LessThanOrEqual"
363+
threshold = 40.0
364+
time_range = "15m"
365+
occurrence_type = "ResultCount"
366+
trigger_source = "AllResults"
367+
trigger_type = "ResolvedCritical"
368+
detection_method = "StaticCondition"
369+
}
370+
notifications {
371+
notification {
372+
connection_type = "Email"
373+
recipients = [
374+
375+
]
376+
subject = "Monitor Alert: {{TriggerType}} on {{Name}}"
377+
time_zone = "PST"
378+
message_body = "Triggered {{TriggerType}} Alert on {{Name}}: {{QueryURL}}"
379+
}
380+
run_for_trigger_types = ["Critical", "ResolvedCritical"]
381+
}
382+
notifications {
383+
notification {
384+
connection_type = "Webhook"
385+
connection_id = "0000000000ABC123"
386+
}
387+
run_for_trigger_types = ["Critical", "ResolvedCritical"]
388+
}
389+
}
390+
```
391+
343392
## Import
344393

345394
Monitors can be imported using the monitor ID, such as:

0 commit comments

Comments
 (0)