diff --git a/SAMtemplates/alarms/main.yaml b/SAMtemplates/alarms/main.yaml index e2a60ff75..f24363045 100644 --- a/SAMtemplates/alarms/main.yaml +++ b/SAMtemplates/alarms/main.yaml @@ -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 @@ -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: diff --git a/SAMtemplates/main_template.yaml b/SAMtemplates/main_template.yaml index aa71b0cc8..cc133abba 100644 --- a/SAMtemplates/main_template.yaml +++ b/SAMtemplates/main_template.yaml @@ -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 @@ -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 diff --git a/package-lock.json b/package-lock.json index b3740e88c..ce1892882 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4454,6 +4454,7 @@ "version": "6.12.6", "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", "integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==", + "dev": true, "dependencies": { "fast-deep-equal": "^3.1.1", "fast-json-stable-stringify": "^2.0.0", @@ -7140,7 +7141,8 @@ "node_modules/fast-json-stable-stringify": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz", - "integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==" + "integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==", + "dev": true }, "node_modules/fast-levenshtein": { "version": "2.0.6", @@ -9335,7 +9337,8 @@ "node_modules/json-schema-traverse": { "version": "0.4.1", "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", - "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==" + "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", + "dev": true }, "node_modules/json-stable-stringify-without-jsonify": { "version": "1.0.1", @@ -13605,22 +13608,6 @@ "node": ">= 0.8.0" } }, - "node_modules/prettier": { - "version": "3.3.3", - "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.3.3.tgz", - "integrity": "sha512-i2tDNA0O5IrMO757lfrdQZCc2jPNDVntV0m/+4whiDfWaTKfMNgR7Qz0NAeGz/nRqF4m5/6CLzbP4/liHt12Ew==", - "dev": true, - "peer": true, - "bin": { - "prettier": "bin/prettier.cjs" - }, - "engines": { - "node": ">=14" - }, - "funding": { - "url": "https://github.com/prettier/prettier?sponsor=1" - } - }, "node_modules/prettier-linter-helpers": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/prettier-linter-helpers/-/prettier-linter-helpers-1.0.0.tgz",