Skip to content

Commit c1ced91

Browse files
New: [AEA-4488] - Adds Slack Alarm (#195)
## Summary - ✨ New Feature ### Details Adds Slack Alarm
1 parent 0d9acf2 commit c1ced91

File tree

8 files changed

+85
-1
lines changed

8 files changed

+85
-1
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ jobs:
106106
LOG_RETENTION_DAYS: 30
107107
CREATE_INT_RELEASE_NOTES: true
108108
CREATE_PROD_RELEASE_NOTES: true
109+
ENABLE_ALERTS: true
109110
secrets:
110111
CLOUD_FORMATION_DEPLOY_ROLE: ${{ secrets.DEV_CLOUD_FORMATION_DEPLOY_ROLE }}
111112
DEV_CLOUD_FORMATION_CHECK_VERSION_ROLE: ${{ secrets.DEV_CLOUD_FORMATION_CHECK_VERSION_ROLE }}
@@ -125,5 +126,6 @@ jobs:
125126
COMMIT_ID: ${{needs.get_commit_id.outputs.commit_id}}
126127
LOG_LEVEL: INFO
127128
LOG_RETENTION_DAYS: 30
129+
ENABLE_ALERTS: true
128130
secrets:
129131
CLOUD_FORMATION_DEPLOY_ROLE: ${{ secrets.QA_CLOUD_FORMATION_DEPLOY_ROLE }}

.github/workflows/pull_request.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,5 +69,6 @@ jobs:
6969
COMMIT_ID: ${{ needs.get_commit_id.outputs.commit_id }}
7070
LOG_LEVEL: INFO
7171
LOG_RETENTION_DAYS: 30
72+
ENABLE_ALERTS: false
7273
secrets:
7374
CLOUD_FORMATION_DEPLOY_ROLE: ${{ secrets.DEV_CLOUD_FORMATION_DEPLOY_ROLE }}

.github/workflows/release.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ jobs:
124124
LOG_RETENTION_DAYS: 30
125125
CREATE_INT_RELEASE_NOTES: true
126126
CREATE_PROD_RELEASE_NOTES: true
127+
ENABLE_ALERTS: true
127128
secrets:
128129
CLOUD_FORMATION_DEPLOY_ROLE: ${{ secrets.DEV_CLOUD_FORMATION_DEPLOY_ROLE }}
129130
DEV_CLOUD_FORMATION_CHECK_VERSION_ROLE: ${{ secrets.DEV_CLOUD_FORMATION_CHECK_VERSION_ROLE }}
@@ -143,6 +144,7 @@ jobs:
143144
COMMIT_ID: ${{needs.get_commit_id.outputs.commit_id}}
144145
LOG_LEVEL: INFO
145146
LOG_RETENTION_DAYS: 30
147+
ENABLE_ALERTS: true
146148
secrets:
147149
CLOUD_FORMATION_DEPLOY_ROLE: ${{ secrets.REF_CLOUD_FORMATION_DEPLOY_ROLE }}
148150

@@ -158,6 +160,7 @@ jobs:
158160
COMMIT_ID: ${{needs.get_commit_id.outputs.commit_id}}
159161
LOG_LEVEL: INFO
160162
LOG_RETENTION_DAYS: 30
163+
ENABLE_ALERTS: true
161164
secrets:
162165
CLOUD_FORMATION_DEPLOY_ROLE: ${{ secrets.QA_CLOUD_FORMATION_DEPLOY_ROLE }}
163166

@@ -175,6 +178,7 @@ jobs:
175178
LOG_RETENTION_DAYS: 30
176179
CREATE_INT_RELEASE_NOTES: true
177180
CREATE_INT_RC_RELEASE_NOTES: true
181+
ENABLE_ALERTS: true
178182
secrets:
179183
CLOUD_FORMATION_DEPLOY_ROLE: ${{ secrets.INT_CLOUD_FORMATION_DEPLOY_ROLE }}
180184
DEV_CLOUD_FORMATION_CHECK_VERSION_ROLE: ${{ secrets.DEV_CLOUD_FORMATION_CHECK_VERSION_ROLE }}
@@ -196,6 +200,7 @@ jobs:
196200
LOG_RETENTION_DAYS: 731
197201
MARK_JIRA_RELEASED: true
198202
CREATE_PROD_RELEASE_NOTES: true
203+
ENABLE_ALERTS: true
199204
secrets:
200205
CLOUD_FORMATION_DEPLOY_ROLE: ${{ secrets.PROD_CLOUD_FORMATION_DEPLOY_ROLE }}
201206
DEV_CLOUD_FORMATION_CHECK_VERSION_ROLE: ${{ secrets.DEV_CLOUD_FORMATION_CHECK_VERSION_ROLE }}

.github/workflows/sam_release_code.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ on:
3939
MARK_JIRA_RELEASED:
4040
type: boolean
4141
default: false
42+
ENABLE_ALERTS:
43+
type: boolean
44+
default: true
4245
secrets:
4346
CLOUD_FORMATION_DEPLOY_ROLE:
4447
required: true
@@ -105,6 +108,7 @@ jobs:
105108
TARGET_ENVIRONMENT: ${{ inputs.TARGET_ENVIRONMENT }}
106109
template_file: template.yaml
107110
VERSION_NUMBER: ${{ inputs.VERSION_NUMBER }}
111+
ENABLE_ALERTS: ${{ inputs.ENABLE_ALERTS }}
108112
run: ./release_code.sh
109113

110114
- name: create_int_release_notes

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,8 @@ sam-deploy-package: guard-artifact_bucket guard-artifact_bucket_prefix guard-sta
101101
--parameter-overrides \
102102
EnableSplunk=true \
103103
LogLevel=$$LOG_LEVEL \
104-
LogRetentionDays=$$LOG_RETENTION_DAYS
104+
LogRetentionDays=$$LOG_RETENTION_DAYS \
105+
EnableAlerts=$$ENABLE_ALERTS
105106

106107
aws-configure:
107108
aws configure sso --region eu-west-2

SAMtemplates/alarms/main.yaml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
AWSTemplateFormatVersion: "2010-09-09"
2+
Transform: AWS::Serverless-2016-10-31
3+
Description: |
4+
FHIR Validator Cloudwatch alarms and related resources
5+
6+
Parameters:
7+
StackName:
8+
Type: String
9+
10+
EnableAlerts:
11+
Type: String
12+
13+
FHIRValidatorUKCoreLambdaName:
14+
Type: String
15+
16+
Resources:
17+
FHIRValidatorErrorLogsMetricFilter:
18+
Type: AWS::Logs::MetricFilter
19+
Properties:
20+
FilterName: FHIRValidatorErrors
21+
# Catch java exceptions
22+
FilterPattern: Exception
23+
LogGroupName:
24+
Fn::ImportValue: !Sub ${StackName}:functions:${FHIRValidatorUKCoreLambdaName}:LambdaLogGroupName
25+
MetricTransformations:
26+
- MetricNamespace: LambdaLogFilterMetrics
27+
MetricName: !Sub ${StackName}FHIRValidatorErrorCount
28+
MetricValue: 1
29+
Unit: Count
30+
31+
FHIRValidatorErrorsAlarm:
32+
Type: AWS::CloudWatch::Alarm
33+
Properties:
34+
AlarmDescription: Count of FHIR Validator system errors
35+
AlarmName: !Sub ${StackName}_FhirValidator_Errors
36+
Namespace: LambdaLogFilterMetrics
37+
MetricName: !Sub ${StackName}FHIRValidatorErrorCount
38+
Period: 60 #seconds
39+
EvaluationPeriods: 1
40+
Statistic: Sum
41+
ComparisonOperator: GreaterThanOrEqualToThreshold
42+
Threshold: 1
43+
Unit: Count
44+
TreatMissingData: notBreaching
45+
ActionsEnabled: !Ref EnableAlerts
46+
AlarmActions:
47+
- !ImportValue lambda-resources:SlackAlertsSnsTopicArn
48+
InsufficientDataActions:
49+
- !ImportValue lambda-resources:SlackAlertsSnsTopicArn
50+
OKActions:
51+
- !ImportValue lambda-resources:SlackAlertsSnsTopicArn

SAMtemplates/lambda_resources.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,3 +139,8 @@ Outputs:
139139
LambdaRole:
140140
Description: "LambdaRole"
141141
Value: !Ref LambdaRole
142+
LogGroupName:
143+
Description: Lambda log group name
144+
Value: !Ref LambdaLogGroup
145+
Export:
146+
Name: !Sub ${StackName}:functions:${LambdaName}:LambdaLogGroupName

SAMtemplates/main_template.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,12 @@ Parameters:
3737
3288,
3838
3653,
3939
]
40+
EnableAlerts:
41+
Type: String
42+
Default: true
43+
AllowedValues:
44+
- true
45+
- false
4046

4147
Resources:
4248
FHIRValidatorUKCoreResources:
@@ -82,6 +88,15 @@ Resources:
8288
- LAMBDA_INSIDE_VPC
8389
- LAMBDA_CONCURRENCY_CHECK
8490

91+
Alarms:
92+
Type: AWS::Serverless::Application
93+
Properties:
94+
Location: alarms/main.yaml
95+
Parameters:
96+
StackName: !Ref AWS::StackName
97+
EnableAlerts: !Ref EnableAlerts
98+
FHIRValidatorUKCoreLambdaName: !Ref FHIRValidatorUKCore
99+
85100
Outputs:
86101
FHIRValidatorUKCoreLambdaName:
87102
Description: Name of the FHIR validator UK Core lambda

0 commit comments

Comments
 (0)