cfn-guardian 0.1.0 → 0.6.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/.github/workflows/build-gem.yml +25 -0
- data/.github/workflows/release-gem.yml +25 -0
- data/.github/workflows/release-image.yml +33 -0
- data/.rspec +1 -0
- data/Dockerfile +19 -0
- data/Gemfile.lock +39 -21
- data/README.md +9 -378
- data/cfn-guardian.gemspec +7 -5
- data/docs/alarm_templates.md +130 -0
- data/docs/cli.md +182 -0
- data/docs/composite_alarms.md +24 -0
- data/docs/custom_checks/azure_file_check.md +28 -0
- data/docs/custom_checks/domain_expiry.md +10 -0
- data/docs/custom_checks/http.md +59 -0
- data/docs/custom_checks/log_group_metric_filters.md +27 -0
- data/docs/custom_checks/nrpe.md +29 -0
- data/docs/custom_checks/port.md +40 -0
- data/docs/custom_checks/sftp.md +73 -0
- data/docs/custom_checks/sql.md +44 -0
- data/docs/custom_checks/tls.md +25 -0
- data/docs/custom_metrics.md +71 -0
- data/docs/event_subscriptions.md +67 -0
- data/docs/maintenance_mode.md +85 -0
- data/docs/notifiers.md +33 -0
- data/docs/overview.md +22 -0
- data/docs/resources.md +93 -0
- data/docs/variables.md +58 -0
- data/lib/cfnguardian.rb +325 -37
- data/lib/cfnguardian/cloudwatch.rb +132 -0
- data/lib/cfnguardian/codecommit.rb +54 -0
- data/lib/cfnguardian/codepipeline.rb +138 -0
- data/lib/cfnguardian/compile.rb +142 -18
- data/lib/cfnguardian/config/defaults.yaml +103 -0
- data/lib/cfnguardian/deploy.rb +2 -16
- data/lib/cfnguardian/display_formatter.rb +163 -0
- data/lib/cfnguardian/drift.rb +79 -0
- data/lib/cfnguardian/error.rb +4 -0
- data/lib/cfnguardian/log.rb +0 -1
- data/lib/cfnguardian/models/alarm.rb +193 -59
- data/lib/cfnguardian/models/check.rb +128 -33
- data/lib/cfnguardian/models/composite.rb +21 -0
- data/lib/cfnguardian/models/event.rb +201 -49
- data/lib/cfnguardian/models/event_subscription.rb +96 -0
- data/lib/cfnguardian/models/metric_filter.rb +28 -0
- data/lib/cfnguardian/resources/amazonmq_rabbitmq.rb +136 -0
- data/lib/cfnguardian/resources/application_targetgroup.rb +2 -0
- data/lib/cfnguardian/resources/azure_file.rb +20 -0
- data/lib/cfnguardian/resources/base.rb +155 -33
- data/lib/cfnguardian/resources/ec2_instance.rb +11 -0
- data/lib/cfnguardian/resources/ecs_service.rb +2 -2
- data/lib/cfnguardian/resources/http.rb +17 -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_cluster.rb +14 -0
- data/lib/cfnguardian/resources/rds_instance.rb +73 -0
- data/lib/cfnguardian/resources/redshift_cluster.rb +2 -2
- data/lib/cfnguardian/resources/sftp.rb +50 -0
- data/lib/cfnguardian/resources/sql.rb +3 -3
- data/lib/cfnguardian/resources/tls.rb +66 -0
- data/lib/cfnguardian/s3.rb +3 -2
- data/lib/cfnguardian/stacks/main.rb +94 -72
- data/lib/cfnguardian/stacks/resources.rb +111 -43
- data/lib/cfnguardian/string.rb +12 -0
- data/lib/cfnguardian/version.rb +1 -1
- metadata +133 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7998606f2ce8404ce0b55dddb9e5d1f4936cd5529364e0b909b1ea3133163ac8
|
4
|
+
data.tar.gz: 82f582858ae75993fc77966e2ae42d9142a1b16a428f74f67f5c1afb2b74854e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f3bda3d2c3c6665749843206c10f3260a5862d87b9f8e066c17eb2b52b996a2911dd619435a16f52336c6aa534a2a0cc39caa03859f1f5f32f6b31182736b44c
|
7
|
+
data.tar.gz: '0665209c6f4e74710383cf37be0a63446e38ed1b89fe6072b8efd030b0b4a010e31f7b54bfed456ea0bd866929b8d769b77506de2e4b5199357bd91fc8ae6213'
|
data/.dockerignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
cfn-guardian-*.gem
|
@@ -0,0 +1,25 @@
|
|
1
|
+
name: test and build gem
|
2
|
+
on:
|
3
|
+
push:
|
4
|
+
branches: [ master ]
|
5
|
+
pull_request:
|
6
|
+
branches: [ master ]
|
7
|
+
|
8
|
+
jobs:
|
9
|
+
build:
|
10
|
+
name: test + build
|
11
|
+
runs-on: ubuntu-latest
|
12
|
+
|
13
|
+
steps:
|
14
|
+
- uses: actions/checkout@v2
|
15
|
+
- name: set up ruby 2.7
|
16
|
+
uses: actions/setup-ruby@v1
|
17
|
+
with:
|
18
|
+
ruby-version: 2.7.x
|
19
|
+
- name: rspec
|
20
|
+
run: |
|
21
|
+
gem install rspec
|
22
|
+
rspec
|
23
|
+
- name: build gem
|
24
|
+
run: |
|
25
|
+
gem build cfn-guardian.gemspec
|
@@ -0,0 +1,25 @@
|
|
1
|
+
name: release gem
|
2
|
+
|
3
|
+
on:
|
4
|
+
release:
|
5
|
+
types: [published]
|
6
|
+
|
7
|
+
jobs:
|
8
|
+
build:
|
9
|
+
name: Build and publish gem
|
10
|
+
runs-on: ubuntu-latest
|
11
|
+
|
12
|
+
steps:
|
13
|
+
- name: Check out the repo
|
14
|
+
uses: actions/checkout@v2
|
15
|
+
|
16
|
+
- name: Set up ruby 2.7
|
17
|
+
uses: actions/setup-ruby@v1
|
18
|
+
with:
|
19
|
+
ruby-version: 2.7.x
|
20
|
+
|
21
|
+
- name: Publish gem
|
22
|
+
uses: dawidd6/action-publish-gem@v1
|
23
|
+
with:
|
24
|
+
api_key: ${{secrets.RUBYGEMS_API_KEY}}
|
25
|
+
github_token: ${{secrets.GITHUB_TOKEN}}
|
@@ -0,0 +1,33 @@
|
|
1
|
+
name: release docker image
|
2
|
+
|
3
|
+
on:
|
4
|
+
release:
|
5
|
+
types: [published]
|
6
|
+
|
7
|
+
jobs:
|
8
|
+
build:
|
9
|
+
name: Build + Publish Container Image
|
10
|
+
runs-on: ubuntu-latest
|
11
|
+
|
12
|
+
steps:
|
13
|
+
- name: Check out the repo
|
14
|
+
uses: actions/checkout@v2
|
15
|
+
|
16
|
+
- name: Set up Docker Buildx
|
17
|
+
uses: docker/setup-buildx-action@v1
|
18
|
+
|
19
|
+
- name: Login to GitHub Container Repository
|
20
|
+
uses: docker/login-action@v1
|
21
|
+
with:
|
22
|
+
registry: ghcr.io
|
23
|
+
username: ${{ github.repository_owner }}
|
24
|
+
password: ${{ secrets.GHCR_PUSH_TOKEN }}
|
25
|
+
|
26
|
+
- name: Build and push Container Image to GitHub Container Repository
|
27
|
+
uses: docker/build-push-action@v2
|
28
|
+
with:
|
29
|
+
context: .
|
30
|
+
file: ./Dockerfile
|
31
|
+
push: true
|
32
|
+
tags: ghcr.io/base2services/guardian:${{ github.event.release.tag_name }}
|
33
|
+
build-args: GUARDIAN_VERSION=${{ github.event.release.tag_name }}
|
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--require spec_helper
|
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,44 +1,62 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
cfn-guardian (0.
|
5
|
-
aws-sdk-cloudformation (~> 1, < 2)
|
6
|
-
aws-sdk-
|
4
|
+
cfn-guardian (0.6.0)
|
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
|
|
11
15
|
GEM
|
12
16
|
remote: https://rubygems.org/
|
13
17
|
specs:
|
14
|
-
aws-eventstream (1.0
|
15
|
-
aws-partitions (1.
|
16
|
-
aws-sdk-cloudformation (1.
|
17
|
-
aws-sdk-core (~> 3, >= 3.
|
18
|
+
aws-eventstream (1.1.0)
|
19
|
+
aws-partitions (1.390.0)
|
20
|
+
aws-sdk-cloudformation (1.44.0)
|
21
|
+
aws-sdk-core (~> 3, >= 3.109.0)
|
18
22
|
aws-sigv4 (~> 1.1)
|
19
|
-
aws-sdk-
|
20
|
-
aws-
|
21
|
-
aws-
|
23
|
+
aws-sdk-cloudwatch (1.40.0)
|
24
|
+
aws-sdk-core (~> 3, >= 3.99.0)
|
25
|
+
aws-sigv4 (~> 1.1)
|
26
|
+
aws-sdk-codecommit (1.36.0)
|
27
|
+
aws-sdk-core (~> 3, >= 3.99.0)
|
28
|
+
aws-sigv4 (~> 1.1)
|
29
|
+
aws-sdk-codepipeline (1.33.0)
|
30
|
+
aws-sdk-core (~> 3, >= 3.99.0)
|
31
|
+
aws-sigv4 (~> 1.1)
|
32
|
+
aws-sdk-core (3.109.2)
|
33
|
+
aws-eventstream (~> 1, >= 1.0.2)
|
34
|
+
aws-partitions (~> 1, >= 1.239.0)
|
22
35
|
aws-sigv4 (~> 1.1)
|
23
36
|
jmespath (~> 1.0)
|
24
|
-
aws-sdk-kms (1.
|
25
|
-
aws-sdk-core (~> 3, >= 3.
|
37
|
+
aws-sdk-kms (1.39.0)
|
38
|
+
aws-sdk-core (~> 3, >= 3.109.0)
|
26
39
|
aws-sigv4 (~> 1.1)
|
27
|
-
aws-sdk-s3 (1.
|
28
|
-
aws-sdk-core (~> 3, >= 3.
|
40
|
+
aws-sdk-s3 (1.84.0)
|
41
|
+
aws-sdk-core (~> 3, >= 3.109.0)
|
29
42
|
aws-sdk-kms (~> 1)
|
30
43
|
aws-sigv4 (~> 1.1)
|
31
|
-
aws-sigv4 (1.
|
32
|
-
aws-eventstream (~> 1
|
33
|
-
cfndsl (1.
|
44
|
+
aws-sigv4 (1.2.2)
|
45
|
+
aws-eventstream (~> 1, >= 1.0.2)
|
46
|
+
cfndsl (1.2.0)
|
34
47
|
hana (~> 1.3)
|
35
|
-
hana (1.3.
|
48
|
+
hana (1.3.6)
|
36
49
|
jmespath (1.4.0)
|
37
|
-
rake (
|
50
|
+
rake (13.0.1)
|
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.25.0)
|
58
|
+
sync
|
59
|
+
unicode-display_width (1.7.0)
|
42
60
|
|
43
61
|
PLATFORMS
|
44
62
|
ruby
|
@@ -46,7 +64,7 @@ PLATFORMS
|
|
46
64
|
DEPENDENCIES
|
47
65
|
bundler (~> 2.0)
|
48
66
|
cfn-guardian!
|
49
|
-
rake (~>
|
67
|
+
rake (~> 13.0)
|
50
68
|
|
51
69
|
BUNDLED WITH
|
52
70
|
2.0.2
|
data/README.md
CHANGED
@@ -1,10 +1,14 @@
|
|
1
1
|
# CfnGuardian
|
2
2
|
|
3
|
+
[Documentation](docs/overview.md)
|
4
|
+
|
3
5
|
CfnGuardian is a AWS monitoring tool with a few capabilities:
|
4
6
|
|
5
7
|
- creates cloudwatch alarms through cloudformation based upon resources defined in a YAML config
|
6
8
|
- alerting through SNS using 4 levels of severity [ Critical, Warning, Task, Informational ]
|
7
9
|
- has a standard set of default alarms across many AWS resources
|
10
|
+
- creates cloudwatch log metric filters with default alarms
|
11
|
+
- creates specfic aws events with sns targets
|
8
12
|
- creates custom metrics for external checks through lambda functions such as
|
9
13
|
- http endpoint availability
|
10
14
|
- http status code matching
|
@@ -13,10 +17,13 @@ CfnGuardian is a AWS monitoring tool with a few capabilities:
|
|
13
17
|
- ssl expiry
|
14
18
|
- sql query
|
15
19
|
- nrpe
|
20
|
+
- sftp availability
|
21
|
+
- sftp file download
|
22
|
+
- tls version checking
|
16
23
|
|
17
24
|
**Supported AWS Resources**
|
18
25
|
|
19
|
-
- AmazonMq
|
26
|
+
- AmazonMq(RabbitMQ and ActiveMQ)
|
20
27
|
- ApiGateway
|
21
28
|
- Application Targetgroups
|
22
29
|
- Network TargetGroups
|
@@ -33,380 +40,4 @@ CfnGuardian is a AWS monitoring tool with a few capabilities:
|
|
33
40
|
- RDS Instances
|
34
41
|
- Redshift Cluster
|
35
42
|
- SQS Queues
|
36
|
-
|
37
|
-
## Installation
|
38
|
-
|
39
|
-
```ruby
|
40
|
-
gem install cfn-guardian
|
41
|
-
```
|
42
|
-
|
43
|
-
## Commands
|
44
|
-
|
45
|
-
**compile**
|
46
|
-
|
47
|
-
```bash
|
48
|
-
Usage:
|
49
|
-
cfn-guardian compile c, --config=CONFIG
|
50
|
-
|
51
|
-
Options:
|
52
|
-
c, --config=CONFIG # yaml config file
|
53
|
-
[--validate], [--no-validate] # validate cfn templates
|
54
|
-
# Default: true
|
55
|
-
[--bucket=BUCKET] # provide custom bucket name, will create a default bucket if not provided
|
56
|
-
r, [--region=REGION] # set the AWS region
|
57
|
-
|
58
|
-
Description:
|
59
|
-
Generates CloudFormation templates from the alarm configuration and output to the out/ directory.
|
60
|
-
```
|
61
|
-
|
62
|
-
**deploy**
|
63
|
-
|
64
|
-
```bash
|
65
|
-
Usage:
|
66
|
-
cfn-guardian deploy c, --config=CONFIG
|
67
|
-
|
68
|
-
Options:
|
69
|
-
c, --config=CONFIG # yaml config file
|
70
|
-
[--bucket=BUCKET] # provide custom bucket name, will create a default bucket if not provided
|
71
|
-
r, [--region=REGION] # set the AWS region
|
72
|
-
r, [--stack-name=STACK_NAME] # set the Cloudformation stack name. Defaults to `guardian`
|
73
|
-
[--sns-critical=SNS_CRITICAL] # sns topic arn for the critical alamrs
|
74
|
-
[--sns-warning=SNS_WARNING] # sns topic arn for the warning alamrs
|
75
|
-
[--sns-task=SNS_TASK] # sns topic arn for the task alamrs
|
76
|
-
[--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.
|
80
|
-
```
|
81
|
-
|
82
|
-
**show-alarms**
|
83
|
-
|
84
|
-
```bash
|
85
|
-
Usage:
|
86
|
-
cfn-guardian show-alarms c, --config=CONFIG
|
87
|
-
|
88
|
-
Options:
|
89
|
-
c, --config=CONFIG # yaml config file
|
90
|
-
g, [--group=GROUP] # resource group
|
91
|
-
n, [--name=NAME] # alarm name
|
92
|
-
r, [--resource=RESOURCE] # resource id
|
93
|
-
|
94
|
-
Description:
|
95
|
-
Displays the configured settings for each alarm. Can be filtered by resource group, resource name and alarm name. Defaults to show all configured alarms.
|
96
|
-
```
|
97
|
-
|
98
|
-
```bash
|
99
|
-
ECSCluster
|
100
|
-
+--------------------------------------+-----------------------------------+
|
101
|
-
| ECSContianerInstancesDisconnected |
|
102
|
-
+--------------------------------------+-----------------------------------+
|
103
|
-
| property | Value |
|
104
|
-
+--------------------------------------+-----------------------------------+
|
105
|
-
| actions_enabled | true |
|
106
|
-
| alarm_action | Critical |
|
107
|
-
| comparison_operator | GreaterThanThreshold |
|
108
|
-
| datapoints_to_alarm | |
|
109
|
-
| dimensions | {:ClusterName=>"MyCluster"} |
|
110
|
-
| enabled | true |
|
111
|
-
| evaluate_low_sample_count_percentile | |
|
112
|
-
| evaluation_periods | 2 |
|
113
|
-
| extended_statistic | |
|
114
|
-
| metric_name | ECSContianerInstancesDisconnected |
|
115
|
-
| namespace | EcsCICheck |
|
116
|
-
| period | 300 |
|
117
|
-
| resource | MyCluster |
|
118
|
-
| resource_name | 3ccc504543e67a86f3fa43bb64cf592b |
|
119
|
-
| statistic | Maximum |
|
120
|
-
| threshold | 0 |
|
121
|
-
| treat_missing_data | |
|
122
|
-
| unit | |
|
123
|
-
+--------------------------------------+-----------------------------------+
|
124
|
-
```
|
125
|
-
|
126
|
-
## Configuration
|
127
|
-
|
128
|
-
Config is stored in a standard YAML file which will default to `alarms.yaml`. This can be overridden by supplying the `--config` switch.
|
129
|
-
|
130
|
-
### AWS Resources
|
131
|
-
|
132
|
-
The resources key is where the resources are defined.
|
133
|
-
|
134
|
-
```yaml
|
135
|
-
Resources:
|
136
|
-
# resource group
|
137
|
-
Ec2Instance:
|
138
|
-
# Array of resources defining the resource id with the Id: key
|
139
|
-
- Id: i-1a2b3c4d5e
|
140
|
-
```
|
141
|
-
|
142
|
-
There are some resources that require more that the resource id to generate the alarm, for these cases addition key:values are required.
|
143
|
-
|
144
|
-
```yaml
|
145
|
-
Resources:
|
146
|
-
ApplicationTargetGroup:
|
147
|
-
- Id: target-group-id
|
148
|
-
# Target group requires the loadbalancer id for the alarm
|
149
|
-
Loadbalancer: app/application-loadbalancer-id
|
150
|
-
```
|
151
|
-
|
152
|
-
| Resource Group | Require Keys |
|
153
|
-
| --------------------------- | ---------------- |
|
154
|
-
| ApiGateway | Id |
|
155
|
-
| AmazonMQBroker | Id |
|
156
|
-
| AutoScalingGroup | Id |
|
157
|
-
| DynamoDBTable | Id |
|
158
|
-
| ElastiCacheReplicationGroup | Id |
|
159
|
-
| ElasticFileSystem | Id |
|
160
|
-
| Ec2Instance | Id |
|
161
|
-
| EcsCluster | Id |
|
162
|
-
| EcsService | Id, Cluster |
|
163
|
-
| NetworkTargetGroup | Id, LoadBalancer |
|
164
|
-
| ApplicationTargetGroup | Id, LoadBalancer |
|
165
|
-
| ElasticLoadBalancer | Id |
|
166
|
-
| RDSInstance | Id |
|
167
|
-
| RDSClusterInstance | Id |
|
168
|
-
| RedshiftCluster | Id |
|
169
|
-
| Lambda | Id |
|
170
|
-
| CloudFrontDistribution | Id |
|
171
|
-
| SQSQueue | Id |
|
172
|
-
|
173
|
-
### Custom Metric Resources
|
174
|
-
|
175
|
-
These are also defined under the resources key but more detail is required and differs per group.
|
176
|
-
|
177
|
-
**Http**
|
178
|
-
|
179
|
-
Cloudwatch NameSpace: `HttpCheck`
|
180
|
-
|
181
|
-
```yaml
|
182
|
-
Resources:
|
183
|
-
Http:
|
184
|
-
# Array of resources defining the http endpoint with the Id: key
|
185
|
-
- Id: https://api.example.com
|
186
|
-
# enables the status code check
|
187
|
-
StatusCode: 200
|
188
|
-
# enables the SSL check
|
189
|
-
Ssl: true
|
190
|
-
- Id: https://www.example.com
|
191
|
-
StatusCode: 301
|
192
|
-
- Id: https://example.com
|
193
|
-
StatusCode: 200
|
194
|
-
Ssl: true
|
195
|
-
# enables the body regex check
|
196
|
-
BodyRegex: 'helloworld'
|
197
|
-
```
|
198
|
-
|
199
|
-
**DomainExpiry**
|
200
|
-
|
201
|
-
Cloudwatch NameSpace: `DNS`
|
202
|
-
|
203
|
-
```yaml
|
204
|
-
Resources:
|
205
|
-
DomainExpiry:
|
206
|
-
# Array of resources defining the domain with the Id: key
|
207
|
-
- Id: example.com
|
208
|
-
```
|
209
|
-
|
210
|
-
**Nrpe**
|
211
|
-
|
212
|
-
Cloudwatch NameSpace: `NRPE`
|
213
|
-
|
214
|
-
*Note: This requires the nrpe agent running and configured on your EC2 Host*
|
215
|
-
|
216
|
-
```yaml
|
217
|
-
Resources:
|
218
|
-
Nrpe:
|
219
|
-
# Array of host groups with the uniq identifier of Environment.
|
220
|
-
# This will create a nrpe lambda per group attach to the defined vpc and subnets
|
221
|
-
- Environment: Prod
|
222
|
-
# VPC id for the vpc the EC2 hosts are running in
|
223
|
-
VpcId: vpc-1234
|
224
|
-
# Array of subnets to attach to the lambda function. Supply multiple if you want to be multi AZ.
|
225
|
-
# Multiple subnets from the same AZ cannot be used!
|
226
|
-
Subnets:
|
227
|
-
- subnet-abcd
|
228
|
-
Hosts:
|
229
|
-
# Array of hosts with the Id: key defining the host private ip address
|
230
|
-
- Id: 10.150.10.6
|
231
|
-
# Array of nrpe commands to run against the host.
|
232
|
-
# A custom metric and alarm is created for each command
|
233
|
-
Commands:
|
234
|
-
- check_disk
|
235
|
-
- Id: 10.150.10.6
|
236
|
-
Commands:
|
237
|
-
- check_disk
|
238
|
-
```
|
239
|
-
|
240
|
-
**Sql**
|
241
|
-
|
242
|
-
Cloudwatch NameSpace: `SQL`
|
243
|
-
|
244
|
-
```yaml
|
245
|
-
Resources:
|
246
|
-
Sql:
|
247
|
-
# Array of host groups with the uniq identifier of Environment.
|
248
|
-
# This will create a sql lambda per group attach to the defined vpc and subnets
|
249
|
-
- Environment: Prod
|
250
|
-
# VPC id for the vpc the EC2 hosts are running in
|
251
|
-
VpcId: vpc-1234
|
252
|
-
# Array of subnets to attach to the lambda function. Supply multiple if you want to be multi AZ.
|
253
|
-
# Multiple subnets from the same AZ cannot be used!
|
254
|
-
Subnets:
|
255
|
-
- subnet-1234
|
256
|
-
Hosts:
|
257
|
-
# Array of hosts with the Id: key defining the host private ip address
|
258
|
-
- Id: my-rds-instance.example.com
|
259
|
-
# Secret manager secret where the sql:// connection string key:value is defined
|
260
|
-
# { "connectionString": "sql://username:password@mydb:3306/information_schema"}
|
261
|
-
SecretId: MyTestDatabaseSecret
|
262
|
-
# Database engine. supports mysql | postgres | mssql
|
263
|
-
Engine: mysql
|
264
|
-
Queries:
|
265
|
-
# Array of SQL queries
|
266
|
-
# MetricName used to create the custom metric and alarm
|
267
|
-
- MetricName: LongRunningTransactions
|
268
|
-
# SQL Query to execute
|
269
|
-
Query: >-
|
270
|
-
SELECT pl.host,trx_id,trx_started,trx_query
|
271
|
-
FROM information_schema.INNODB_TRX it INNER
|
272
|
-
JOIN information_schema.PROCESSLIST pl
|
273
|
-
ON pl.Id=it.trx_mysql_thread_id
|
274
|
-
WHERE it.trx_started < (NOW() - INTERVAL 4 HOUR);
|
275
|
-
```
|
276
|
-
|
277
|
-
Create secretmanager secret:
|
278
|
-
|
279
|
-
```bash
|
280
|
-
aws secretsmanager create-secret --name MyTestDatabaseSecret \
|
281
|
-
--description "My test database secret for use with guardian sql check" \
|
282
|
-
--secret-string '{"connectionString":"sql://username:password@mydb:3306/information_schema"}'
|
283
|
-
```
|
284
|
-
|
285
|
-
## Alarm Templates
|
286
|
-
|
287
|
-
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.
|
288
|
-
|
289
|
-
Custom alarm templates are defined within the same YAML config file un the `Templates` key.
|
290
|
-
|
291
|
-
### Overriding Defaults
|
292
|
-
|
293
|
-
```yaml
|
294
|
-
Templates:
|
295
|
-
# define the resource group
|
296
|
-
Ec2Instance:
|
297
|
-
# define the Alarm name you want to override
|
298
|
-
CPUUtilizationHigh:
|
299
|
-
# supply the key value of the alarm property you want to override
|
300
|
-
Threshold: 80
|
301
|
-
```
|
302
|
-
|
303
|
-
### Creating A New Alarm From A Default
|
304
|
-
|
305
|
-
You can create a default alarm from a default alarm using the `Inherit:` key. This will inherit all properites from the default alarm which can then be overridden.
|
306
|
-
|
307
|
-
```yaml
|
308
|
-
Templates:
|
309
|
-
# define the resource group
|
310
|
-
Ec2Instance:
|
311
|
-
# define the Alarm name you want to override
|
312
|
-
CPUUtilizationWarning:
|
313
|
-
# Inherit the CPUUtilizationHigh alarm
|
314
|
-
Inherit: CPUUtilizationHigh
|
315
|
-
# supply the key value of the alarm property you want to override
|
316
|
-
Threshold: 75
|
317
|
-
EvaluationPeriods: 60
|
318
|
-
AlarmAction: Warning
|
319
|
-
```
|
320
|
-
|
321
|
-
### Creating A New Alarm With No Defaults
|
322
|
-
|
323
|
-
You can create a new alarm with out inheriting an existing one. This will the inherit the default properties for the resource group.
|
324
|
-
|
325
|
-
```yaml
|
326
|
-
Templates:
|
327
|
-
# define the resource group
|
328
|
-
Ec2Instance:
|
329
|
-
# define the Alarm name you want to override
|
330
|
-
CPUUtilizationWarning:
|
331
|
-
# metric name must be provided
|
332
|
-
MetricName: CPUUtilization
|
333
|
-
# supply the key value of the alarm property you want to override
|
334
|
-
Statistic: Minimum
|
335
|
-
Threshold: 75
|
336
|
-
EvaluationPeriods: 60
|
337
|
-
AlarmAction: Warning
|
338
|
-
```
|
339
|
-
|
340
|
-
### Disabling An Alarm
|
341
|
-
|
342
|
-
You can disable an alarm by setting the alarm to `false`
|
343
|
-
|
344
|
-
```yaml
|
345
|
-
Templates:
|
346
|
-
# define the resource group
|
347
|
-
Ec2Instance:
|
348
|
-
# define the Alarm and set the value to false
|
349
|
-
CPUUtilizationHigh: false
|
350
|
-
```
|
351
|
-
|
352
|
-
### Creating A New Resource Group
|
353
|
-
|
354
|
-
You can create a new resource group based upon an existing resource group. For example if you had 2 target groups and wanted to disable an alarm for one but not the other you can create a new resource group which will inherit all the ApplicationTargetGroup alarms and the disabled the select alarm.
|
355
|
-
|
356
|
-
```yaml
|
357
|
-
Resources:
|
358
|
-
# the default resource group
|
359
|
-
ApplicationTargetGroup:
|
360
|
-
- Id: ApiTG
|
361
|
-
LoadBalancer: MyPublicLB
|
362
|
-
- Id: WebTG
|
363
|
-
LoadBalancer: MyPublicLB
|
364
|
-
- Id: ServiceTG
|
365
|
-
LoadBalancer: MyPublicLB
|
366
|
-
|
367
|
-
# my new custom resource group
|
368
|
-
RedirectTargetGroup:
|
369
|
-
- Id: RedirectTG
|
370
|
-
LoadBalancer: MyPublicLB
|
371
|
-
|
372
|
-
Templates:
|
373
|
-
# create the new resource group
|
374
|
-
RedirectTargetGroup:
|
375
|
-
# inherit the ApplicationTargetGroup resource group
|
376
|
-
Inherit: ApplicationTargetGroup
|
377
|
-
# disable the selected alarm
|
378
|
-
TargetResponseTime: false
|
379
|
-
```
|
380
|
-
|
381
|
-
## SNS Topics
|
382
|
-
|
383
|
-
Create the topics before launching the guardian stack
|
384
|
-
|
385
|
-
```bash
|
386
|
-
aws sns create-topic --name Guardian-Critical
|
387
|
-
aws sns create-topic --name Guardian-Warning
|
388
|
-
aws sns create-topic --name Guardian-Task
|
389
|
-
aws sns create-topic --name Guardian-Informational
|
390
|
-
```
|
391
|
-
|
392
|
-
SNS topics can be defined in the YAML config or during the `deploy` command using the sns switches. The full ARN must be used.
|
393
|
-
|
394
|
-
```yaml
|
395
|
-
Topics:
|
396
|
-
Critical: arn:aws:sns:ap-southeast-2:111111111111:Guardian-Critical
|
397
|
-
Warning: arn:aws:sns:ap-southeast-2:111111111111:Guardian-Warning
|
398
|
-
Task: arn:aws:sns:ap-southeast-2:111111111111:Guardian-Task
|
399
|
-
Informational: arn:aws:sns:ap-southeast-2:111111111111:Guardian-Informational
|
400
|
-
```
|
401
|
-
|
402
|
-
## Severities
|
403
|
-
|
404
|
-
Severties are defined in each alarm sing the `AlarmAction` key. There are 4 options `[ Critical, Warning, Task, Informational ]`
|
405
|
-
|
406
|
-
## Contributing
|
407
|
-
|
408
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/base2services/cfn-guardian.
|
409
|
-
|
410
|
-
## License
|
411
|
-
|
412
|
-
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
43
|
+
- LogGroup Metric Filters
|