-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathapp.tf
More file actions
231 lines (227 loc) · 11.2 KB
/
Copy pathapp.tf
File metadata and controls
231 lines (227 loc) · 11.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
module "classic_elb_module" {
source = "git::https://github.com/SumoLogic/terraform-sumologic-sumo-logic-integrations.git//sumologic?ref=fy27q2"
# source = "SumoLogic/sumo-logic-integrations/sumologic//sumologic"
# version = "1.0.23"
access_id = var.access_id
access_key = var.access_key
environment = var.environment
# ********************** Required Fields and FERs are created at aws-observability-terraform/field.tf ********************** #
# ********************** Apps ********************** #
managed_apps = {
"ClassicLBApp" = {
content_json = join("", [var.json_file_directory_path, "/aws-observability/json/Classic-lb-App.json"])
folder_id = var.app_folder_id
}
}
# ********************** Monitors ********************** #
managed_monitors = {
"AWSClassicLoadBalancerAccessfromHighlyMaliciousSources" = {
monitor_name = "AWS Classic Load Balancer - Access from Highly Malicious Sources"
monitor_description = "This alert fires when the Classic load balancer is accessed from highly malicious IP addresses within last 5 minutes."
monitor_monitor_type = "Logs"
monitor_parent_id = var.monitor_folder_id
monitor_is_disabled = var.monitors_disabled
monitor_evaluation_delay = "0m"
queries = {
A = "account=* region=* namespace=aws/elb\n| parse \"* * * * * * * * * * * \\\"*\\\" \\\"*\\\" * *\" as datetime, loadbalancername, client, backend, request_processing_time, backend_processing_time, response_processing_time, elb_status_code, backend_status_code, received_bytes, sent_bytes, request, user_agent, ssl_cipher, ssl_protocol\n| parse regex \"(?<ClientIp>\\b\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3})\" multi\n| where ClientIp != \"0.0.0.0\" and ClientIp != \"127.0.0.1\"\n| count as ip_count by ClientIp, loadbalancername, account, region, namespace\n| lookup type, actor, raw, threatlevel as MaliciousConfidence from sumo://threat/cs on threat=ClientIp \n| json field=raw \"labels[*].name\" as LabelName nodrop\n| replace(LabelName, \"\\\\/\",\"->\") as LabelName\n| replace(LabelName, \"\\\"\",\" \") as LabelName\n| where MaliciousConfidence=\"high\"\n| if (isEmpty(actor), \"Unassigned\", actor) as Actor\n| sum (ip_count) as ThreatCount by ClientIp, loadbalancername, account, region, namespace, MaliciousConfidence, Actor, LabelName"
}
triggers = [
{
detection_method = "StaticCondition",
time_range = "-5m",
trigger_type = "Critical",
threshold = 0,
threshold_type = "GreaterThan",
occurrence_type = "ResultCount",
trigger_source = "AllResults"
},
{
detection_method = "StaticCondition",
time_range = "-5m",
trigger_type = "ResolvedCritical",
threshold = 0,
threshold_type = "LessThanOrEqual",
occurrence_type = "ResultCount",
trigger_source = "AllResults"
}
]
group_notifications = var.group_notifications
connection_notifications = var.connection_notifications
email_notifications = var.email_notifications
},
"AWSClassicLoadBalancerHigh4XXErrors" = {
monitor_name = "AWS Classic Load Balancer - High 4XX Errors"
monitor_description = "This alert fires where there are too many HTTP requests (>5%) with a response status of 4xx within an interval of 5 minutes."
monitor_monitor_type = "Metrics"
monitor_parent_id = var.monitor_folder_id
monitor_is_disabled = var.monitors_disabled
monitor_evaluation_delay = "4m"
queries = {
A = "Namespace=aws/elb metric=HTTPCode_ELB_4XX Statistic=Sum account=* region=* loadbalancername=* | sum by loadbalancername, account, region, namespace"
B = "Namespace=aws/elb metric=RequestCount Statistic=Sum account=* region=* loadbalancername=* | sum by loadbalancername, account, region, namespace"
C = "#A * 100 / #B along loadbalancername, account, region, namespace"
}
triggers = [
{
detection_method = "StaticCondition",
time_range = "-5m",
trigger_type = "Critical",
threshold = 5,
threshold_type = "GreaterThanOrEqual",
occurrence_type = "Always",
trigger_source = "AnyTimeSeries"
},
{
detection_method = "StaticCondition",
time_range = "-5m",
trigger_type = "ResolvedCritical",
threshold = 5,
threshold_type = "LessThan",
occurrence_type = "Always",
trigger_source = "AnyTimeSeries"
}
]
group_notifications = var.group_notifications
connection_notifications = var.connection_notifications
email_notifications = var.email_notifications
},
"AWSClassicLoadBalancerHighLatency" = {
monitor_name = "AWS Classic Load Balancer - High Latency"
monitor_description = "This alert fires when we detect that the average latency for a given Classic load balancer within a time interval of 5 minutes is greater than or equal to three seconds."
monitor_monitor_type = "Metrics"
monitor_parent_id = var.monitor_folder_id
monitor_is_disabled = var.monitors_disabled
monitor_evaluation_delay = "4m"
queries = {
A = "Namespace=aws/elb metric=Latency Statistic=Average account=* region=* loadbalancername=* | eval(_value*1000) | sum by account, region, namespace, loadbalancername"
}
triggers = [
{
detection_method = "StaticCondition",
time_range = "-5m",
trigger_type = "Critical",
threshold = 3000,
threshold_type = "GreaterThanOrEqual",
occurrence_type = "Always",
trigger_source = "AnyTimeSeries"
},
{
detection_method = "StaticCondition",
time_range = "-5m",
trigger_type = "ResolvedCritical",
threshold = 3000,
threshold_type = "LessThan",
occurrence_type = "Always",
trigger_source = "AnyTimeSeries"
}
],
group_notifications = var.group_notifications
connection_notifications = var.connection_notifications
email_notifications = var.email_notifications
},
"AWSClassicLoadBalancerDeletionAlert" = {
monitor_name = "AWS Classic Load Balancer - Deletion Alert"
monitor_description = "This alert fires when we detect greater than or equal to 2 classic load balancers are deleted over a 5 minute time-period."
monitor_monitor_type = "Logs"
monitor_parent_id = var.monitor_folder_id
monitor_is_disabled = var.monitors_disabled
monitor_evaluation_delay = "0m"
queries = {
A = "account=* region=* namespace=aws/elb \"\"eventsource\":\"elasticloadbalancing.amazonaws.com\"\" \"\"apiVersion\":\"2012-06-01\"\" | json \"eventSource\", \"eventName\" as event_source, event_name nodrop | where event_source = \"elasticloadbalancing.amazonaws.com\" | where event_name matches \"DeleteLoadBalancer\""
}
triggers = [
{
detection_method = "StaticCondition",
time_range = "-5m",
trigger_type = "Critical",
threshold = 2,
threshold_type = "GreaterThanOrEqual",
occurrence_type = "ResultCount",
trigger_source = "AllResults"
},
{
detection_method = "StaticCondition",
time_range = "-5m",
trigger_type = "ResolvedCritical",
threshold = 2,
threshold_type = "LessThan",
occurrence_type = "ResultCount",
trigger_source = "AllResults"
}
],
group_notifications = var.group_notifications
connection_notifications = var.connection_notifications
email_notifications = var.email_notifications
},
"AWSClassicLoadBalancerTargetsDeregistered" = {
monitor_name = "AWS Classic Load Balancer - Targets Deregistered"
monitor_description = "This alert fires when we detect greater than or equal to 1 target is de-registered over a 5 minute time-period."
monitor_monitor_type = "Logs"
monitor_parent_id = var.monitor_folder_id
monitor_is_disabled = var.monitors_disabled
monitor_evaluation_delay = "0m"
queries = {
A = "account=* region=* namespace=aws/elb \"\"eventsource\":\"elasticloadbalancing.amazonaws.com\"\" \"\"apiVersion\":\"2012-06-01\"\" \n| json \"eventSource\", \"eventName\" as event_source, event_name nodrop \n| where event_source = \"elasticloadbalancing.amazonaws.com\" \n| where event_name matches \"DeregisterInstancesFromLoadBalancer\""
}
triggers = [
{
detection_method = "StaticCondition",
time_range = "-5m",
trigger_type = "Critical",
threshold = 1,
threshold_type = "GreaterThanOrEqual",
occurrence_type = "ResultCount",
trigger_source = "AllResults"
},
{
detection_method = "StaticCondition",
time_range = "-5m",
trigger_type = "ResolvedCritical",
threshold = 1,
threshold_type = "LessThan",
occurrence_type = "ResultCount",
trigger_source = "AllResults"
}
],
group_notifications = var.group_notifications
connection_notifications = var.connection_notifications
email_notifications = var.email_notifications
},
"AWSClassicLoadBalancerHigh5XXErrors" = {
monitor_name = "AWS Classic Load Balancer - High 5XX Errors"
monitor_description = "This alert fires where there are too many HTTP requests (>5%) with a response status of 5xx within an interval of 5 minutes."
monitor_monitor_type = "Metrics"
monitor_parent_id = var.monitor_folder_id
monitor_is_disabled = var.monitors_disabled
monitor_evaluation_delay = "4m"
queries = {
A = "Namespace=aws/elb metric=HTTPCode_ELB_5XX Statistic=Sum account=* region=* loadbalancername=* | sum by loadbalancername, account, region, namespace"
B = "Namespace=aws/elb metric=RequestCount Statistic=Sum account=* region=* loadbalancername=* | sum by loadbalancername, account, region, namespace"
C = "#A * 100 / #B along loadbalancername, account, region, namespace"
}
triggers = [
{
detection_method = "StaticCondition",
time_range = "-5m",
trigger_type = "Critical",
threshold = 5,
threshold_type = "GreaterThanOrEqual",
occurrence_type = "Always",
trigger_source = "AnyTimeSeries"
},
{
detection_method = "StaticCondition",
time_range = "-5m",
trigger_type = "ResolvedCritical",
threshold = 5,
threshold_type = "LessThan",
occurrence_type = "Always",
trigger_source = "AnyTimeSeries"
}
],
group_notifications = var.group_notifications
connection_notifications = var.connection_notifications
email_notifications = var.email_notifications
}
}
}