CfnAlarm
- class aws_cdk.aws_cloudwatch.CfnAlarm(scope, id, *, comparison_operator, evaluation_periods, actions_enabled=None, alarm_actions=None, alarm_description=None, alarm_name=None, datapoints_to_alarm=None, dimensions=None, evaluate_low_sample_count_percentile=None, extended_statistic=None, insufficient_data_actions=None, metric_name=None, metrics=None, namespace=None, ok_actions=None, period=None, statistic=None, threshold=None, threshold_metric_id=None, treat_missing_data=None, unit=None)
Bases:
CfnResource
A CloudFormation
AWS::CloudWatch::Alarm
.The
AWS::CloudWatch::Alarm
type specifies an alarm and associates it with the specified metric or metric math expression.When this operation creates an alarm, the alarm state is immediately set to
INSUFFICIENT_DATA
. The alarm is then evaluated and its state is set appropriately. Any actions associated with the new state are then executed.When you update an existing alarm, its state is left unchanged, but the update completely overwrites the previous configuration of the alarm.
- CloudformationResource:
AWS::CloudWatch::Alarm
- Link:
http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-cloudwatch-alarm.html
- ExampleMetadata:
fixture=_generated
Example:
# The code below shows an example of how to instantiate this type. # The values are placeholders you should change. import aws_cdk.aws_cloudwatch as cloudwatch cfn_alarm = cloudwatch.CfnAlarm(self, "MyCfnAlarm", comparison_operator="comparisonOperator", evaluation_periods=123, # the properties below are optional actions_enabled=False, alarm_actions=["alarmActions"], alarm_description="alarmDescription", alarm_name="alarmName", datapoints_to_alarm=123, dimensions=[cloudwatch.CfnAlarm.DimensionProperty( name="name", value="value" )], evaluate_low_sample_count_percentile="evaluateLowSampleCountPercentile", extended_statistic="extendedStatistic", insufficient_data_actions=["insufficientDataActions"], metric_name="metricName", metrics=[cloudwatch.CfnAlarm.MetricDataQueryProperty( id="id", # the properties below are optional account_id="accountId", expression="expression", label="label", metric_stat=cloudwatch.CfnAlarm.MetricStatProperty( metric=cloudwatch.CfnAlarm.MetricProperty( dimensions=[cloudwatch.CfnAlarm.DimensionProperty( name="name", value="value" )], metric_name="metricName", namespace="namespace" ), period=123, stat="stat", # the properties below are optional unit="unit" ), period=123, return_data=False )], namespace="namespace", ok_actions=["okActions"], period=123, statistic="statistic", threshold=123, threshold_metric_id="thresholdMetricId", treat_missing_data="treatMissingData", unit="unit" )
Create a new
AWS::CloudWatch::Alarm
.- Parameters:
scope (
Construct
) –scope in which this resource is defined.
id (
str
) –scoped id of the resource.
comparison_operator (
str
) – The arithmetic operation to use when comparing the specified statistic and threshold. The specified statistic value is used as the first operand. You can specify the following values:GreaterThanThreshold
,GreaterThanOrEqualToThreshold
,LessThanThreshold
, orLessThanOrEqualToThreshold
.evaluation_periods (
Union
[int
,float
]) – 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, andDatapointsToAlarm
is the M. For more information, see Evaluating an Alarm in the Amazon CloudWatch User Guide .actions_enabled (
Union
[bool
,IResolvable
,None
]) – Indicates whether actions should be executed during any changes to the alarm state. The default is TRUE.alarm_actions (
Optional
[Sequence
[str
]]) – 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 .alarm_description (
Optional
[str
]) – The description of the alarm.alarm_name (
Optional
[str
]) – 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. .. epigraph:: 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.datapoints_to_alarm (
Union
[int
,float
,None
]) –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 forEvaluationPeriods
, and the alarm goes to alarm state if that many consecutive periods are breaching.dimensions (
Union
[IResolvable
,Sequence
[Union
[IResolvable
,DimensionProperty
,Dict
[str
,Any
]]],None
]) – The dimensions for the metric associated with the alarm. For an alarm based on a math expression, you can’t specifyDimensions
. Instead, you useMetrics
.evaluate_low_sample_count_percentile (
Optional
[str
]) – Used only for alarms based on percentiles. Ifignore
, the alarm state does not change during periods with too few data points to be statistically significant. Ifevaluate
or this parameter is not used, the alarm is always evaluated and possibly changes state no matter how many data points are available.extended_statistic (
Optional
[str
]) – 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 eitherStatistic
orExtendedStatistic
but not both. For an alarm based on a math expression, you can’t specifyExtendedStatistic
. Instead, you useMetrics
.insufficient_data_actions (
Optional
[Sequence
[str
]]) – The actions to execute when this alarm transitions to theINSUFFICIENT_DATA
state from any other state. Each action is specified as an Amazon Resource Name (ARN).metric_name (
Optional
[str
]) – 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 useMetrics
instead and you can’t specifyMetricName
.metrics (
Union
[IResolvable
,Sequence
[Union
[IResolvable
,MetricDataQueryProperty
,Dict
[str
,Any
]]],None
]) – 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 theMetrics
parameter, you cannot specifyMetricName
,Dimensions
,Period
,Namespace
,Statistic
,ExtendedStatistic
, orUnit
.namespace (
Optional
[str
]) – 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 specifyNamespace
and you useMetrics
instead. For a list of namespaces for metrics from AWS services, see AWS Services That Publish CloudWatch Metrics.ok_actions (
Optional
[Sequence
[str
]]) – The actions to execute when this alarm transitions to theOK
state from any other state. Each action is specified as an Amazon Resource Name (ARN).period (
Union
[int
,float
,None
]) – 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 specifyPeriod
, and instead you use theMetrics
parameter. Minimum: 10statistic (
Optional
[str
]) – The statistic for the metric associated with the alarm, other than percentile. For percentile statistics, useExtendedStatistic
. For an alarm based on a metric, you must specify eitherStatistic
orExtendedStatistic
but not both. For an alarm based on a math expression, you can’t specifyStatistic
. Instead, you useMetrics
.threshold (
Union
[int
,float
,None
]) – The value to compare with the specified statistic.threshold_metric_id (
Optional
[str
]) – In an alarm based on an anomaly detection model, this is the ID of theANOMALY_DETECTION_BAND
function used as the threshold for the alarm.treat_missing_data (
Optional
[str
]) – Sets how this alarm is to handle missing data points. Valid values arebreaching
,notBreaching
,ignore
, andmissing
. 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 ofmissing
is used.unit (
Optional
[str
]) – 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 aMetrics
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.
Methods
- add_deletion_override(path)
Syntactic sugar for
addOverride(path, undefined)
.- Parameters:
path (
str
) – The path of the value to delete.- Return type:
None
- add_depends_on(target)
Indicates that this resource depends on another resource and cannot be provisioned unless the other resource has been successfully provisioned.
This can be used for resources across stacks (or nested stack) boundaries and the dependency will automatically be transferred to the relevant scope.
- Parameters:
target (
CfnResource
) –- Return type:
None
- add_metadata(key, value)
Add a value to the CloudFormation Resource Metadata.
- Parameters:
key (
str
) –value (
Any
) –
- See:
- Return type:
None
Note that this is a different set of metadata from CDK node metadata; this metadata ends up in the stack template under the resource, whereas CDK node metadata ends up in the Cloud Assembly.
- add_override(path, value)
Adds an override to the synthesized CloudFormation resource.
To add a property override, either use
addPropertyOverride
or prefixpath
with “Properties.” (i.e.Properties.TopicName
).If the override is nested, separate each nested level using a dot (.) in the path parameter. If there is an array as part of the nesting, specify the index in the path.
To include a literal
.
in the property name, prefix with a\
. In most programming languages you will need to write this as"\\."
because the\
itself will need to be escaped.For example:
cfn_resource.add_override("Properties.GlobalSecondaryIndexes.0.Projection.NonKeyAttributes", ["myattribute"]) cfn_resource.add_override("Properties.GlobalSecondaryIndexes.1.ProjectionType", "INCLUDE")
would add the overrides Example:
"Properties": { "GlobalSecondaryIndexes": [ { "Projection": { "NonKeyAttributes": [ "myattribute" ] ... } ... }, { "ProjectionType": "INCLUDE" ... }, ] ... }
The
value
argument toaddOverride
will not be processed or translated in any way. Pass raw JSON values in here with the correct capitalization for CloudFormation. If you pass CDK classes or structs, they will be rendered with lowercased key names, and CloudFormation will reject the template.- Parameters:
path (
str
) –The path of the property, you can use dot notation to override values in complex types. Any intermdediate keys will be created as needed.
value (
Any
) –The value. Could be primitive or complex.
- Return type:
None
- add_property_deletion_override(property_path)
Adds an override that deletes the value of a property from the resource definition.
- Parameters:
property_path (
str
) – The path to the property.- Return type:
None
- add_property_override(property_path, value)
Adds an override to a resource property.
Syntactic sugar for
addOverride("Properties.<...>", value)
.- Parameters:
property_path (
str
) – The path of the property.value (
Any
) – The value.
- Return type:
None
- apply_removal_policy(policy=None, *, apply_to_update_replace_policy=None, default=None)
Sets the deletion policy of the resource based on the removal policy specified.
The Removal Policy controls what happens to this resource when it stops being managed by CloudFormation, either because you’ve removed it from the CDK application or because you’ve made a change that requires the resource to be replaced.
The resource can be deleted (
RemovalPolicy.DESTROY
), or left in your AWS account for data recovery and cleanup later (RemovalPolicy.RETAIN
).- Parameters:
policy (
Optional
[RemovalPolicy
]) –apply_to_update_replace_policy (
Optional
[bool
]) – Apply the same deletion policy to the resource’s “UpdateReplacePolicy”. Default: truedefault (
Optional
[RemovalPolicy
]) – The default policy to apply in case the removal policy is not defined. Default: - Default value is resource specific. To determine the default value for a resoure, please consult that specific resource’s documentation.
- Return type:
None
- get_att(attribute_name)
Returns a token for an runtime attribute of this resource.
Ideally, use generated attribute accessors (e.g.
resource.arn
), but this can be used for future compatibility in case there is no generated attribute.- Parameters:
attribute_name (
str
) – The name of the attribute.- Return type:
- get_metadata(key)
Retrieve a value value from the CloudFormation Resource Metadata.
- Parameters:
key (
str
) –- See:
- Return type:
Any
Note that this is a different set of metadata from CDK node metadata; this metadata ends up in the stack template under the resource, whereas CDK node metadata ends up in the Cloud Assembly.
- inspect(inspector)
Examines the CloudFormation resource and discloses attributes.
- Parameters:
inspector (
TreeInspector
) –tree inspector to collect and process attributes.
- Return type:
None
- override_logical_id(new_logical_id)
Overrides the auto-generated logical ID with a specific ID.
- Parameters:
new_logical_id (
str
) – The new logical ID to use for this stack element.- Return type:
None
- to_string()
Returns a string representation of this construct.
- Return type:
str
- Returns:
a string representation of this resource
Attributes
- CFN_RESOURCE_TYPE_NAME = 'AWS::CloudWatch::Alarm'
- actions_enabled
Indicates whether actions should be executed during any changes to the alarm state.
The default is TRUE.
- alarm_actions
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 .
- alarm_description
The description of the alarm.
- alarm_name
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. .. epigraph:
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.
- attr_arn
The ARN of the CloudWatch alarm, such as
arn:aws:cloudwatch:us-west-2:123456789012:alarm:myCloudWatchAlarm-CPUAlarm-UXMMZK36R55Z
.- CloudformationAttribute:
Arn
- cfn_options
Options for this resource, such as condition, update policy etc.
- cfn_resource_type
AWS resource type.
- comparison_operator
The arithmetic operation to use when comparing the specified statistic and threshold.
The specified statistic value is used as the first operand.
You can specify the following values:
GreaterThanThreshold
,GreaterThanOrEqualToThreshold
,LessThanThreshold
, orLessThanOrEqualToThreshold
.
- creation_stack
return:
the stack trace of the point where this Resource was created from, sourced from the +metadata+ entry typed +aws:cdk:logicalId+, and with the bottom-most node +internal+ entries filtered.
- datapoints_to_alarm
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
The dimensions for the metric associated with the alarm.
For an alarm based on a math expression, you can’t specify
Dimensions
. Instead, you useMetrics
.
- evaluate_low_sample_count_percentile
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. Ifevaluate
or this parameter is not used, the alarm is always evaluated and possibly changes state no matter how many data points are available.
- evaluation_periods
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 .
- extended_statistic
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
orExtendedStatistic
but not both.For an alarm based on a math expression, you can’t specify
ExtendedStatistic
. Instead, you useMetrics
.
- insufficient_data_actions
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).
- logical_id
The logical ID for this CloudFormation stack element.
The logical ID of the element is calculated from the path of the resource node in the construct tree.
To override this value, use
overrideLogicalId(newLogicalId)
.- Returns:
the logical ID as a stringified token. This value will only get resolved during synthesis.
- metric_name
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 specifyMetricName
.
- metrics
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 specifyMetricName
,Dimensions
,Period
,Namespace
,Statistic
,ExtendedStatistic
, orUnit
.
- namespace
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 useMetrics
instead.For a list of namespaces for metrics from AWS services, see AWS Services That Publish CloudWatch Metrics.
- node
The construct tree node associated with this construct.
- ok_actions
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
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 theMetrics
parameter.Minimum: 10
- ref
Return a string that will be resolved to a CloudFormation
{ Ref }
for this element.If, by any chance, the intrinsic reference of a resource is not a string, you could coerce it to an IResolvable through
Lazy.any({ produce: resource.ref })
.
- stack
The stack in which this element is defined.
CfnElements must be defined within a stack scope (directly or indirectly).
- statistic
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
orExtendedStatistic
but not both.For an alarm based on a math expression, you can’t specify
Statistic
. Instead, you useMetrics
.
- threshold
The value to compare with the specified statistic.
- threshold_metric_id
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_missing_data
Sets how this alarm is to handle missing data points.
Valid values are
breaching
,notBreaching
,ignore
, andmissing
. 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
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.
Static Methods
- classmethod is_cfn_element(x)
Returns
true
if a construct is a stack element (i.e. part of the synthesized cloudformation template).Uses duck-typing instead of
instanceof
to allow stack elements from different versions of this library to be included in the same stack.- Parameters:
x (
Any
) –- Return type:
bool
- Returns:
The construct as a stack element or undefined if it is not a stack element.
- classmethod is_cfn_resource(construct)
Check whether the given construct is a CfnResource.
- Parameters:
construct (
IConstruct
) –- Return type:
bool
- classmethod is_construct(x)
Return whether the given object is a Construct.
- Parameters:
x (
Any
) –- Return type:
bool
DimensionProperty
- class CfnAlarm.DimensionProperty(*, name, value)
Bases:
object
Dimension is an embedded property of the
AWS::CloudWatch::Alarm
type.Dimensions are name/value pairs that can be associated with a CloudWatch metric. You can specify a maximum of 10 dimensions for a given metric.
- Parameters:
name (
str
) – The name of the dimension, from 1–255 characters in length. This dimension name must have been included when the metric was published.value (
str
) – The value for the dimension, from 1–255 characters in length.
- Link:
http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-cw-dimension.html
- ExampleMetadata:
fixture=_generated
Example:
# The code below shows an example of how to instantiate this type. # The values are placeholders you should change. import aws_cdk.aws_cloudwatch as cloudwatch dimension_property = cloudwatch.CfnAlarm.DimensionProperty( name="name", value="value" )
Attributes
- name
The name of the dimension, from 1–255 characters in length.
This dimension name must have been included when the metric was published.
- value
The value for the dimension, from 1–255 characters in length.
MetricDataQueryProperty
- class CfnAlarm.MetricDataQueryProperty(*, id, account_id=None, expression=None, label=None, metric_stat=None, period=None, return_data=None)
Bases:
object
The
MetricDataQuery
property type specifies the metric data to return, and whether this call is just retrieving a batch set of data for one metric, or is performing a math expression on metric data.Any expression used must return a single time series. For more information, see Metric Math Syntax and Functions in the Amazon CloudWatch User Guide .
- Parameters:
id (
str
) – A short name used to tie this object to the results in the response. This name must be unique within a single call toGetMetricData
. If you are performing math expressions on this set of data, this name represents that data and can serve as a variable in the mathematical expression. The valid characters are letters, numbers, and underscore. The first character must be a lowercase letter.account_id (
Optional
[str
]) – The ID of the account where the metrics are located, if this is a cross-account alarm.expression (
Optional
[str
]) –The math expression to be performed on the returned data, if this object is performing a math expression. This expression can use the
Id
of the other metrics to refer to those metrics, and can also use theId
of other expressions to use the result of those expressions. For more information about metric math expressions, see Metric Math Syntax and Functions in the Amazon CloudWatch User Guide . Within each MetricDataQuery object, you must specify eitherExpression
orMetricStat
but not both.label (
Optional
[str
]) – A human-readable label for this metric or expression. This is especially useful if this is an expression, so that you know what the value represents. If the metric or expression is shown in a CloudWatch dashboard widget, the label is shown. IfLabel
is omitted, CloudWatch generates a default.metric_stat (
Union
[IResolvable
,MetricStatProperty
,Dict
[str
,Any
],None
]) – The metric to be returned, along with statistics, period, and units. Use this parameter only if this object is retrieving a metric and not performing a math expression on returned data. Within one MetricDataQuery object, you must specify eitherExpression
orMetricStat
but not both.period (
Union
[int
,float
,None
]) – The granularity, in seconds, of the returned data points. For metrics with regular resolution, a period can be as short as one minute (60 seconds) and must be a multiple of 60. For high-resolution metrics that are collected at intervals of less than one minute, the period can be 1, 5, 10, 30, 60, or any multiple of 60. High-resolution metrics are those metrics stored by aPutMetricData
operation that includes aStorageResolution of 1 second
.return_data (
Union
[bool
,IResolvable
,None
]) – This option indicates whether to return the timestamps and raw data values of this metric. When you create an alarm based on a metric math expression, specifyTrue
for this value for only the one math expression that the alarm is based on. You must specifyFalse
forReturnData
for all the other metrics and expressions used in the alarm. This field is required.
- Link:
- ExampleMetadata:
fixture=_generated
Example:
# The code below shows an example of how to instantiate this type. # The values are placeholders you should change. import aws_cdk.aws_cloudwatch as cloudwatch metric_data_query_property = cloudwatch.CfnAlarm.MetricDataQueryProperty( id="id", # the properties below are optional account_id="accountId", expression="expression", label="label", metric_stat=cloudwatch.CfnAlarm.MetricStatProperty( metric=cloudwatch.CfnAlarm.MetricProperty( dimensions=[cloudwatch.CfnAlarm.DimensionProperty( name="name", value="value" )], metric_name="metricName", namespace="namespace" ), period=123, stat="stat", # the properties below are optional unit="unit" ), period=123, return_data=False )
Attributes
- account_id
The ID of the account where the metrics are located, if this is a cross-account alarm.
- expression
The math expression to be performed on the returned data, if this object is performing a math expression.
This expression can use the
Id
of the other metrics to refer to those metrics, and can also use theId
of other expressions to use the result of those expressions. For more information about metric math expressions, see Metric Math Syntax and Functions in the Amazon CloudWatch User Guide .Within each MetricDataQuery object, you must specify either
Expression
orMetricStat
but not both.
- id
A short name used to tie this object to the results in the response.
This name must be unique within a single call to
GetMetricData
. If you are performing math expressions on this set of data, this name represents that data and can serve as a variable in the mathematical expression. The valid characters are letters, numbers, and underscore. The first character must be a lowercase letter.
- label
A human-readable label for this metric or expression.
This is especially useful if this is an expression, so that you know what the value represents. If the metric or expression is shown in a CloudWatch dashboard widget, the label is shown. If
Label
is omitted, CloudWatch generates a default.
- metric_stat
The metric to be returned, along with statistics, period, and units.
Use this parameter only if this object is retrieving a metric and not performing a math expression on returned data.
Within one MetricDataQuery object, you must specify either
Expression
orMetricStat
but not both.
- period
The granularity, in seconds, of the returned data points.
For metrics with regular resolution, a period can be as short as one minute (60 seconds) and must be a multiple of 60. For high-resolution metrics that are collected at intervals of less than one minute, the period can be 1, 5, 10, 30, 60, or any multiple of 60. High-resolution metrics are those metrics stored by a
PutMetricData
operation that includes aStorageResolution of 1 second
.
- return_data
This option indicates whether to return the timestamps and raw data values of this metric.
When you create an alarm based on a metric math expression, specify
True
for this value for only the one math expression that the alarm is based on. You must specifyFalse
forReturnData
for all the other metrics and expressions used in the alarm.This field is required.
MetricProperty
- class CfnAlarm.MetricProperty(*, dimensions=None, metric_name=None, namespace=None)
Bases:
object
The
Metric
property type represents a specific metric.Metric
is a property of the MetricStat property type.- Parameters:
dimensions (
Union
[IResolvable
,Sequence
[Union
[IResolvable
,DimensionProperty
,Dict
[str
,Any
]]],None
]) – The metric dimensions that you want to be used for the metric that the alarm will watch.metric_name (
Optional
[str
]) – The name of the metric that you want the alarm to watch. This is a required field.namespace (
Optional
[str
]) – The namespace of the metric that the alarm will watch.
- Link:
- ExampleMetadata:
fixture=_generated
Example:
# The code below shows an example of how to instantiate this type. # The values are placeholders you should change. import aws_cdk.aws_cloudwatch as cloudwatch metric_property = cloudwatch.CfnAlarm.MetricProperty( dimensions=[cloudwatch.CfnAlarm.DimensionProperty( name="name", value="value" )], metric_name="metricName", namespace="namespace" )
Attributes
- dimensions
The metric dimensions that you want to be used for the metric that the alarm will watch.
- metric_name
The name of the metric that you want the alarm to watch.
This is a required field.
- namespace
The namespace of the metric that the alarm will watch.
MetricStatProperty
- class CfnAlarm.MetricStatProperty(*, metric, period, stat, unit=None)
Bases:
object
This structure defines the metric to be returned, along with the statistics, period, and units.
MetricStat
is a property of the MetricDataQuery property type.- Parameters:
metric (
Union
[IResolvable
,MetricProperty
,Dict
[str
,Any
]]) – The metric to return, including the metric name, namespace, and dimensions.period (
Union
[int
,float
]) – The granularity, in seconds, of the returned data points. For metrics with regular resolution, a period can be as short as one minute (60 seconds) and must be a multiple of 60. For high-resolution metrics that are collected at intervals of less than one minute, the period can be 1, 5, 10, 30, 60, or any multiple of 60. High-resolution metrics are those metrics stored by aPutMetricData
call that includes aStorageResolution
of 1 second. If theStartTime
parameter specifies a time stamp that is greater than 3 hours ago, you must specify the period as follows or no data points in that time range is returned: - Start time between 3 hours and 15 days ago - Use a multiple of 60 seconds (1 minute). - Start time between 15 and 63 days ago - Use a multiple of 300 seconds (5 minutes). - Start time greater than 63 days ago - Use a multiple of 3600 seconds (1 hour).stat (
str
) – The statistic to return. It can include any CloudWatch statistic or extended statistic. For a list of valid values, see the table in Statistics in the Amazon CloudWatch User Guide .unit (
Optional
[str
]) – The unit to use for the returned data points. Valid values are: 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.
- Link:
- ExampleMetadata:
fixture=_generated
Example:
# The code below shows an example of how to instantiate this type. # The values are placeholders you should change. import aws_cdk.aws_cloudwatch as cloudwatch metric_stat_property = cloudwatch.CfnAlarm.MetricStatProperty( metric=cloudwatch.CfnAlarm.MetricProperty( dimensions=[cloudwatch.CfnAlarm.DimensionProperty( name="name", value="value" )], metric_name="metricName", namespace="namespace" ), period=123, stat="stat", # the properties below are optional unit="unit" )
Attributes
- metric
The metric to return, including the metric name, namespace, and dimensions.
- period
The granularity, in seconds, of the returned data points.
For metrics with regular resolution, a period can be as short as one minute (60 seconds) and must be a multiple of 60. For high-resolution metrics that are collected at intervals of less than one minute, the period can be 1, 5, 10, 30, 60, or any multiple of 60. High-resolution metrics are those metrics stored by a
PutMetricData
call that includes aStorageResolution
of 1 second.If the
StartTime
parameter specifies a time stamp that is greater than 3 hours ago, you must specify the period as follows or no data points in that time range is returned:Start time between 3 hours and 15 days ago - Use a multiple of 60 seconds (1 minute).
Start time between 15 and 63 days ago - Use a multiple of 300 seconds (5 minutes).
Start time greater than 63 days ago - Use a multiple of 3600 seconds (1 hour).
- stat
The statistic to return.
It can include any CloudWatch statistic or extended statistic. For a list of valid values, see the table in Statistics in the Amazon CloudWatch User Guide .
- unit
The unit to use for the returned data points.
Valid values are: 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.