aws-cdk-lib.aws_cloudwatch.AlarmProps

interface AlarmProps

LanguageType name
.NETAmazon.CDK.AWS.CloudWatch.AlarmProps
Gogithub.com/aws/aws-cdk-go/awscdk/v2/awscloudwatch#AlarmProps
Javasoftware.amazon.awscdk.services.cloudwatch.AlarmProps
Pythonaws_cdk.aws_cloudwatch.AlarmProps
TypeScript (source)aws-cdk-lib » aws_cloudwatch » AlarmProps

Properties for Alarms.

Example

import * as cloudwatch from 'aws-cdk-lib/aws-cloudwatch';

declare const alias: lambda.Alias;
const alarm = new cloudwatch.Alarm(this, 'Errors', {
  comparisonOperator: cloudwatch.ComparisonOperator.GREATER_THAN_THRESHOLD,
  threshold: 1,
  evaluationPeriods: 1,
  metric: alias.metricErrors(),
});
const deploymentGroup = new codedeploy.LambdaDeploymentGroup(this, 'BlueGreenDeployment', {
  alias,
  deploymentConfig: codedeploy.LambdaDeploymentConfig.LINEAR_10PERCENT_EVERY_1MINUTE,
  alarms: [
    // pass some alarms when constructing the deployment group
    alarm,
  ],
});

// or add alarms to an existing group
declare const blueGreenAlias: lambda.Alias;
deploymentGroup.addAlarm(new cloudwatch.Alarm(this, 'BlueGreenErrors', {
  comparisonOperator: cloudwatch.ComparisonOperator.GREATER_THAN_THRESHOLD,
  threshold: 1,
  evaluationPeriods: 1,
  metric: blueGreenAlias.metricErrors(),
}));

Properties

NameTypeDescription
evaluationPeriodsnumberThe number of periods over which data is compared to the specified threshold.
metricIMetricThe metric to add the alarm on.
thresholdnumberThe value against which the specified statistic is compared.
actionsEnabled?booleanWhether the actions for this alarm are enabled.
alarmDescription?stringDescription for the alarm.
alarmName?stringName of the alarm.
comparisonOperator?ComparisonOperatorComparison to use to check if metric is breaching.
datapointsToAlarm?numberThe number of datapoints that must be breaching to trigger the alarm.
evaluateLowSampleCountPercentile?stringSpecifies whether to evaluate the data and potentially change the alarm state if there are too few data points to be statistically significant.
treatMissingData?TreatMissingDataSets how this alarm is to handle missing data points.

evaluationPeriods

Type: number

The number of periods over which data is compared to the specified threshold.


metric

Type: IMetric

The metric to add the alarm on.

Metric objects can be obtained from most resources, or you can construct custom Metric objects by instantiating one.


threshold

Type: number

The value against which the specified statistic is compared.


actionsEnabled?

Type: boolean (optional, default: true)

Whether the actions for this alarm are enabled.


alarmDescription?

Type: string (optional, default: No description)

Description for the alarm.


alarmName?

Type: string (optional, default: Automatically generated name)

Name of the alarm.


comparisonOperator?

Type: ComparisonOperator (optional, default: GreaterThanOrEqualToThreshold)

Comparison to use to check if metric is breaching.


datapointsToAlarm?

Type: number (optional, default: evaluationPeriods)

The number of datapoints that must be breaching to trigger the alarm.

This is used only if you are setting an "M out of N" alarm. In that case, this value is the M. For more information, see Evaluating an Alarm in the Amazon CloudWatch User Guide.

See also: https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/AlarmThatSendsEmail.html#alarm-evaluation


evaluateLowSampleCountPercentile?

Type: string (optional, default: Not configured.)

Specifies whether to evaluate the data and potentially change the alarm state if there are too few data points to be statistically significant.

Used only for alarms that are based on percentiles.


treatMissingData?

Type: TreatMissingData (optional, default: TreatMissingData.Missing)

Sets how this alarm is to handle missing data points.