-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.tf
171 lines (146 loc) · 4.32 KB
/
main.tf
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
terraform {
required_providers {
datadog = {
source = "Datadog/datadog"
}
aws = {
source = "hashicorp/aws"
}
}
backend "s3" {
bucket = "aisoftware-ops"
key = "terraform/datadog-tfstate"
region = "us-east-1"
encrypt = true
}
}
provider "aws" {
region = var.region
}
provider "datadog" {
api_key = var.api_key
app_key = var.app_key
}
#-----BASE MONITORS-----#
#1. MONITOR: no_audit_logs
resource "datadog_monitor" "no_audit_logs" {
name = "No Recent Audit Logs"
type = "query alert"
query = "max(last_15m):abs(sum:most_recent_audit_log_id{*}.as_rate() - day_before(sum:most_recent_audit_log_id{*}.as_rate())) <= 0"
message = <<-EOM
{{#is_alert}}
${var.alert_recipients_testing}
{{/is_alert}}
no audit logs detected in `equity_jane.audit_log` in the last 15 minutes. check status of `audit-daemon` in production!
{{#is_recovery}}
${var.alert_recipients_testing}
{{/is_recovery}}
EOM
monitor_thresholds {
critical = 0
}
notify_audit = true
require_full_window = false
renotify_interval = 0
include_tags = true
priority = 3
tags = [
"alert:${var.alert_recipients_testing}",
"base",
"managed_by:terraform"
]
}
#2. MONITOR: clockskew_sync
#resource "datadog_monitor" "clockskew_sync" {
# name = "[Auto] Clock in sync with NTP"
# type = "service check"
# query = "\"ntp.in_sync\".over(\"*\").last(2).count_by_status()"
# message = <<-EOM
# {{#is_alert}}
# ${var.alert_recipients_testing}
# {{/is_alert}}
#
# Triggers if any host's clock goes out of sync with the time given by NTP. The offset threshold is configured in the Agent's `ntp.yaml` file.
#
# Please read the [KB article](https://docs.datadoghq.com/agent/faq/network-time-protocol-ntp-offset-issues) on NTP Offset issues for more details on cause and resolution.
# {{#is_recovery}}
# ${var.alert_recipients_testing}
# {{/is_recovery}}
# EOM
#
# monitor_thresholds {
# warning = 1
# ok = 1
# critical = 1
# }
#
# notify_audit = true
# require_full_window = false
# renotify_interval = 0
# include_tags = true
# priority = 3
#
# tags = [
# "alert:${var.alert_recipients_testing}",
# "base",
# "managed_by:terraform"
# ]
#}
#2. MONITOR: instance_down
resource "datadog_monitor" "instance_down" {
name = "Instance Down for 3 Minutes"
type = "query alert"
query = "min(last_3m):max:aws.ec2.status_check_failed_instance{cluster_name:production} by {instance-type} > 0"
message = <<-EOM
{{#is_alert}}
{{#is_exact_match "kube_cluster_name.name" "production"}}${var.alert_recipients_testing}{{/is_exact_match}}
{{#is_exact_match "kube_cluster_name.name" "staging"}}${var.alert_recipients_testing}{{/is_exact_match}}
{{/is_alert}}
Recent runs of EndToEnd SLA Tests have failed in the last 3 mins
{{#is_recovery}}
{{#is_exact_match "kube_cluster_name.name" "production"}}${var.alert_recipients_testing}{{/is_exact_match}}
{{#is_exact_match "kube_cluster_name.name" "staging"}}${var.alert_recipients_testing}{{/is_exact_match}}
{{/is_recovery}}
EOM
monitor_thresholds {
critical = 0
}
notify_audit = true
require_full_window = false
renotify_interval = 0
include_tags = true
priority = 3
evaluation_delay = 900
tags = [
"alert:${var.alert_recipients_testing}",
"base",
"managed_by:terraform"
]
}
resource "datadog_monitor" "vpn_site_to_site" {
name = "VPN: Site to site down"
type = "query alert"
query = "avg(last_5m):avg:aws.vpn.tunnel_state{vpnid:vpn-026358002d035d56e} <= 0"
message = <<-EOM
{{#is_alert}}
${var.alert_recipients_testing}
{{/is_alert}}
Site to Site VPN is down! Check office Meraki device and AWS VPC Site-to-Site settings
{{#is_recovery}}
${var.alert_recipients_testing}
{{/is_recovery}}
EOM
monitor_thresholds {
critical = 0
}
notify_audit = true
require_full_window = false
renotify_interval = 0
include_tags = true
priority = 3
tags = [
"alert:${var.alert_recipients_testing}",
"base",
"managed_by:terraform"
]
}