cfn-guardian 0.1.0 → 0.3.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.dockerignore +1 -0
- data/Dockerfile +19 -0
- data/Gemfile.lock +31 -13
- data/README.md +441 -42
- data/cfn-guardian.gemspec +6 -2
- data/lib/cfnguardian.rb +301 -27
- data/lib/cfnguardian/cloudwatch.rb +121 -0
- data/lib/cfnguardian/codecommit.rb +54 -0
- data/lib/cfnguardian/codepipeline.rb +138 -0
- data/lib/cfnguardian/compile.rb +58 -17
- data/lib/cfnguardian/config/defaults.yaml +94 -0
- data/lib/cfnguardian/display_formatter.rb +164 -0
- data/lib/cfnguardian/drift.rb +79 -0
- data/lib/cfnguardian/log.rb +0 -1
- data/lib/cfnguardian/models/alarm.rb +98 -36
- data/lib/cfnguardian/models/check.rb +103 -26
- data/lib/cfnguardian/models/composite.rb +21 -0
- data/lib/cfnguardian/models/event.rb +164 -40
- data/lib/cfnguardian/models/metric_filter.rb +28 -0
- data/lib/cfnguardian/resources/application_targetgroup.rb +2 -0
- data/lib/cfnguardian/resources/base.rb +38 -16
- data/lib/cfnguardian/resources/ecs_service.rb +2 -2
- data/lib/cfnguardian/resources/http.rb +16 -1
- data/lib/cfnguardian/resources/internal_http.rb +74 -0
- data/lib/cfnguardian/resources/internal_port.rb +33 -0
- data/lib/cfnguardian/resources/internal_sftp.rb +58 -0
- data/lib/cfnguardian/resources/log_group.rb +26 -0
- data/lib/cfnguardian/resources/network_targetgroup.rb +1 -0
- data/lib/cfnguardian/resources/port.rb +25 -0
- data/lib/cfnguardian/resources/rds_instance.rb +2 -0
- data/lib/cfnguardian/resources/sftp.rb +50 -0
- data/lib/cfnguardian/resources/sql.rb +1 -1
- data/lib/cfnguardian/resources/tls.rb +66 -0
- data/lib/cfnguardian/s3.rb +3 -2
- data/lib/cfnguardian/stacks/main.rb +86 -65
- data/lib/cfnguardian/stacks/resources.rb +81 -42
- data/lib/cfnguardian/string.rb +12 -0
- data/lib/cfnguardian/version.rb +1 -1
- metadata +102 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7b64db0c4a4a45a9432c2cf750ac07b2600b54938e080fc24e3a50201144bfaa
|
4
|
+
data.tar.gz: 8e6561a49bd7be8d9185fd64f55e6d3d1842683e325c6c12b6c61ebad1058e43
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4585cdc22260486afe530c5abd07f490d4d71a1a63f435d64e1bdc964ebb175a852b9d45af9b6ada79ee025bde0c7df88c1352ef2fc5bb799f507553186b3377
|
7
|
+
data.tar.gz: eca47bd9aab11dc4888e29aa7a4992512344db581ad06455d4283ec7009d1998a46dcb122191b37d5e300c60a6ee28bf0979a0c6a6c2cfc8281fe785b34ebafe
|
data/.dockerignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
cfn-guardian-*.gem
|
data/Dockerfile
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
FROM ruby:2.7-alpine
|
2
|
+
|
3
|
+
ARG GUARDIAN_VERSION="0.2.2"
|
4
|
+
|
5
|
+
COPY . /src
|
6
|
+
|
7
|
+
WORKDIR /src
|
8
|
+
|
9
|
+
RUN apk add --no-cache git \
|
10
|
+
&& gem build cfn-guardian.gemspec \
|
11
|
+
&& gem install cfn-guardian-${GUARDIAN_VERSION}.gem \
|
12
|
+
&& rm -rf /src
|
13
|
+
|
14
|
+
RUN addgroup -g 1000 guardian && \
|
15
|
+
adduser -D -u 1000 -G guardian guardian
|
16
|
+
|
17
|
+
USER guardian
|
18
|
+
|
19
|
+
RUN cfndsl -u 11.5.0
|
data/Gemfile.lock
CHANGED
@@ -1,10 +1,14 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
cfn-guardian (0.1
|
5
|
-
aws-sdk-cloudformation (~> 1, < 2)
|
6
|
-
aws-sdk-
|
4
|
+
cfn-guardian (0.3.1)
|
5
|
+
aws-sdk-cloudformation (~> 1.31, < 2)
|
6
|
+
aws-sdk-cloudwatch (~> 1.28, < 2)
|
7
|
+
aws-sdk-codecommit (~> 1.28, < 2)
|
8
|
+
aws-sdk-codepipeline (~> 1.28, < 2)
|
9
|
+
aws-sdk-s3 (~> 1.60, < 2)
|
7
10
|
cfndsl (~> 1.0, < 2)
|
11
|
+
term-ansicolor (~> 1, < 2)
|
8
12
|
terminal-table (~> 1, < 2)
|
9
13
|
thor (~> 0.20)
|
10
14
|
|
@@ -12,33 +16,47 @@ GEM
|
|
12
16
|
remote: https://rubygems.org/
|
13
17
|
specs:
|
14
18
|
aws-eventstream (1.0.3)
|
15
|
-
aws-partitions (1.
|
16
|
-
aws-sdk-cloudformation (1.
|
19
|
+
aws-partitions (1.281.0)
|
20
|
+
aws-sdk-cloudformation (1.31.0)
|
17
21
|
aws-sdk-core (~> 3, >= 3.71.0)
|
18
22
|
aws-sigv4 (~> 1.1)
|
19
|
-
aws-sdk-
|
23
|
+
aws-sdk-cloudwatch (1.34.0)
|
24
|
+
aws-sdk-core (~> 3, >= 3.71.0)
|
25
|
+
aws-sigv4 (~> 1.1)
|
26
|
+
aws-sdk-codecommit (1.31.0)
|
27
|
+
aws-sdk-core (~> 3, >= 3.71.0)
|
28
|
+
aws-sigv4 (~> 1.1)
|
29
|
+
aws-sdk-codepipeline (1.28.0)
|
30
|
+
aws-sdk-core (~> 3, >= 3.71.0)
|
31
|
+
aws-sigv4 (~> 1.1)
|
32
|
+
aws-sdk-core (3.91.0)
|
20
33
|
aws-eventstream (~> 1.0, >= 1.0.2)
|
21
|
-
aws-partitions (~> 1, >= 1.
|
34
|
+
aws-partitions (~> 1, >= 1.239.0)
|
22
35
|
aws-sigv4 (~> 1.1)
|
23
36
|
jmespath (~> 1.0)
|
24
|
-
aws-sdk-kms (1.
|
37
|
+
aws-sdk-kms (1.30.0)
|
25
38
|
aws-sdk-core (~> 3, >= 3.71.0)
|
26
39
|
aws-sigv4 (~> 1.1)
|
27
|
-
aws-sdk-s3 (1.
|
28
|
-
aws-sdk-core (~> 3, >= 3.
|
40
|
+
aws-sdk-s3 (1.61.0)
|
41
|
+
aws-sdk-core (~> 3, >= 3.83.0)
|
29
42
|
aws-sdk-kms (~> 1)
|
30
43
|
aws-sigv4 (~> 1.1)
|
31
|
-
aws-sigv4 (1.1.
|
44
|
+
aws-sigv4 (1.1.1)
|
32
45
|
aws-eventstream (~> 1.0, >= 1.0.2)
|
33
|
-
cfndsl (1.0.
|
46
|
+
cfndsl (1.0.5)
|
34
47
|
hana (~> 1.3)
|
35
48
|
hana (1.3.5)
|
36
49
|
jmespath (1.4.0)
|
37
50
|
rake (10.5.0)
|
51
|
+
sync (0.5.0)
|
52
|
+
term-ansicolor (1.7.1)
|
53
|
+
tins (~> 1.0)
|
38
54
|
terminal-table (1.8.0)
|
39
55
|
unicode-display_width (~> 1.1, >= 1.1.1)
|
40
56
|
thor (0.20.3)
|
41
|
-
|
57
|
+
tins (1.24.1)
|
58
|
+
sync
|
59
|
+
unicode-display_width (1.7.0)
|
42
60
|
|
43
61
|
PLATFORMS
|
44
62
|
ruby
|
data/README.md
CHANGED
@@ -5,6 +5,7 @@ CfnGuardian is a AWS monitoring tool with a few capabilities:
|
|
5
5
|
- creates cloudwatch alarms through cloudformation based upon resources defined in a YAML config
|
6
6
|
- alerting through SNS using 4 levels of severity [ Critical, Warning, Task, Informational ]
|
7
7
|
- has a standard set of default alarms across many AWS resources
|
8
|
+
- creates cloudwatch log metric filters with default alarms
|
8
9
|
- creates custom metrics for external checks through lambda functions such as
|
9
10
|
- http endpoint availability
|
10
11
|
- http status code matching
|
@@ -13,6 +14,9 @@ CfnGuardian is a AWS monitoring tool with a few capabilities:
|
|
13
14
|
- ssl expiry
|
14
15
|
- sql query
|
15
16
|
- nrpe
|
17
|
+
- sftp availability
|
18
|
+
- sftp file download
|
19
|
+
- tls version checking
|
16
20
|
|
17
21
|
**Supported AWS Resources**
|
18
22
|
|
@@ -33,6 +37,7 @@ CfnGuardian is a AWS monitoring tool with a few capabilities:
|
|
33
37
|
- RDS Instances
|
34
38
|
- Redshift Cluster
|
35
39
|
- SQS Queues
|
40
|
+
- LogGroup Metric Filters
|
36
41
|
|
37
42
|
## Installation
|
38
43
|
|
@@ -44,6 +49,8 @@ gem install cfn-guardian
|
|
44
49
|
|
45
50
|
**compile**
|
46
51
|
|
52
|
+
Generates CloudFormation templates from the alarm configuration and output to the out/ directory.
|
53
|
+
|
47
54
|
```bash
|
48
55
|
Usage:
|
49
56
|
cfn-guardian compile c, --config=CONFIG
|
@@ -54,13 +61,13 @@ Options:
|
|
54
61
|
# Default: true
|
55
62
|
[--bucket=BUCKET] # provide custom bucket name, will create a default bucket if not provided
|
56
63
|
r, [--region=REGION] # set the AWS region
|
57
|
-
|
58
|
-
Description:
|
59
|
-
Generates CloudFormation templates from the alarm configuration and output to the out/ directory.
|
64
|
+
[--debug], [--no-debug] # enable debug logging
|
60
65
|
```
|
61
66
|
|
62
67
|
**deploy**
|
63
68
|
|
69
|
+
Generates CloudFormation templates from the alarm configuration and output to the out/ directory. Then copies the files to the s3 bucket and deploys the Cloudformation.
|
70
|
+
|
64
71
|
```bash
|
65
72
|
Usage:
|
66
73
|
cfn-guardian deploy c, --config=CONFIG
|
@@ -69,58 +76,95 @@ Options:
|
|
69
76
|
c, --config=CONFIG # yaml config file
|
70
77
|
[--bucket=BUCKET] # provide custom bucket name, will create a default bucket if not provided
|
71
78
|
r, [--region=REGION] # set the AWS region
|
72
|
-
|
79
|
+
s, [--stack-name=STACK_NAME] # set the Cloudformation stack name. Defaults to `guardian`
|
73
80
|
[--sns-critical=SNS_CRITICAL] # sns topic arn for the critical alamrs
|
74
81
|
[--sns-warning=SNS_WARNING] # sns topic arn for the warning alamrs
|
75
82
|
[--sns-task=SNS_TASK] # sns topic arn for the task alamrs
|
76
83
|
[--sns-informational=SNS_INFORMATIONAL] # sns topic arn for the informational alamrs
|
77
|
-
|
78
|
-
Description:
|
79
|
-
Generates CloudFormation templates from the alarm configuration and output to the out/ directory. Then copies the files to the s3 bucket and deploys the cloudformation.
|
84
|
+
[--debug], [--no-debug] # enable debug logging
|
80
85
|
```
|
81
86
|
|
82
87
|
**show-alarms**
|
83
88
|
|
89
|
+
Displays the configured settings for each alarm. Can be filtered by resource group and alarm name. Defaults to show all configured alarms.
|
90
|
+
|
84
91
|
```bash
|
85
92
|
Usage:
|
86
93
|
cfn-guardian show-alarms c, --config=CONFIG
|
87
94
|
|
88
95
|
Options:
|
89
|
-
c, --config=CONFIG
|
90
|
-
g, [--group=GROUP]
|
91
|
-
|
92
|
-
|
96
|
+
c, --config=CONFIG # yaml config file
|
97
|
+
g, [--group=GROUP] # resource group
|
98
|
+
a, [--alarm=ALARM] # alarm name
|
99
|
+
[--id=ID] # resource id
|
100
|
+
[--compare], [--no-compare] # compare config to deployed alarms
|
101
|
+
[--defaults], [--no-defaults] # show default alarm and properites
|
102
|
+
[--debug], [--no-debug] # enable debug logging
|
103
|
+
```
|
104
|
+
|
105
|
+
**show-history**
|
106
|
+
|
107
|
+
Displays the alarm state or config history for the last 7 days. Alarms can be described in 2 different ways:
|
108
|
+
|
109
|
+
1. Using the config to describe the alarms and filter via the group, alarm and resource id.
|
110
|
+
2. Supplying a list of alarm names with the `--alarm-names` option.
|
111
|
+
|
112
|
+
*NOTE: Options 2 may find alarms not in the guardian stack.*
|
93
113
|
|
94
|
-
|
95
|
-
|
114
|
+
```bash
|
115
|
+
Usage:
|
116
|
+
cfn-guardian show-history
|
117
|
+
|
118
|
+
Options:
|
119
|
+
c, [--config=CONFIG] # yaml config file
|
120
|
+
g, [--group=GROUP] # resource group
|
121
|
+
a, [--alarm=ALARM] # alarm name
|
122
|
+
[--alarm-names=one two three] # CloudWatch alarm name if not providing config
|
123
|
+
[--id=ID] # resource id
|
124
|
+
t, [--type=TYPE] # filter by alarm state
|
125
|
+
# Default: state
|
126
|
+
# Possible values: state, config
|
127
|
+
[--debug], [--no-debug] # enable debug logging
|
96
128
|
```
|
97
129
|
|
130
|
+
**show-state**
|
131
|
+
|
132
|
+
Displays the current CloudWatch alarm state. Alarms can be described in 3 different ways:
|
133
|
+
|
134
|
+
1. Using the config to describe the alarms and filter via the group, alarm and resource id.
|
135
|
+
2. Supplying a list of alarm names with the `--alarm-names` option.
|
136
|
+
3. Supplying the alarm name prefix using the `--alarm-prefix` option. For example `--alarm-prefix ECS` will find all the ECSCluster related alarms.
|
137
|
+
|
138
|
+
*NOTE: Options 2 and 3 may find alarms not in the guardian stack.*
|
139
|
+
|
98
140
|
```bash
|
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
|
-
|
141
|
+
Usage:
|
142
|
+
cfn-guardian show-state
|
143
|
+
|
144
|
+
Options:
|
145
|
+
c, [--config=CONFIG] # yaml config file
|
146
|
+
g, [--group=GROUP] # resource group
|
147
|
+
a, [--alarm=ALARM] # alarm name
|
148
|
+
[--id=ID] # resource id
|
149
|
+
s, [--state=STATE] # filter by alarm state
|
150
|
+
# Possible values: OK, ALARM, INSUFFICIENT_DATA
|
151
|
+
[--alarm-names=one two three] # CloudWatch alarm name if not providing config
|
152
|
+
[--alarm-prefix=ALARM_PREFIX] # CloudWatch alarm name prefix if not providing config
|
153
|
+
[--debug], [--no-debug] # enable debug logging
|
154
|
+
```
|
155
|
+
|
156
|
+
**show-drift**
|
157
|
+
|
158
|
+
Displays any Cloudformation drift detection in the CloudWatch alarms from the deployed stacks.
|
159
|
+
|
160
|
+
```bash
|
161
|
+
Usage:
|
162
|
+
cfn-guardian show-drift
|
163
|
+
|
164
|
+
Options:
|
165
|
+
s, [--stack-name=STACK_NAME] # set the Cloudformation stack name
|
166
|
+
# Default: guardian
|
167
|
+
[--debug], [--no-debug] # enable debug logging
|
124
168
|
```
|
125
169
|
|
126
170
|
## Configuration
|
@@ -170,11 +214,82 @@ Resources:
|
|
170
214
|
| CloudFrontDistribution | Id |
|
171
215
|
| SQSQueue | Id |
|
172
216
|
|
217
|
+
### Alarm Defaults
|
218
|
+
|
219
|
+
To list the default alarms use the `show-alarms` command with the `--defaults` switch.
|
220
|
+
The list can be filtered using the `--group ApplicationTargetGroup` and `--alarm TargetResponseTime` optional switches
|
221
|
+
|
222
|
+
```sh
|
223
|
+
cfn-guardian show-alarms --defaults --group ApplicationTargetGroup --alarm TargetResponseTime
|
224
|
+
|
225
|
+
+-------------------------+----------------------------------+
|
226
|
+
| ApplicationTargetGroup::TargetResponseTime |
|
227
|
+
| guardian-ApplicationTargetGroup-Default-TargetResponseTime |
|
228
|
+
+-------------------------+----------------------------------+
|
229
|
+
| Property | Config |
|
230
|
+
+-------------------------+----------------------------------+
|
231
|
+
| ResourceId | Default |
|
232
|
+
| ResourceHash | 7a1920d61156abc05a60135aefe8bc67 |
|
233
|
+
| Enabled | true |
|
234
|
+
| MetricName | TargetResponseTime |
|
235
|
+
| Dimensions | |
|
236
|
+
| Threshold | 5 |
|
237
|
+
| Period | 60 |
|
238
|
+
| EvaluationPeriods | 5 |
|
239
|
+
| ComparisonOperator | GreaterThanThreshold |
|
240
|
+
| Statistic | Maximum |
|
241
|
+
| ActionsEnabled | true |
|
242
|
+
| AlarmAction | Critical |
|
243
|
+
| TreatMissingData | notBreaching |
|
244
|
+
+-------------------------+----------------------------------+
|
245
|
+
```
|
246
|
+
|
247
|
+
### Friendly Resource Names
|
248
|
+
|
249
|
+
You can set a friendly name which will replace the resource id in the alarm name.
|
250
|
+
The resource id will still be available in the alarm description.
|
251
|
+
|
252
|
+
```yaml
|
253
|
+
Resources:
|
254
|
+
ApplicationTargetGroup:
|
255
|
+
- Id: target-group-id
|
256
|
+
Loadbalancer: app/application-loadbalancer-id
|
257
|
+
Name: webapp
|
258
|
+
```
|
259
|
+
|
260
|
+
### Log Group Metric Filters
|
261
|
+
|
262
|
+
Metric filters creates the metric filter and a corresponding alarm.
|
263
|
+
Cloudwatch NameSpace: `MetricFilters`
|
264
|
+
|
265
|
+
AWS [documentation](https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/FilterAndPatternSyntax.html) of pattern syntax
|
266
|
+
|
267
|
+
```yaml
|
268
|
+
Resources:
|
269
|
+
LogGroup:
|
270
|
+
# Log group name
|
271
|
+
- Id: /aws/lambda/myfuntion
|
272
|
+
# List of metric filters
|
273
|
+
MetricFilters:
|
274
|
+
# Name of the cloud watch metric
|
275
|
+
- MetricName: MyFunctionErrors
|
276
|
+
# search pattern, see aws docs for syntax
|
277
|
+
Pattern: error
|
278
|
+
# metric to push to cloudwatch. Optional as it defaults to 1
|
279
|
+
MetricValue: 1
|
280
|
+
|
281
|
+
Templates:
|
282
|
+
LogGroup:
|
283
|
+
# use the MetricName name to override the alarm defaults
|
284
|
+
MyFunctionErrors:
|
285
|
+
Threshold: 10
|
286
|
+
```
|
287
|
+
|
173
288
|
### Custom Metric Resources
|
174
289
|
|
175
290
|
These are also defined under the resources key but more detail is required and differs per group.
|
176
291
|
|
177
|
-
|
292
|
+
#### Http
|
178
293
|
|
179
294
|
Cloudwatch NameSpace: `HttpCheck`
|
180
295
|
|
@@ -187,6 +302,8 @@ Resources:
|
|
187
302
|
StatusCode: 200
|
188
303
|
# enables the SSL check
|
189
304
|
Ssl: true
|
305
|
+
# boolean tp request a compressed response
|
306
|
+
Compressed: true
|
190
307
|
- Id: https://www.example.com
|
191
308
|
StatusCode: 301
|
192
309
|
- Id: https://example.com
|
@@ -194,9 +311,80 @@ Resources:
|
|
194
311
|
Ssl: true
|
195
312
|
# enables the body regex check
|
196
313
|
BodyRegex: 'helloworld'
|
314
|
+
- Id: http://www.example.com/images/cat.jpg
|
315
|
+
StatusCode: 200
|
316
|
+
# md5 hash of the image
|
317
|
+
BodyRegex: ae49b4246a89efcb5c639f00a013e812
|
318
|
+
- Id: https://api.example.com/user
|
319
|
+
StatusCode: 201
|
320
|
+
# default method is get but can be overridden to support post/put/head etc
|
321
|
+
Method: post
|
322
|
+
# specify headers using "key=value key=value"
|
323
|
+
Headers: content-type=application/json
|
324
|
+
# pass in custom payload for the request
|
325
|
+
Payload: '{"name": "john"}'
|
197
326
|
```
|
198
327
|
|
199
|
-
|
328
|
+
#### InternalHttp
|
329
|
+
|
330
|
+
Cloudwatch NameSpace: `InternalHttpCheck`
|
331
|
+
|
332
|
+
```yaml
|
333
|
+
Resources:
|
334
|
+
InternalHttp:
|
335
|
+
# Array of host groups with the uniq identifier of Environment.
|
336
|
+
# This will create a nrpe lambda per group attach to the defined vpc and subnets
|
337
|
+
- Environment: Prod
|
338
|
+
# VPC id for the vpc the EC2 hosts are running in
|
339
|
+
VpcId: vpc-1234
|
340
|
+
# Array of subnets to attach to the lambda function. Supply multiple if you want to be multi AZ.
|
341
|
+
# Multiple subnets from the same AZ cannot be used!
|
342
|
+
Subnets:
|
343
|
+
- subnet-abcd
|
344
|
+
Hosts:
|
345
|
+
# Array of resources defining the http endpoint with the Id: key
|
346
|
+
# All the same options as Http including ssl check on the internal endpoint
|
347
|
+
- Id: http://api.example.com
|
348
|
+
```
|
349
|
+
|
350
|
+
#### Port
|
351
|
+
|
352
|
+
Cloudwatch NameSpace: `PortCheck`
|
353
|
+
|
354
|
+
```yaml
|
355
|
+
Resources:
|
356
|
+
Port:
|
357
|
+
# Array of resources defining the endpoint with the Id: key and Port: Int
|
358
|
+
- Id: api.example.com
|
359
|
+
Port: 443
|
360
|
+
# can override the default timeout of 120 seconds
|
361
|
+
Timeout: 60
|
362
|
+
```
|
363
|
+
|
364
|
+
#### InternalPort
|
365
|
+
|
366
|
+
Cloudwatch NameSpace: `InternalPortCheck`
|
367
|
+
|
368
|
+
```yaml
|
369
|
+
Resources:
|
370
|
+
InternalPort:
|
371
|
+
# Array of host groups with the uniq identifier of Environment.
|
372
|
+
# This will create a nrpe lambda per group attach to the defined vpc and subnets
|
373
|
+
- Environment: Prod
|
374
|
+
# VPC id for the vpc the EC2 hosts are running in
|
375
|
+
VpcId: vpc-1234
|
376
|
+
# Array of subnets to attach to the lambda function. Supply multiple if you want to be multi AZ.
|
377
|
+
# Multiple subnets from the same AZ cannot be used!
|
378
|
+
Subnets:
|
379
|
+
- subnet-abcd
|
380
|
+
Hosts:
|
381
|
+
# Array of resources defining the endpoint with the Id: key and Port: Int
|
382
|
+
# All the same options as Port
|
383
|
+
- Id: api.example.com
|
384
|
+
Port: 8080
|
385
|
+
```
|
386
|
+
|
387
|
+
#### DomainExpiry
|
200
388
|
|
201
389
|
Cloudwatch NameSpace: `DNS`
|
202
390
|
|
@@ -207,7 +395,7 @@ Resources:
|
|
207
395
|
- Id: example.com
|
208
396
|
```
|
209
397
|
|
210
|
-
|
398
|
+
#### Nrpe
|
211
399
|
|
212
400
|
Cloudwatch NameSpace: `NRPE`
|
213
401
|
|
@@ -237,7 +425,7 @@ Resources:
|
|
237
425
|
- check_disk
|
238
426
|
```
|
239
427
|
|
240
|
-
|
428
|
+
#### Sql
|
241
429
|
|
242
430
|
Cloudwatch NameSpace: `SQL`
|
243
431
|
|
@@ -282,6 +470,90 @@ aws secretsmanager create-secret --name MyTestDatabaseSecret \
|
|
282
470
|
--secret-string '{"connectionString":"sql://username:password@mydb:3306/information_schema"}'
|
283
471
|
```
|
284
472
|
|
473
|
+
#### SFTP
|
474
|
+
|
475
|
+
CloudWatch Namespace: `SftpCheck`
|
476
|
+
|
477
|
+
```yaml
|
478
|
+
Resources:
|
479
|
+
SFTP:
|
480
|
+
# sftp endpoint, can accept both ip address or dns endpoint
|
481
|
+
- Id: example.com
|
482
|
+
# sftp user to test connection with
|
483
|
+
User: user
|
484
|
+
# optionally set port, defaults to port 22
|
485
|
+
Port: 22
|
486
|
+
# for added security you can use allowed hosts when creating a
|
487
|
+
# connection to the sftp by supplying the public key of the sftp server.
|
488
|
+
# this removes the security risk for man in the middle attacks.
|
489
|
+
ServerKey: public-server-key
|
490
|
+
# ssm parameter path for the password for the SFTP user.
|
491
|
+
Password: /ssm/path/password
|
492
|
+
# ssm parameter path for the private key for the SFTP user
|
493
|
+
PrivateKey: /ssm/path/privatekey
|
494
|
+
# ssm parameter path for the password for the private key
|
495
|
+
PrivateKeyPass: /ssm/path/privatekey/password
|
496
|
+
# optionally set a file to check its existence and test the time it takes to get the file
|
497
|
+
File: file.txt
|
498
|
+
# optionally check for a regex match pattern in the body of the file
|
499
|
+
FileRegexMatch: ok
|
500
|
+
```
|
501
|
+
|
502
|
+
#### InternalSFTP
|
503
|
+
|
504
|
+
CloudWatch Namespace: `InternalSftpCheck`
|
505
|
+
|
506
|
+
```yaml
|
507
|
+
Resources:
|
508
|
+
InternalSFTP:
|
509
|
+
# Array of host groups with the uniq identifier of Environment.
|
510
|
+
# This will create a sql lambda per group attach to the defined vpc and subnets
|
511
|
+
- Environment: Prod
|
512
|
+
# VPC id for the vpc the EC2 hosts are running in
|
513
|
+
VpcId: vpc-1234
|
514
|
+
# Array of subnets to attach to the lambda function. Supply multiple if you want to be multi AZ.
|
515
|
+
# Multiple subnets from the same AZ cannot be used!
|
516
|
+
Subnets:
|
517
|
+
- subnet-1234
|
518
|
+
Hosts:
|
519
|
+
# Array of sftp hosts with the Id: key defining the host private ip address
|
520
|
+
- Id: example.com
|
521
|
+
User: user
|
522
|
+
Port: 22
|
523
|
+
ServerKey: public-server-key
|
524
|
+
Password: /ssm/path/password
|
525
|
+
PrivateKey: /ssm/path/privatekey
|
526
|
+
PrivateKeyPass: /ssm/path/privatekey/password
|
527
|
+
File: file.txt
|
528
|
+
FileRegexMatch: ok
|
529
|
+
```
|
530
|
+
|
531
|
+
#### TLS
|
532
|
+
|
533
|
+
CloudWatch Namespace: `TLSVersionCheck`
|
534
|
+
|
535
|
+
```yaml
|
536
|
+
Resources:
|
537
|
+
TLS:
|
538
|
+
# endpoint
|
539
|
+
- Id: example.com
|
540
|
+
# port to check, defaults to 443
|
541
|
+
Port: 443
|
542
|
+
# list of tls versions to validate against
|
543
|
+
# there is a metric for each version with a 0 being no supported and 1 for supported
|
544
|
+
# alarm thresholds will have to be adjusted to suit your checking requirements
|
545
|
+
# defaults to all versions shown below
|
546
|
+
Versions:
|
547
|
+
- SSLv2
|
548
|
+
- SSLv3
|
549
|
+
- TLSv1
|
550
|
+
- TLSv1.1
|
551
|
+
- TLSv1.2
|
552
|
+
# checks and reports the max tls version supported as an int
|
553
|
+
# ['SSLv2 => 1', 'SSLv3 => 2', 'TLSv1 => 3','TLSv1.1 => 4', 'TLSv1.2 => 5']
|
554
|
+
MaxSupported: '1'
|
555
|
+
```
|
556
|
+
|
285
557
|
## Alarm Templates
|
286
558
|
|
287
559
|
Each resource group has a set of default alarm templates which defines all the cloudwatch alarm options such as Threshold, Statistic, EvaluationPeriods etc. These can be manipulated in a few ways to change the values or create new alarms.
|
@@ -399,6 +671,133 @@ Topics:
|
|
399
671
|
Informational: arn:aws:sns:ap-southeast-2:111111111111:Guardian-Informational
|
400
672
|
```
|
401
673
|
|
674
|
+
## M Out Of N Metric Data Points
|
675
|
+
|
676
|
+
This can be good to alert on groups of spikes with in a certain time frame without getting alerts for individual spikes.
|
677
|
+
It works by setting the `EvaluationPeriods` as N value and `DatapointsToAlarm` as the M value.
|
678
|
+
The following example will trigger the alarm if 6 out of 10 data points crossed the threshold of 90% CPU utilisation in a 10 minute period.
|
679
|
+
|
680
|
+
```yaml
|
681
|
+
Templates:
|
682
|
+
Ec2Instance:
|
683
|
+
CPUUtilizationHigh:
|
684
|
+
Threshold: 90
|
685
|
+
Period: 60
|
686
|
+
EvaluationPeriods: 10
|
687
|
+
DatapointsToAlarm: 6
|
688
|
+
```
|
689
|
+
|
690
|
+
## Composite Alarms
|
691
|
+
|
692
|
+
Composite alarms take into account a combination of alarm states and only alarm when all conditions in the rule are met. See AWS (documentation)[https://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/API_PutCompositeAlarm.html] for rule syntax.
|
693
|
+
|
694
|
+
Using the `Composites:` top level key, create the alarm using the following syntax.
|
695
|
+
|
696
|
+
**NOTE:** Each composite alarm cost $0.50/month
|
697
|
+
|
698
|
+
```yaml
|
699
|
+
Composites:
|
700
|
+
|
701
|
+
# the key is used as the alarm name
|
702
|
+
AlarmName:
|
703
|
+
# Set the notification SNS topic, defaults to no notifications
|
704
|
+
Action: Informational
|
705
|
+
# Set a meaningful alarm description
|
706
|
+
Description: test
|
707
|
+
# Set the alarm rule by providing the alarm names. See above for rule syntax.
|
708
|
+
# Use the show-state command to get a list of the alarm names.
|
709
|
+
Rule: >-
|
710
|
+
ALARM(guardian-alarm-1)
|
711
|
+
AND
|
712
|
+
ALARM(guardian-alarm-2)
|
713
|
+
```
|
714
|
+
|
715
|
+
## Maintenance Mode
|
716
|
+
|
717
|
+
CloudWatch alarms can be enabled and disabled to allow maintenance periods without getting alert notifications.
|
718
|
+
Alarms can be provided to the function the following ways
|
719
|
+
|
720
|
+
**Alarm Names**
|
721
|
+
|
722
|
+
Alarm names be provided by a space delimited list using the `--alarms` switch.
|
723
|
+
|
724
|
+
```bash
|
725
|
+
cfn-guardian disable-alarms --group alarm-1 alarm-2
|
726
|
+
cfn-guardian enable-alarms --group alarm-1 alarm-2
|
727
|
+
```
|
728
|
+
|
729
|
+
**Alarm Name Prefix**
|
730
|
+
|
731
|
+
Alarm name prefix will find the alarms in the account and region that start with the provided string.
|
732
|
+
This can be useful if required to disable all guardian alarms, disable all alarm for a resource group or for a specific resource.
|
733
|
+
Alarm names are created using the following convention.
|
734
|
+
|
735
|
+
`guardian` - `ResourceGroupName` - `ResourceId` or `FriendlyName` - `AlarmName`
|
736
|
+
|
737
|
+
The following example would disable/enable all alarms for all ECS Services
|
738
|
+
|
739
|
+
```bash
|
740
|
+
cfn-guardian disable-alarms --alarm-prefix guardian-ECSService
|
741
|
+
cfn-guardian enable-alarms --alarm-prefix guardian-ECSService
|
742
|
+
```
|
743
|
+
|
744
|
+
The following example would disable/enable all alarms for the ECS Service app
|
745
|
+
|
746
|
+
```bash
|
747
|
+
cfn-guardian disable-alarms --alarm-prefix guardian-ECSService-app
|
748
|
+
cfn-guardian enable-alarms --alarm-prefix guardian-ECSService-app
|
749
|
+
```
|
750
|
+
|
751
|
+
**Maintenance Groups**
|
752
|
+
|
753
|
+
Maintenance groups are defined in the `alarms.yaml` config and creates a logical mapping between alarms.
|
754
|
+
|
755
|
+
```yaml
|
756
|
+
Resources:
|
757
|
+
|
758
|
+
ApplicationTargetGroup:
|
759
|
+
- Id: app-tg
|
760
|
+
LoadBalancer: public-lb
|
761
|
+
|
762
|
+
AutoScalingGroup:
|
763
|
+
- Id: ecs-asg
|
764
|
+
|
765
|
+
ECSCluster:
|
766
|
+
- Id: prod
|
767
|
+
|
768
|
+
ECSService:
|
769
|
+
- Id: app
|
770
|
+
Cluster: prod
|
771
|
+
|
772
|
+
Http:
|
773
|
+
- Id: https://myapp.com
|
774
|
+
StatusCode: 200
|
775
|
+
|
776
|
+
# Define the top level key
|
777
|
+
MaintenaceGroups:
|
778
|
+
|
779
|
+
# Define the group name
|
780
|
+
AppUpdate:
|
781
|
+
# Define the resource group
|
782
|
+
ECSService:
|
783
|
+
# define the alarms in the resource group
|
784
|
+
UnhealthyTaskCritical:
|
785
|
+
# define the resource id's
|
786
|
+
- Id: app
|
787
|
+
# or the friendly name
|
788
|
+
- Name: app
|
789
|
+
Http:
|
790
|
+
EndpointAvailable:
|
791
|
+
- Id: https://myapp.com
|
792
|
+
EndpointStatusCodeMatch:
|
793
|
+
- Id: https://myapp.com
|
794
|
+
```
|
795
|
+
|
796
|
+
```bash
|
797
|
+
cfn-guardian disable-alarms --group AppUpdate
|
798
|
+
cfn-guardian enable-alarms --group AppUpdate
|
799
|
+
```
|
800
|
+
|
402
801
|
## Severities
|
403
802
|
|
404
803
|
Severties are defined in each alarm sing the `AlarmAction` key. There are 4 options `[ Critical, Warning, Task, Informational ]`
|