interface CfnAlarmProps
Language | Type name |
---|---|
.NET | Amazon.CDK.AWS.CloudWatch.CfnAlarmProps |
Go | github.com/aws/aws-cdk-go/awscdk/v2/awscloudwatch#CfnAlarmProps |
Java | software.amazon.awscdk.services.cloudwatch.CfnAlarmProps |
Python | aws_cdk.aws_cloudwatch.CfnAlarmProps |
TypeScript | aws-cdk-lib » aws_cloudwatch » CfnAlarmProps |
Properties for defining a CfnAlarm
.
See also: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-cloudwatch-alarm.html
Example
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import { aws_cloudwatch as cloudwatch } from 'aws-cdk-lib';
const cfnAlarmProps: cloudwatch.CfnAlarmProps = {
comparisonOperator: 'comparisonOperator',
evaluationPeriods: 123,
// the properties below are optional
actionsEnabled: false,
alarmActions: ['alarmActions'],
alarmDescription: 'alarmDescription',
alarmName: 'alarmName',
datapointsToAlarm: 123,
dimensions: [{
name: 'name',
value: 'value',
}],
evaluateLowSampleCountPercentile: 'evaluateLowSampleCountPercentile',
extendedStatistic: 'extendedStatistic',
insufficientDataActions: ['insufficientDataActions'],
metricName: 'metricName',
metrics: [{
id: 'id',
// the properties below are optional
accountId: 'accountId',
expression: 'expression',
label: 'label',
metricStat: {
metric: {
dimensions: [{
name: 'name',
value: 'value',
}],
metricName: 'metricName',
namespace: 'namespace',
},
period: 123,
stat: 'stat',
// the properties below are optional
unit: 'unit',
},
period: 123,
returnData: false,
}],
namespace: 'namespace',
okActions: ['okActions'],
period: 123,
statistic: 'statistic',
tags: [{
key: 'key',
value: 'value',
}],
threshold: 123,
thresholdMetricId: 'thresholdMetricId',
treatMissingData: 'treatMissingData',
unit: 'unit',
};
Properties
Name | Type | Description |
---|---|---|
comparison | string | The arithmetic operation to use when comparing the specified statistic and threshold. |
evaluation | number | The number of periods over which data is compared to the specified threshold. |
actions | boolean | IResolvable | Indicates whether actions should be executed during any changes to the alarm state. |
alarm | string[] | The list of actions to execute when this alarm transitions into an ALARM state from any other state. |
alarm | string | The description of the alarm. |
alarm | string | The name of the alarm. |
datapoints | number | The number of datapoints that must be breaching to trigger the alarm. |
dimensions? | IResolvable | IResolvable | Dimension [] | The dimensions for the metric associated with the alarm. |
evaluate | string | Used only for alarms based on percentiles. |
extended | string | The percentile statistic for the metric associated with the alarm. Specify a value between p0.0 and p100. |
insufficient | string[] | The actions to execute when this alarm transitions to the INSUFFICIENT_DATA state from any other state. |
metric | string | The name of the metric associated with the alarm. |
metrics? | IResolvable | IResolvable | Metric [] | An array that enables you to create an alarm based on the result of a metric math expression. |
namespace? | string | The namespace of the metric associated with the alarm. |
ok | string[] | The actions to execute when this alarm transitions to the OK state from any other state. |
period? | number | The period, in seconds, over which the statistic is applied. |
statistic? | string | The statistic for the metric associated with the alarm, other than percentile. For percentile statistics, use ExtendedStatistic . |
tags? | Cfn [] | A list of key-value pairs to associate with the alarm. |
threshold? | number | The value to compare with the specified statistic. |
threshold | string | In an alarm based on an anomaly detection model, this is the ID of the ANOMALY_DETECTION_BAND function used as the threshold for the alarm. |
treat | string | Sets how this alarm is to handle missing data points. |
unit? | string | The unit of the metric associated with the alarm. |
comparisonOperator
Type:
string
The arithmetic operation to use when comparing the specified statistic and threshold.
The specified statistic value is used as the first operand.
evaluationPeriods
Type:
number
The number of periods over which data is compared to the specified threshold.
If you are setting an alarm that requires that a number of consecutive data points be breaching to trigger the alarm, this value specifies that number. If you are setting an "M out of N" alarm, this value is the N, and DatapointsToAlarm
is the M.
For more information, see Evaluating an Alarm in the Amazon CloudWatch User Guide .
actionsEnabled?
Type:
boolean |
IResolvable
(optional, default: true)
Indicates whether actions should be executed during any changes to the alarm state.
The default is TRUE.
alarmActions?
Type:
string[]
(optional)
The list of actions to execute when this alarm transitions into an ALARM state from any other state.
Specify each action as an Amazon Resource Name (ARN). For more information about creating alarms and the actions that you can specify, see PutMetricAlarm in the Amazon CloudWatch API Reference .
alarmDescription?
Type:
string
(optional)
The description of the alarm.
alarmName?
Type:
string
(optional)
The name of the alarm.
If you don't specify a name, AWS CloudFormation generates a unique physical ID and uses that ID for the alarm name.
If you specify a name, you cannot perform updates that require replacement of this resource. You can perform updates that require no or some interruption. If you must replace the resource, specify a new name.
datapointsToAlarm?
Type:
number
(optional)
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, and the value that you set for EvaluationPeriods
is the N value. For more information, see Evaluating an Alarm in the Amazon CloudWatch User Guide .
If you omit this parameter, CloudWatch uses the same value here that you set for EvaluationPeriods
, and the alarm goes to alarm state if that many consecutive periods are breaching.
dimensions?
Type:
IResolvable
|
IResolvable
|
Dimension
[]
(optional)
The dimensions for the metric associated with the alarm.
For an alarm based on a math expression, you can't specify Dimensions
. Instead, you use Metrics
.
evaluateLowSampleCountPercentile?
Type:
string
(optional)
Used only for alarms based on percentiles.
If ignore
, the alarm state does not change during periods with too few data points to be statistically significant. If evaluate
or this parameter is not used, the alarm is always evaluated and possibly changes state no matter how many data points are available.
extendedStatistic?
Type:
string
(optional)
The percentile statistic for the metric associated with the alarm. Specify a value between p0.0 and p100.
For an alarm based on a metric, you must specify either Statistic
or ExtendedStatistic
but not both.
For an alarm based on a math expression, you can't specify ExtendedStatistic
. Instead, you use Metrics
.
insufficientDataActions?
Type:
string[]
(optional)
The actions to execute when this alarm transitions to the INSUFFICIENT_DATA
state from any other state.
Each action is specified as an Amazon Resource Name (ARN).
metricName?
Type:
string
(optional)
The name of the metric associated with the alarm.
This is required for an alarm based on a metric. For an alarm based on a math expression, you use Metrics
instead and you can't specify MetricName
.
metrics?
Type:
IResolvable
|
IResolvable
|
Metric
[]
(optional)
An array that enables you to create an alarm based on the result of a metric math expression.
Each item in the array either retrieves a metric or performs a math expression.
If you specify the Metrics
parameter, you cannot specify MetricName
, Dimensions
, Period
, Namespace
, Statistic
, ExtendedStatistic
, or Unit
.
namespace?
Type:
string
(optional)
The namespace of the metric associated with the alarm.
This is required for an alarm based on a metric. For an alarm based on a math expression, you can't specify Namespace
and you use Metrics
instead.
For a list of namespaces for metrics from AWS services, see AWS Services That Publish CloudWatch Metrics.
okActions?
Type:
string[]
(optional)
The actions to execute when this alarm transitions to the OK
state from any other state.
Each action is specified as an Amazon Resource Name (ARN).
period?
Type:
number
(optional)
The period, in seconds, over which the statistic is applied.
This is required for an alarm based on a metric. Valid values are 10, 30, 60, and any multiple of 60.
For an alarm based on a math expression, you can't specify Period
, and instead you use the Metrics
parameter.
Minimum: 10
statistic?
Type:
string
(optional)
The statistic for the metric associated with the alarm, other than percentile. For percentile statistics, use ExtendedStatistic
.
For an alarm based on a metric, you must specify either Statistic
or ExtendedStatistic
but not both.
For an alarm based on a math expression, you can't specify Statistic
. Instead, you use Metrics
.
tags?
Type:
Cfn
[]
(optional)
A list of key-value pairs to associate with the alarm.
You can associate as many as 50 tags with an alarm. To be able to associate tags with the alarm when you create the alarm, you must have the cloudwatch:TagResource
permission.
Tags can help you organize and categorize your resources. You can also use them to scope user permissions by granting a user permission to access or change only resources with certain tag values.
threshold?
Type:
number
(optional)
The value to compare with the specified statistic.
thresholdMetricId?
Type:
string
(optional)
In an alarm based on an anomaly detection model, this is the ID of the ANOMALY_DETECTION_BAND
function used as the threshold for the alarm.
treatMissingData?
Type:
string
(optional)
Sets how this alarm is to handle missing data points.
Valid values are breaching
, notBreaching
, ignore
, and missing
. For more information, see Configuring How CloudWatch Alarms Treat Missing Data in the Amazon CloudWatch User Guide .
If you omit this parameter, the default behavior of missing
is used.
unit?
Type:
string
(optional)
The unit of the metric associated with the alarm.
Specify this only if you are creating an alarm based on a single metric. Do not specify this if you are specifying a Metrics
array.
You can specify the following values: Seconds, Microseconds, Milliseconds, Bytes, Kilobytes, Megabytes, Gigabytes, Terabytes, Bits, Kilobits, Megabits, Gigabits, Terabits, Percent, Count, Bytes/Second, Kilobytes/Second, Megabytes/Second, Gigabytes/Second, Terabytes/Second, Bits/Second, Kilobits/Second, Megabits/Second, Gigabits/Second, Terabits/Second, Count/Second, or None.