MathExpression¶
-
class
aws_cdk.aws_cloudwatch.
MathExpression
(*, expression, using_metrics, color=None, label=None, period=None)¶ Bases:
object
A math expression built with metric(s) emitted by a service.
The math expression is a combination of an expression (x+y) and metrics to apply expression on. It also contains metadata which is used only in graphs, such as color and label. It makes sense to embed this in here, so that compound constructs can attach that metadata to metrics they expose.
This class does not represent a resource, so hence is not a construct. Instead, MathExpression is an abstraction that makes it easy to specify metrics for use in both alarms and graphs.
- Parameters
expression (
str
) – The expression defining the metric.using_metrics (
Mapping
[str
,IMetric
]) – The metrics used in the expression, in a map. The key is the identifier that represents the given metric in the expression, and the value is the actual Metric object.color (
Optional
[str
]) – Color for this metric when added to a Graph in a Dashboard. Default: - Automatic colorlabel (
Optional
[str
]) – Label for this metric when added to a Graph in a Dashboard. Default: - Expression value is used as labelperiod (
Optional
[Duration
]) – The period over which the expression’s statistics are applied. This period overrides all periods in the metrics used in this math expression. Default: Duration.minutes(5)
Methods
-
create_alarm
(scope, id, *, evaluation_periods, threshold, actions_enabled=None, alarm_description=None, alarm_name=None, comparison_operator=None, datapoints_to_alarm=None, evaluate_low_sample_count_percentile=None, period=None, statistic=None, treat_missing_data=None)¶ Make a new Alarm for this metric.
Combines both properties that may adjust the metric (aggregation) as well as alarm properties.
- Parameters
scope (
Construct
) –id (
str
) –evaluation_periods (
Union
[int
,float
]) – The number of periods over which data is compared to the specified threshold.threshold (
Union
[int
,float
]) – The value against which the specified statistic is compared.actions_enabled (
Optional
[bool
]) – Whether the actions for this alarm are enabled. Default: truealarm_description (
Optional
[str
]) – Description for the alarm. Default: No descriptionalarm_name (
Optional
[str
]) – Name of the alarm. Default: Automatically generated namecomparison_operator (
Optional
[ComparisonOperator
]) – Comparison to use to check if metric is breaching. Default: GreaterThanOrEqualToThresholddatapoints_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. For more information, see Evaluating an Alarm in the Amazon CloudWatch User Guide. Default:evaluationPeriods
evaluate_low_sample_count_percentile (
Optional
[str
]) – 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. Default: - Not configured.period (
Optional
[Duration
]) – (deprecated) The period over which the specified statistic is applied. Cannot be used withMathExpression
objects. Default: - The period from the metricstatistic (
Optional
[str
]) – (deprecated) What function to use for aggregating. Can be one of the following: - “Minimum” | “min” - “Maximum” | “max” - “Average” | “avg” - “Sum” | “sum” - “SampleCount | “n” - “pNN.NN” Cannot be used withMathExpression
objects. Default: - The statistic from the metrictreat_missing_data (
Optional
[TreatMissingData
]) – Sets how this alarm is to handle missing data points. Default: TreatMissingData.Missing
- Return type
-
to_alarm_config
()¶ Turn this metric object into an alarm configuration.
- Return type
-
to_graph_config
()¶ Turn this metric object into a graph configuration.
- Return type
-
to_metric_config
()¶ Inspect the details of the metric object.
- Return type
-
to_string
()¶ Returns a string representation of an object.
- Return type
str
-
with_
(*, color=None, label=None, period=None)¶ Return a copy of Metric with properties changed.
All properties except namespace and metricName can be changed.
- Parameters
color (
Optional
[str
]) – Color for this metric when added to a Graph in a Dashboard. Default: - Automatic colorlabel (
Optional
[str
]) – Label for this metric when added to a Graph in a Dashboard. Default: - Expression value is used as labelperiod (
Optional
[Duration
]) – The period over which the expression’s statistics are applied. This period overrides all periods in the metrics used in this math expression. Default: Duration.minutes(5)
- Return type
Attributes
-
color
¶ The hex color code, prefixed with ‘#’ (e.g. ‘#00ff00’), to use when this metric is rendered on a graph. The
Color
class has a set of standard colors that can be used here.- Return type
Optional
[str
]
-
expression
¶ The expression defining the metric.
- Return type
str
-
label
¶ Label for this metric when added to a Graph.
- Return type
Optional
[str
]