aws-cdk-lib.aws_cloudwatch.CreateAlarmOptions

interface CreateAlarmOptions

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

Properties needed to make an alarm from a metric.

Example

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

declare const myHostedZone: route53.HostedZone;
const certificate = new acm.Certificate(this, 'Certificate', {
  domainName: 'hello.example.com',
  validation: acm.CertificateValidation.fromDns(myHostedZone),
});
certificate.metricDaysToExpiry().createAlarm(this, 'Alarm', {
  comparisonOperator: cloudwatch.ComparisonOperator.LESS_THAN_THRESHOLD,
  evaluationPeriods: 1,
  threshold: 45, // Automatic rotation happens between 60 and 45 days before expiry
});

Properties

NameTypeDescription
evaluationPeriodsnumberThe number of periods over which data is compared to the specified threshold.
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.


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.