Skip to content

Commit 02a5c9d

Browse files
committed
updated docs with webhook examples and updated field names
1 parent 2e18fc5 commit 02a5c9d

File tree

1 file changed

+116
-13
lines changed

1 file changed

+116
-13
lines changed

website/docs/r/monitor.html.markdown

Lines changed: 116 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,33 @@ resource "sumologic_monitor" "tf_logs_monitor_1" {
3232
trigger_type = "Critical"
3333
detection_method = "StaticCondition"
3434
}
35+
triggers {
36+
threshold_type = "LessThanOrEqual"
37+
threshold = 40.0
38+
time_range = "15m"
39+
occurrence_type = "ResultCount"
40+
trigger_source = "AllResults"
41+
trigger_type = "ResolvedCritical"
42+
detection_method = "StaticCondition"
43+
}
3544
notifications {
3645
notification {
37-
action_type = "EmailAction"
38-
recipients = ["[email protected]"]
39-
subject = "Triggered: tf logs monitor"
40-
time_zone = "PST"
41-
message_body = "testing123"
46+
connection_type = "Email"
47+
recipients = [
48+
49+
]
50+
subject = "Monitor Alert: {{TriggerType}} on {{Name}}"
51+
time_zone = "PST"
52+
message_body = "Triggered {{TriggerType}} Alert on {{Name}}: {{QueryURL}}"
4253
}
43-
run_for_trigger_types = ["Critical"]
54+
run_for_trigger_types = ["Critical", "ResolvedCritical"]
55+
}
56+
notifications {
57+
notification {
58+
connection_type = "Webhook"
59+
connection_id = "0000000000ABC123"
60+
}
61+
run_for_trigger_types = ["Critical", "ResolvedCritical"]
4462
}
4563
}
4664
```
@@ -53,7 +71,6 @@ resource "sumologic_monitor" "tf_metrics_monitor_1" {
5371
description = "tf metrics monitor"
5472
type = "MonitorsLibraryMonitor"
5573
is_disabled = false
56-
parent_id = "0000000000000001"
5774
content_type = "Monitor"
5875
monitor_type = "Metrics"
5976
queries {
@@ -80,17 +97,103 @@ resource "sumologic_monitor" "tf_metrics_monitor_1" {
8097
}
8198
notifications {
8299
notification {
83-
action_type = "EmailAction"
84-
recipients = ["[email protected]"]
85-
subject = "Triggered: tf metrics monitor"
86-
time_zone = "PST"
87-
message_body = "testing123"
100+
connection_type = "Email"
101+
recipients = ["[email protected]"]
102+
subject = "Triggered {{TriggerType}} Alert on Monitor {{Name}}"
103+
time_zone = "PST"
104+
message_body = "Triggered {{TriggerType}} Alert on {{Name}}: {{QueryURL}}"
88105
}
89106
run_for_trigger_types = ["Critical","ResolvedCritical"]
90107
}
91108
}
92109
```
93110

111+
## Example Logs Monitor with Webhook Connection and Folder
112+
113+
```hcl
114+
resource "sumologic_monitor_folder" "tf_monitor_folder_1" {
115+
name = "Terraform Managed Folder 1"
116+
description = "A folder for Monitors"
117+
}
118+
119+
resource "sumologic_connection" "example_pagerduty_connection" {
120+
name = "example_pagerduty_connection"
121+
description = "PagerDuty connection for notifications from Monitors"
122+
type = "WebhookConnection"
123+
webhook_type = "PagerDuty"
124+
url = "https://events.pagerduty.com/"
125+
default_payload = <<JSON
126+
{
127+
"service_key": "pagerduty_api_integration_key",
128+
"event_type": "trigger",
129+
"description": "PagerDuty connection for notifications",
130+
"client": "Sumo Logic",
131+
"client_url": ""
132+
}
133+
JSON
134+
}
135+
136+
resource "sumologic_monitor" "tf_logs_monitor_2" {
137+
name = "Terraform Logs Monitor with Webhook Connection"
138+
description = "tf logs monitor with webhook"
139+
type = "MonitorsLibraryMonitor"
140+
parent_id = sumologic_monitor_folder.tf_monitor_folder_1.id
141+
is_disabled = false
142+
content_type = "Monitor"
143+
monitor_type = "Logs"
144+
queries {
145+
row_id = "A"
146+
query = "_sourceCategory=event-action info"
147+
}
148+
triggers {
149+
threshold_type = "GreaterThan"
150+
threshold = 40.0
151+
time_range = "15m"
152+
occurrence_type = "ResultCount"
153+
trigger_source = "AllResults"
154+
trigger_type = "Critical"
155+
detection_method = "StaticCondition"
156+
}
157+
triggers {
158+
threshold_type = "LessThanOrEqual"
159+
threshold = 40.0
160+
time_range = "15m"
161+
occurrence_type = "ResultCount"
162+
trigger_source = "AllResults"
163+
trigger_type = "ResolvedCritical"
164+
detection_method = "StaticCondition"
165+
}
166+
notifications {
167+
notification {
168+
connection_type = "Email"
169+
recipients = [
170+
171+
]
172+
subject = "Monitor Alert: {{TriggerType}} on {{Name}}"
173+
time_zone = "PST"
174+
message_body = "Triggered {{TriggerType}} Alert on {{Name}}: {{QueryURL}}"
175+
}
176+
run_for_trigger_types = ["Critical", "ResolvedCritical"]
177+
}
178+
notifications {
179+
notification {
180+
connection_type = "PagerDuty"
181+
connection_id = sumologic_connection.example_pagerduty_connection.id
182+
payload_override = <<JSON
183+
{
184+
"service_key": "your_pagerduty_api_integration_key",
185+
"event_type": "trigger",
186+
"description": "Alert: Triggered {{TriggerType}} for Monitor {{Name}}",
187+
"client": "Sumo Logic",
188+
"client_url": "{{QueryUrl}}"
189+
}
190+
JSON
191+
}
192+
run_for_trigger_types = ["Critical", "ResolvedCritical"]
193+
}
194+
}
195+
```
196+
94197
## Example Monitor Folder
95198

96199
NOTE: Monitor folders are considered a different resource from Library content folders.
@@ -140,4 +243,4 @@ Monitors can be imported using the monitor ID, such as:
140243
terraform import sumologic_monitor.test 1234567890
141244
```
142245

143-
[1]: https://help.sumologic.com/Beta/Monitors
246+
[1]: https://help.sumologic.com/?cid=10020

0 commit comments

Comments
 (0)