@Stability(value=Experimental)
See: Description
| Interface | Description |
|---|---|
| AlarmActionConfig |
Properties for an alarm action.
|
| AlarmProps |
Properties for Alarms.
|
| AlarmWidgetProps |
Properties for an AlarmWidget.
|
| CfnAlarm.DimensionProperty | |
| CfnAlarm.MetricDataQueryProperty | |
| CfnAlarm.MetricProperty | |
| CfnAlarm.MetricStatProperty | |
| CfnAlarmProps |
Properties for defining a `AWS::CloudWatch::Alarm`.
|
| CfnDashboardProps |
Properties for defining a `AWS::CloudWatch::Dashboard`.
|
| CommonMetricOptions |
Options shared by most methods accepting metric options.
|
| CreateAlarmOptions |
Properties needed to make an alarm from a metric.
|
| DashboardProps |
EXPERIMENTAL
|
| Dimension |
Metric dimension.
|
| GraphWidgetProps |
Properties for a GraphWidget.
|
| HorizontalAnnotation |
Horizontal annotation to be added to a graph.
|
| IAlarm |
EXPERIMENTAL
|
| IAlarmAction |
Interface for objects that can be the targets of CloudWatch alarm actions.
|
| IMetric |
Interface for metrics.
|
| IWidget |
A single dashboard widget.
|
| MetricAlarmConfig |
Properties used to construct the Metric identifying part of an Alarm.
|
| MetricGraphConfig |
Properties used to construct the Metric identifying part of a Graph.
|
| MetricOptions |
Properties of a metric that can be changed.
|
| MetricProps |
Properties for a metric.
|
| MetricWidgetProps |
Basic properties for widgets that display metrics.
|
| SingleValueWidgetProps |
Properties for a SingleValueWidget.
|
| SpacerProps |
Props of the spacer.
|
| TextWidgetProps |
Properties for a Text widget.
|
| YAxisProps |
Properties for a Y-Axis.
|
| Class | Description |
|---|---|
| Alarm |
An alarm on a CloudWatch metric.
|
| AlarmActionConfig.Builder |
A builder for
AlarmActionConfig |
| AlarmActionConfig.Jsii$Proxy |
A proxy class which represents a concrete javascript instance of this type.
|
| AlarmProps.Builder |
A builder for
AlarmProps |
| AlarmProps.Jsii$Proxy |
A proxy class which represents a concrete javascript instance of this type.
|
| AlarmWidget |
Display the metric associated with an alarm, including the alarm line.
|
| AlarmWidgetProps.Builder |
A builder for
AlarmWidgetProps |
| AlarmWidgetProps.Jsii$Proxy |
A proxy class which represents a concrete javascript instance of this type.
|
| CfnAlarm |
A CloudFormation `AWS::CloudWatch::Alarm`.
|
| CfnAlarm.DimensionProperty.Builder |
A builder for
CfnAlarm.DimensionProperty |
| CfnAlarm.DimensionProperty.Jsii$Proxy |
A proxy class which represents a concrete javascript instance of this type.
|
| CfnAlarm.MetricDataQueryProperty.Builder |
A builder for
CfnAlarm.MetricDataQueryProperty |
| CfnAlarm.MetricDataQueryProperty.Jsii$Proxy |
A proxy class which represents a concrete javascript instance of this type.
|
| CfnAlarm.MetricProperty.Builder |
A builder for
CfnAlarm.MetricProperty |
| CfnAlarm.MetricProperty.Jsii$Proxy |
A proxy class which represents a concrete javascript instance of this type.
|
| CfnAlarm.MetricStatProperty.Builder |
A builder for
CfnAlarm.MetricStatProperty |
| CfnAlarm.MetricStatProperty.Jsii$Proxy |
A proxy class which represents a concrete javascript instance of this type.
|
| CfnAlarmProps.Builder |
A builder for
CfnAlarmProps |
| CfnAlarmProps.Jsii$Proxy |
A proxy class which represents a concrete javascript instance of this type.
|
| CfnDashboard |
A CloudFormation `AWS::CloudWatch::Dashboard`.
|
| CfnDashboardProps.Builder |
A builder for
CfnDashboardProps |
| CfnDashboardProps.Jsii$Proxy |
A proxy class which represents a concrete javascript instance of this type.
|
| Column |
A widget that contains other widgets in a vertical column.
|
| CommonMetricOptions.Builder |
A builder for
CommonMetricOptions |
| CommonMetricOptions.Jsii$Proxy |
A proxy class which represents a concrete javascript instance of this type.
|
| ConcreteWidget |
A real CloudWatch widget that has its own fixed size and remembers its position.
|
| CreateAlarmOptions.Builder |
A builder for
CreateAlarmOptions |
| CreateAlarmOptions.Jsii$Proxy |
A proxy class which represents a concrete javascript instance of this type.
|
| Dashboard |
A CloudWatch dashboard.
|
| DashboardProps.Builder |
A builder for
DashboardProps |
| DashboardProps.Jsii$Proxy |
A proxy class which represents a concrete javascript instance of this type.
|
| Dimension.Builder |
A builder for
Dimension |
| Dimension.Jsii$Proxy |
A proxy class which represents a concrete javascript instance of this type.
|
| GraphWidget |
A dashboard widget that displays metrics.
|
| GraphWidgetProps.Builder |
A builder for
GraphWidgetProps |
| GraphWidgetProps.Jsii$Proxy |
A proxy class which represents a concrete javascript instance of this type.
|
| HorizontalAnnotation.Builder |
A builder for
HorizontalAnnotation |
| HorizontalAnnotation.Jsii$Proxy |
A proxy class which represents a concrete javascript instance of this type.
|
| IAlarm.Jsii$Proxy |
A proxy class which represents a concrete javascript instance of this type.
|
| IAlarmAction.Jsii$Proxy |
A proxy class which represents a concrete javascript instance of this type.
|
| IMetric.Jsii$Proxy |
A proxy class which represents a concrete javascript instance of this type.
|
| IWidget.Jsii$Proxy |
A proxy class which represents a concrete javascript instance of this type.
|
| Metric |
A metric emitted by a service.
|
| MetricAlarmConfig.Builder |
A builder for
MetricAlarmConfig |
| MetricAlarmConfig.Jsii$Proxy |
A proxy class which represents a concrete javascript instance of this type.
|
| MetricGraphConfig.Builder |
A builder for
MetricGraphConfig |
| MetricGraphConfig.Jsii$Proxy |
A proxy class which represents a concrete javascript instance of this type.
|
| MetricOptions.Builder |
A builder for
MetricOptions |
| MetricOptions.Jsii$Proxy |
A proxy class which represents a concrete javascript instance of this type.
|
| MetricProps.Builder |
A builder for
MetricProps |
| MetricProps.Jsii$Proxy |
A proxy class which represents a concrete javascript instance of this type.
|
| MetricWidgetProps.Builder |
A builder for
MetricWidgetProps |
| MetricWidgetProps.Jsii$Proxy |
A proxy class which represents a concrete javascript instance of this type.
|
| Row |
A widget that contains other widgets in a horizontal row.
|
| SingleValueWidget |
A dashboard widget that displays the most recent value for every metric.
|
| SingleValueWidgetProps.Builder |
A builder for
SingleValueWidgetProps |
| SingleValueWidgetProps.Jsii$Proxy |
A proxy class which represents a concrete javascript instance of this type.
|
| Spacer |
A widget that doesn't display anything but takes up space.
|
| SpacerProps.Builder |
A builder for
SpacerProps |
| SpacerProps.Jsii$Proxy |
A proxy class which represents a concrete javascript instance of this type.
|
| TextWidget |
A dashboard widget that displays MarkDown.
|
| TextWidgetProps.Builder |
A builder for
TextWidgetProps |
| TextWidgetProps.Jsii$Proxy |
A proxy class which represents a concrete javascript instance of this type.
|
| YAxisProps.Builder |
A builder for
YAxisProps |
| YAxisProps.Jsii$Proxy |
A proxy class which represents a concrete javascript instance of this type.
|
| Enum | Description |
|---|---|
| ComparisonOperator |
Comparison operator for evaluating alarms.
|
| PeriodOverride |
EXPERIMENTAL
|
| Shading |
EXPERIMENTAL
|
| Statistic |
Statistic to use over the aggregation period.
|
| TreatMissingData |
Specify how missing data points are treated during alarm evaluation.
|
| Unit |
Unit for metric.
|
This is a developer preview (public beta) module. Releases might lack important features and might have future breaking changes.
This API is still under active development and subject to non-backward compatible changes or removal in any future version. Use of the API is not recommended in production environments. Experimental APIs are not subject to the Semantic Versioning model.
Metric objects represent a metric that is emitted by AWS services or your own
application, such as CPUUsage, FailureCount or Bandwidth.
Metric objects can be constructed directly or are exposed by resources as
attributes. Resources that expose metrics will have functions that look
like metricXxx() which will return a Metric object, initialized with defaults
that make sense.
For example, lambda.Function objects have the fn.metricErrors() method, which
represents the amount of errors reported by that Lambda function:
const errors = fn.metricErrors();
To graph or alarm on metrics you must aggregate them first, using a function
like Average or a percentile function like P99. By default, most Metric objects
returned by CDK libraries will be configured as Average over 300 seconds (5 minutes).
The exception is if the metric represents a count of discrete events, such as
failures. In that case, the Metric object will be configured as Sum over 300 seconds, i.e. it represents the number of times that event occurred over the
time period.
If you want to change the default aggregation of the Metric object (for example, the function or the period), you can do so by passing additional parameters to the metric function call:
const minuteErrorRate = fn.metricErrors({
statistic: 'avg',
periodSec: 60,
label: 'Lambda failure rate'
});
This function also allows changing the metric label or color (which will be useful when embedding them in graphs, see below).
Rates versus Sums
The reason for using
Sumto count discrete events is that some events are emitted as either0or1(for exampleErrorsfor a Lambda) and some are only emitted as1(for exampleNumberOfMessagesPublishedfor an SNS topic).In case
0-metrics are emitted, it makes sense to take theAverageof this metric: the result will be the fraction of errors over all executions.If
0-metrics are not emitted, theAveragewill always be equal to1, and not be very useful.In order to simplify the mental model of
Metricobjects, we default to aggregating usingSum, which will be the same for both metrics types. If you happen to know the Metric you want to alarm on makes sense as a rate (Average) you can always choose to change the statistic.
Alarms can be created on metrics in one of two ways. Either create an Alarm
object, passing the Metric object to set the alarm on:
new Alarm(this, 'Alarm', {
metric: fn.metricErrors(),
threshold: 100,
evaluationPeriods: 2,
});
Alternatively, you can call metric.newAlarm():
fn.metricErrors().newAlarm(this, 'Alarm', {
threshold: 100,
evaluationPeriods: 2,
});
The most important properties to set while creating an Alarms are:
threshold: the value to compare the metric against.comparisonOperator: the comparison operation to use, defaults to metric >= threshold.evaluationPeriods: how many consecutive periods the metric has to be
breaching the the threshold for the alarm to trigger.Dashboards are set of Widgets stored server-side which can be accessed quickly from the AWS console. Available widgets are graphs of a metric over time, the current value of a metric, or a static piece of Markdown which explains what the graphs mean.
The following widgets are available:
GraphWidget -- shows any number of metrics on both the left and right
vertical axes.AlarmWidget -- shows the graph and alarm line for a single alarm.SingleValueWidget -- shows the current value of a set of metrics.TextWidget -- shows some static Markdown.A graph widget can display any number of metrics on either the left or
right vertical axis:
dashboard.add(new GraphWidget({
title: "Executions vs error rate",
left: [executionCountMetric],
right: [errorCountMetric.with({
statistic: "average",
label: "Error rate",
color: "00FF00"
})]
}));
An alarm widget shows the graph and the alarm line of a single alarm:
dashboard.add(new AlarmWidget({
title: "Errors",
alarm: errorAlarm,
}));
A single-value widget shows the latest value of a set of metrics (as opposed to a graph of the value over time):
dashboard.add(new SingleValueWidget({
metrics: [visitorCount, purchaseCount],
}));
A text widget shows an arbitrary piece of MarkDown. Use this to add explanations to your dashboard:
dashboard.add(new TextWidget({
markdown: '# Key Performance Indicators'
}));
The widgets on a dashboard are visually laid out in a grid that is 24 columns wide. Normally you specify X and Y coordinates for the widgets on a Dashboard, but because this is inconvenient to do manually, the library contains a simple layout system to help you lay out your dashboards the way you want them to.
Widgets have a width and height property, and they will be automatically
laid out either horizontally or vertically stacked to fill out the available
space.
Widgets are added to a Dashboard by calling add(widget1, widget2, ...).
Widgets given in the same call will be laid out horizontally. Widgets given
in different calls will be laid out vertically. To make more complex layouts,
you can use the following widgets to pack widgets together in different ways:
Column: stack two or more widgets vertically.Row: lay out two or more widgets horizontally.Spacer: take up empty spaceCopyright © 2019. All rights reserved.