Skip to content

Commit

Permalink
New: [AEA-4490] - Add an alarm on Dynamo capacity (#939)
Browse files Browse the repository at this point in the history
## Summary

- ✨ New Feature

### Details

[Ticket](https://nhsd-jira.digital.nhs.uk/browse/AEA-4490)

We want to alert when the database consumption rate approaches the
provisioned capacity. This adds an alarm to the existing `alarms.yml` to
do so. The alarm is placed in the PSU stack so as to also apply itself
to alternate stack names (e.g. PR stacks)
  • Loading branch information
wildjames authored Oct 22, 2024
1 parent ec1291a commit 44a2beb
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 18 deletions.
48 changes: 48 additions & 0 deletions SAMtemplates/alarms/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ Parameters:
EnableAlerts:
Type: String

DynamoDBUtilizationPercentageThreshold:
Type: Number
Description: When the database usage crosses this percentage of provisioned capacity, trigger an alarm
Default: 90

Resources:
GetStatusUpdatesErrorsLogsMetricFilter:
Type: AWS::Logs::MetricFilter
Expand Down Expand Up @@ -220,6 +225,49 @@ Resources:
OKActions:
- !ImportValue lambda-resources:SlackAlertsSnsTopicArn

DynamoDBWriteConsumptionAlarm:
Type: AWS::CloudWatch::Alarm
Properties:
AlarmName: !Sub "${AWS::StackName}_DynamoDB_ConsumedWriteCapacity"
ActionsEnabled: !Ref EnableAlerts
AlarmActions:
- !ImportValue lambda-resources:SlackAlertsSnsTopicArn
InsufficientDataActions:
- !ImportValue lambda-resources:SlackAlertsSnsTopicArn
OKActions:
- !ImportValue lambda-resources:SlackAlertsSnsTopicArn
EvaluationPeriods: 1
Threshold: !Ref DynamoDBUtilizationPercentageThreshold
ComparisonOperator: GreaterThanOrEqualToThreshold
TreatMissingData: notBreaching
Metrics:
- Id: e1
Label: UtilizationPercentage
ReturnData: true
Expression: "(m1 / (m2 * 60)) * 100"
- Id: m1
ReturnData: false
MetricStat:
Metric:
Namespace: AWS/DynamoDB
MetricName: ConsumedWriteCapacityUnits
Dimensions:
- Name: TableName
Value: !Ref PrescriptionStatusUpdatesTableName
Period: 60
Stat: Sum
- Id: m2
ReturnData: false
MetricStat:
Metric:
Namespace: AWS/DynamoDB
MetricName: ProvisionedWriteCapacityUnits
Dimensions:
- Name: TableName
Value: !Ref PrescriptionStatusUpdatesTableName
Period: 60
Stat: Maximum

CPSUFhirConverterErrorLogsMetricFilter:
Type: AWS::Logs::MetricFilter
Properties:
Expand Down
7 changes: 7 additions & 0 deletions SAMtemplates/main_template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,12 @@ Parameters:
- true
- false

DynamoDBUtilizationPercentageThreshold:
Type: Number
Description: When the database usage crosses this percentage of provisioned capacity, trigger an alarm
Default: 90


Resources:
Tables:
Type: AWS::Serverless::Application
Expand Down Expand Up @@ -150,4 +156,5 @@ Resources:
UpdatePrescriptionStatusFunctionName: !GetAtt Functions.Outputs.UpdatePrescriptionStatusFunctionName
PrescriptionStatusUpdatesTableName: !GetAtt Tables.Outputs.PrescriptionStatusUpdatesTableName
ConvertRequestToFhirFormatFunctionName: !GetAtt Functions.Outputs.ConvertRequestToFhirFormatFunctionName
DynamoDBUtilizationPercentageThreshold: !Ref DynamoDBUtilizationPercentageThreshold
EnableAlerts: !Ref EnableAlerts
23 changes: 5 additions & 18 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 44a2beb

Please sign in to comment.