diff --git a/src/alarms/__tests__/__snapshots__/database-alarms.test.ts.snap b/src/alarms/__tests__/__snapshots__/database-alarms.test.ts.snap index 564f7377..b55e8a93 100644 --- a/src/alarms/__tests__/__snapshots__/database-alarms.test.ts.snap +++ b/src/alarms/__tests__/__snapshots__/database-alarms.test.ts.snap @@ -55,7 +55,6 @@ Object { "Statistic": "Minimum", "Threshold": 28.8, "TreatMissingData": "ignore", - "Unit": "Count", }, "Type": "AWS::CloudWatch::Alarm", }, @@ -84,9 +83,8 @@ Object { ], "Period": 300, "Statistic": "Minimum", - "Threshold": 1.25, + "Threshold": 1342177280, "TreatMissingData": "ignore", - "Unit": "Gigabytes", }, "Type": "AWS::CloudWatch::Alarm", }, @@ -115,9 +113,8 @@ Object { ], "Period": 300, "Statistic": "Minimum", - "Threshold": 6.25, + "Threshold": 6710886400, "TreatMissingData": "ignore", - "Unit": "Gigabytes", }, "Type": "AWS::CloudWatch::Alarm", }, diff --git a/src/alarms/__tests__/__snapshots__/service-alarms.test.ts.snap b/src/alarms/__tests__/__snapshots__/service-alarms.test.ts.snap index c377f65a..89f5e378 100644 --- a/src/alarms/__tests__/__snapshots__/service-alarms.test.ts.snap +++ b/src/alarms/__tests__/__snapshots__/service-alarms.test.ts.snap @@ -204,9 +204,8 @@ Object { }, ], "Period": 300, - "Threshold": 500, + "Threshold": 0.5, "TreatMissingData": "ignore", - "Unit": "Milliseconds", }, "Type": "AWS::CloudWatch::Alarm", }, diff --git a/src/alarms/database-alarms.ts b/src/alarms/database-alarms.ts index d7107993..79a47110 100644 --- a/src/alarms/database-alarms.ts +++ b/src/alarms/database-alarms.ts @@ -2,7 +2,6 @@ import * as constructs from "constructs" import * as cdk from "aws-cdk-lib" import * as cloudwatch from "aws-cdk-lib/aws-cloudwatch" import * as ec2 from "aws-cdk-lib/aws-ec2" -import { Unit } from "aws-cdk-lib/aws-cloudwatch" export interface DatabaseAlarmsProps { /** @@ -118,7 +117,6 @@ export class DatabaseAlarms extends constructs.Construct { metricName: "CPUCreditBalance", namespace: "AWS/RDS", statistic: "Minimum", - unit: Unit.COUNT, period: cdk.Duration.minutes(5), dimensionsMap: { DBInstanceIdentifier: this.databaseInstanceIdentifier, @@ -192,7 +190,6 @@ export class DatabaseAlarms extends constructs.Construct { metricName: "FreeStorageSpace", namespace: "AWS/RDS", statistic: "Minimum", - unit: Unit.GIGABYTES, period: cdk.Duration.minutes(5), dimensionsMap: { DBInstanceIdentifier: this.databaseInstanceIdentifier, @@ -202,8 +199,8 @@ export class DatabaseAlarms extends constructs.Construct { comparisonOperator: cloudwatch.ComparisonOperator.LESS_THAN_THRESHOLD, evaluationPeriods: 1, threshold: - props?.lowStorageSpaceAlarm?.threshold?.toGibibytes() ?? - this.allocatedStorage.toGibibytes() * 0.25, + props?.lowStorageSpaceAlarm?.threshold?.toBytes() ?? + this.allocatedStorage.toBytes() * 0.25, treatMissingData: cloudwatch.TreatMissingData.IGNORE, }) if (props?.lowStorageSpaceAlarm?.enabled ?? true) { @@ -219,7 +216,6 @@ export class DatabaseAlarms extends constructs.Construct { metricName: "FreeStorageSpace", namespace: "AWS/RDS", statistic: "Minimum", - unit: Unit.GIGABYTES, period: cdk.Duration.minutes(5), dimensionsMap: { DBInstanceIdentifier: this.databaseInstanceIdentifier, @@ -229,8 +225,8 @@ export class DatabaseAlarms extends constructs.Construct { comparisonOperator: cloudwatch.ComparisonOperator.LESS_THAN_THRESHOLD, evaluationPeriods: 1, threshold: - props?.criticallyLowStorageSpaceAlarm?.threshold?.toGibibytes() ?? - this.allocatedStorage.toGibibytes() * 0.05, + props?.criticallyLowStorageSpaceAlarm?.threshold?.toBytes() ?? + this.allocatedStorage.toBytes() * 0.05, treatMissingData: cloudwatch.TreatMissingData.IGNORE, }) if (props?.criticallyLowStorageSpaceAlarm?.enabled ?? true) { diff --git a/src/alarms/service-alarms.ts b/src/alarms/service-alarms.ts index 644d970c..1f1db15a 100644 --- a/src/alarms/service-alarms.ts +++ b/src/alarms/service-alarms.ts @@ -295,7 +295,6 @@ export class ServiceAlarms extends constructs.Construct { namespace: "AWS/ApplicationELB", statistic: "p95", period: props.targetResponseTimeAlarm?.period ?? cdk.Duration.minutes(5), - unit: cloudwatch.Unit.MILLISECONDS, dimensionsMap: { LoadBalancer: props.loadBalancerFullName, TargetGroup: props.targetGroupFullName, @@ -308,7 +307,7 @@ export class ServiceAlarms extends constructs.Construct { evaluationPeriods: props.targetResponseTimeAlarm?.evaluationPeriods ?? 1, threshold: ( props.targetResponseTimeAlarm?.threshold ?? cdk.Duration.millis(500) - ).toMilliseconds(), + ).toSeconds({ integral: false }), treatMissingData: cloudwatch.TreatMissingData.IGNORE, }) if (props.targetResponseTimeAlarm?.enabled ?? true) {