This documentation is for the developer preview release of the AWS CDK. Do not use this version of the AWS CDK in production. Subsequent releases of the AWS CDK will likely include breaking changes.

@aws-cdk/aws-cloudwatch

Metrics

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();

Aggregation

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 Sum to count discrete events is that some events are emitted as either 0 or 1 (for example Errors for a Lambda) and some are only emitted as 1 (for example NumberOfMessagesPublished for an SNS topic).

In case 0-metrics are emitted, it makes sense to take the Average of this metric: the result will be the fraction of errors over all executions.

If 0-metrics are not emitted, the Average will always be equal to 1, and not be very useful.

In order to simplify the mental model of Metric objects, we default to aggregating using Sum, 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

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

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.

Warning! Due to a bug in CloudFormation, you cannot update a Dashboard after initially creating it if you let its name automatically be generated. You must set dashboardName if you intend to update the dashboard after creation.

(This note will be removed once the bug is fixed).

Graph widget

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"
    })]
}));

Alarm widget

An alarm widget shows the graph and the alarm line of a single alarm:

dashboard.add(new AlarmWidget({
    title: "Errors",
    alarm: errorAlarm,
}));

Single value widget

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],
}));

Text widget

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'
}));

Dashboard Layout

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 space

Reference

View in Nuget

csproj:

<PackageReference Include="Amazon.CDK.AWS.CloudWatch" Version="0.25.3" />

dotnet:

dotnet add package Amazon.CDK.AWS.CloudWatch --version 0.25.3

packages.config:

<package id="Amazon.CDK.AWS.CloudWatch" version="0.25.3" />

View in Maven Central

Apache Buildr:

'software.amazon.awscdk:cloudwatch:jar:0.25.3'

Apache Ivy:

<dependency groupId="software.amazon.awscdk" name="cloudwatch" rev="0.25.3"/>

Apache Maven:

<dependency>
  <groupId>software.amazon.awscdk</groupId>
  <artifactId>cloudwatch</artifactId>
  <version>0.25.3</version>
</dependency>

Gradle / Grails:

compile 'software.amazon.awscdk:cloudwatch:0.25.3'

Groovy Grape:

@Grapes(
@Grab(group='software.amazon.awscdk', module='cloudwatch', version='0.25.3')
)

View in NPM

npm:

$ npm i @aws-cdk/aws-cloudwatch@0.25.3

package.json:

{
  "@aws-cdk/aws-cloudwatch": "^0.25.3"
}

yarn:

$ yarn add @aws-cdk/aws-cloudwatch@0.25.3

View in NPM

npm:

$ npm i @aws-cdk/aws-cloudwatch@0.25.3

package.json:

{
  "@aws-cdk/aws-cloudwatch": "^0.25.3"
}

yarn:

$ yarn add @aws-cdk/aws-cloudwatch@0.25.3

Alarm

class @aws-cdk/aws-cloudwatch.Alarm(scope, id, props)

Language-specific names:

using Amazon.CDK.AWS.CloudWatch;
import software.amazon.awscdk.services.cloudwatch.Alarm;
const { Alarm } = require('@aws-cdk/aws-cloudwatch');
import { Alarm } from '@aws-cdk/aws-cloudwatch';

An alarm on a CloudWatch metric

Extends:

@aws-cdk/cdk.Construct

Parameters:
onAlarm(*actions)

Trigger this action if the alarm fires

Typically the ARN of an SNS topic or ARN of an AutoScaling policy.

Parameters:*actions (IAlarmAction) –
onInsufficientData(*actions)

Trigger this action if there is insufficient data to evaluate the alarm

Typically the ARN of an SNS topic or ARN of an AutoScaling policy.

Parameters:*actions (IAlarmAction) –
onOk(*actions)

Trigger this action if the alarm returns from breaching state into ok state

Typically the ARN of an SNS topic or ARN of an AutoScaling policy.

Parameters:*actions (IAlarmAction) –
toAnnotation() → @aws-cdk/aws-cloudwatch.HorizontalAnnotation

Turn this alarm into a horizontal annotation

This is useful if you want to represent an Alarm in a non-AlarmWidget.

An AlarmWidget can directly show an alarm, but it can only show a

single alarm and no other metrics. Instead, you can convert the alarm to

a HorizontalAnnotation and add it as an annotation to another graph.

This might be useful if:

  • You want to show multiple alarms inside a single graph, for example if

    you have both a “small margin/long period” alarm as well as a

    “large margin/short period” alarm.

  • You want to show an Alarm line in a graph with multiple metrics in it.

Return type:HorizontalAnnotation
alarmArn

ARN of this alarm

Type:string (readonly)
alarmName

Name of this alarm.

Type:string (readonly)
metric

The metric object this alarm was based on

Type:Metric (readonly)
prepare()

Inherited from @aws-cdk/cdk.Construct

Perform final modifications before synthesis

This method can be implemented by derived constructs in order to perform

final changes before synthesis. prepare() will be called after child

constructs have been prepared.

This is an advanced framework feature. Only use this if you

understand the implications.

Protected method

toString() → string

Inherited from @aws-cdk/cdk.Construct

Returns a string representation of this construct.

Return type:string
validate() → string[]

Inherited from @aws-cdk/cdk.Construct

Validate the current construct.

This method can be implemented by derived constructs in order to perform

validation logic. It is called on all constructs before synthesis.

Protected method

Returns:An array of validation error messages, or an empty array if there the construct is valid.
Return type:string[]
dependencyRoots

Inherited from @aws-cdk/cdk.Construct

The set of constructs that form the root of this dependable

All resources under all returned constructs are included in the ordering

dependency.

Type:@aws-cdk/cdk.IConstruct[] (readonly)
node

Inherited from @aws-cdk/cdk.Construct

Construct node.

Type:@aws-cdk/cdk.ConstructNode (readonly)

AlarmMetricJson (interface)

class @aws-cdk/aws-cloudwatch.AlarmMetricJson

Language-specific names:

using Amazon.CDK.AWS.CloudWatch;
import software.amazon.awscdk.services.cloudwatch.AlarmMetricJson;
// AlarmMetricJson is an interface
import { AlarmMetricJson } from '@aws-cdk/aws-cloudwatch';

Properties used to construct the Metric identifying part of an Alarm

metricName

Name of the metric

Type:string
namespace

Namespace of the metric

Type:string
period

How many seconds to aggregate over

Type:number
dimensions

The dimensions to apply to the alarm

Type:Dimension[] (optional)
extendedStatistic

Percentile aggregation function to use

Type:string (optional)
statistic

Simple aggregation function to use

Type:Statistic (optional)
unit

The unit of the alarm

Type:Unit (optional)

AlarmProps (interface)

class @aws-cdk/aws-cloudwatch.AlarmProps

Language-specific names:

using Amazon.CDK.AWS.CloudWatch;
import software.amazon.awscdk.services.cloudwatch.AlarmProps;
// AlarmProps is an interface
import { AlarmProps } from '@aws-cdk/aws-cloudwatch';

Properties for Alarms

Extends:MetricAlarmProps
metric

The metric to add the alarm on

Metric objects can be obtained from most resources, or you can construct

custom Metric objects by instantiating one.

Type:Metric
evaluationPeriods

Inherited from @aws-cdk/aws-cloudwatch.MetricAlarmProps

The number of periods over which data is compared to the specified threshold.

Type:number
threshold

Inherited from @aws-cdk/aws-cloudwatch.MetricAlarmProps

The value against which the specified statistic is compared.

Type:number
actionsEnabled

Inherited from @aws-cdk/aws-cloudwatch.MetricAlarmProps

Whether the actions for this alarm are enabled

Type:boolean (optional)
Default:true
alarmDescription

Inherited from @aws-cdk/aws-cloudwatch.MetricAlarmProps

Description for the alarm

Type:string (optional)
Default:No description
alarmName

Inherited from @aws-cdk/aws-cloudwatch.MetricAlarmProps

Name of the alarm

Type:string (optional)
Default:Automatically generated name
comparisonOperator

Inherited from @aws-cdk/aws-cloudwatch.MetricAlarmProps

Comparison to use to check if metric is breaching

Type:ComparisonOperator (optional)
Default:GreaterThanOrEqualToThreshold
datapointsToAlarm

Inherited from @aws-cdk/aws-cloudwatch.MetricAlarmProps

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.

Type:number (optional)
Default:evaluationPeriods
evaluateLowSampleCountPercentile

Inherited from @aws-cdk/aws-cloudwatch.MetricAlarmProps

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.

Type:string (optional)
periodSec

Inherited from @aws-cdk/aws-cloudwatch.MetricAlarmProps

The period over which the specified statistic is applied.

Specify time in seconds, in multiples of 60.

Type:number (optional)
Default:300
statistic

Inherited from @aws-cdk/aws-cloudwatch.MetricAlarmProps

What function to use for aggregating.

Can be one of the following:

  • “Minimum” | “min”
  • “Maximum” | “max”
  • “Average” | “avg”
  • “Sum” | “sum”
  • “SampleCount | “n”
  • “pNN.NN”
Type:string (optional)
Default:Average
treatMissingData

Inherited from @aws-cdk/aws-cloudwatch.MetricAlarmProps

Sets how this alarm is to handle missing data points.

Type:TreatMissingData (optional)
Default:TreatMissingData.Missing

AlarmWidget

class @aws-cdk/aws-cloudwatch.AlarmWidget(props)

Language-specific names:

using Amazon.CDK.AWS.CloudWatch;
import software.amazon.awscdk.services.cloudwatch.AlarmWidget;
const { AlarmWidget } = require('@aws-cdk/aws-cloudwatch');
import { AlarmWidget } from '@aws-cdk/aws-cloudwatch';

Display the metric associated with an alarm, including the alarm line

Extends:ConcreteWidget
Parameters:props (AlarmWidgetProps) –
toJson() → any[]

Implements @aws-cdk/aws-cloudwatch.ConcreteWidget.toJson()

Return the widget JSON for use in the dashboard

Return type:any[]
position(x, y)

Inherited from @aws-cdk/aws-cloudwatch.ConcreteWidget

Place the widget at a given position

Parameters:
  • x (number) –
  • y (number) –
height

Inherited from @aws-cdk/aws-cloudwatch.ConcreteWidget

The amount of vertical grid units the widget will take up

Type:number (readonly)
width

Inherited from @aws-cdk/aws-cloudwatch.ConcreteWidget

The amount of horizontal grid units the widget will take up

Type:number (readonly)
x

Inherited from @aws-cdk/aws-cloudwatch.ConcreteWidget

Protected property

Type:number (optional)
y

Inherited from @aws-cdk/aws-cloudwatch.ConcreteWidget

Protected property

Type:number (optional)

AlarmWidgetProps (interface)

class @aws-cdk/aws-cloudwatch.AlarmWidgetProps

Language-specific names:

using Amazon.CDK.AWS.CloudWatch;
import software.amazon.awscdk.services.cloudwatch.AlarmWidgetProps;
// AlarmWidgetProps is an interface
import { AlarmWidgetProps } from '@aws-cdk/aws-cloudwatch';

Properties for an AlarmWidget

Extends:MetricWidgetProps
alarm

The alarm to show

Type:Alarm
leftAxisRange

Range of left Y axis

Type:YAxisRange (optional)
Default:0..automatic
height

Inherited from @aws-cdk/aws-cloudwatch.MetricWidgetProps

Height of the widget

Type:number (optional)
Default:Depends on the type of widget
region

Inherited from @aws-cdk/aws-cloudwatch.MetricWidgetProps

The region the metrics of this graph should be taken from

Type:string (optional)
Default:Current region
title

Inherited from @aws-cdk/aws-cloudwatch.MetricWidgetProps

Title for the graph

Type:string (optional)
width

Inherited from @aws-cdk/aws-cloudwatch.MetricWidgetProps

Width of the widget, in a grid of 24 units wide

Type:number (optional)
Default:6

CfnAlarm

class @aws-cdk/aws-cloudwatch.CfnAlarm(scope, id, props)

Language-specific names:

using Amazon.CDK.AWS.CloudWatch;
import software.amazon.awscdk.services.cloudwatch.CfnAlarm;
const { CfnAlarm } = require('@aws-cdk/aws-cloudwatch');
import { CfnAlarm } from '@aws-cdk/aws-cloudwatch';
Extends:

@aws-cdk/cdk.Resource

Parameters:
renderProperties(properties) → string => any

Overrides @aws-cdk/cdk.Resource.renderProperties()

Protected method

Parameters:properties (any) –
Return type:string => any
resourceTypeName

The CloudFormation resource type name for this resource class.

Type:string (readonly) (static)
alarmArn
Type:string (readonly)
alarmName
Type:string (readonly)
propertyOverrides
Type:CfnAlarmProps (readonly)
class DimensionProperty

Language-specific names:

using Amazon.CDK.AWS.CloudWatch;
import software.amazon.awscdk.services.cloudwatch.CfnAlarm.DimensionProperty;
// CfnAlarm.DimensionProperty is an interface
import { CfnAlarm.DimensionProperty } from '@aws-cdk/aws-cloudwatch';
name

CfnAlarm.DimensionProperty.Name

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-cw-dimension.html#cfn-cloudwatch-alarm-dimension-name

Type:string
value

CfnAlarm.DimensionProperty.Value

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-cw-dimension.html#cfn-cloudwatch-alarm-dimension-value

Type:string
class MetricDataQueryProperty

Language-specific names:

using Amazon.CDK.AWS.CloudWatch;
import software.amazon.awscdk.services.cloudwatch.CfnAlarm.MetricDataQueryProperty;
// CfnAlarm.MetricDataQueryProperty is an interface
import { CfnAlarm.MetricDataQueryProperty } from '@aws-cdk/aws-cloudwatch';
id

CfnAlarm.MetricDataQueryProperty.Id

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-cloudwatch-alarm-metricdataquery.html#cfn-cloudwatch-alarm-metricdataquery-id

Type:string
expression

CfnAlarm.MetricDataQueryProperty.Expression

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-cloudwatch-alarm-metricdataquery.html#cfn-cloudwatch-alarm-metricdataquery-expression

Type:string (optional)
label

CfnAlarm.MetricDataQueryProperty.Label

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-cloudwatch-alarm-metricdataquery.html#cfn-cloudwatch-alarm-metricdataquery-label

Type:string (optional)
metricStat

CfnAlarm.MetricDataQueryProperty.MetricStat

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-cloudwatch-alarm-metricdataquery.html#cfn-cloudwatch-alarm-metricdataquery-metricstat

Type:@aws-cdk/cdk.Token or MetricStatProperty (optional)
returnData

CfnAlarm.MetricDataQueryProperty.ReturnData

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-cloudwatch-alarm-metricdataquery.html#cfn-cloudwatch-alarm-metricdataquery-returndata

Type:boolean or @aws-cdk/cdk.Token (optional)
class MetricProperty

Language-specific names:

using Amazon.CDK.AWS.CloudWatch;
import software.amazon.awscdk.services.cloudwatch.CfnAlarm.MetricProperty;
// CfnAlarm.MetricProperty is an interface
import { CfnAlarm.MetricProperty } from '@aws-cdk/aws-cloudwatch';
dimensions

CfnAlarm.MetricProperty.Dimensions

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-cloudwatch-alarm-metric.html#cfn-cloudwatch-alarm-metric-dimensions

Type:@aws-cdk/cdk.Token or (@aws-cdk/cdk.Token or DimensionProperty)[] (optional)
metricName

CfnAlarm.MetricProperty.MetricName

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-cloudwatch-alarm-metric.html#cfn-cloudwatch-alarm-metric-metricname

Type:string (optional)
namespace

CfnAlarm.MetricProperty.Namespace

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-cloudwatch-alarm-metric.html#cfn-cloudwatch-alarm-metric-namespace

Type:string (optional)
class MetricStatProperty

Language-specific names:

using Amazon.CDK.AWS.CloudWatch;
import software.amazon.awscdk.services.cloudwatch.CfnAlarm.MetricStatProperty;
// CfnAlarm.MetricStatProperty is an interface
import { CfnAlarm.MetricStatProperty } from '@aws-cdk/aws-cloudwatch';
metric

CfnAlarm.MetricStatProperty.Metric

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-cloudwatch-alarm-metricstat.html#cfn-cloudwatch-alarm-metricstat-metric

Type:@aws-cdk/cdk.Token or MetricProperty
period

CfnAlarm.MetricStatProperty.Period

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-cloudwatch-alarm-metricstat.html#cfn-cloudwatch-alarm-metricstat-period

Type:number or @aws-cdk/cdk.Token
stat

CfnAlarm.MetricStatProperty.Stat

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-cloudwatch-alarm-metricstat.html#cfn-cloudwatch-alarm-metricstat-stat

Type:string
unit

CfnAlarm.MetricStatProperty.Unit

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-cloudwatch-alarm-metricstat.html#cfn-cloudwatch-alarm-metricstat-unit

Type:string (optional)
toString() → string

Inherited from @aws-cdk/cdk.Construct

Returns a string representation of this construct.

Return type:string
validate() → string[]

Inherited from @aws-cdk/cdk.Construct

Validate the current construct.

This method can be implemented by derived constructs in order to perform

validation logic. It is called on all constructs before synthesis.

Protected method

Returns:An array of validation error messages, or an empty array if there the construct is valid.
Return type:string[]
dependencyRoots

Inherited from @aws-cdk/cdk.Construct

The set of constructs that form the root of this dependable

All resources under all returned constructs are included in the ordering

dependency.

Type:@aws-cdk/cdk.IConstruct[] (readonly)
node

Inherited from @aws-cdk/cdk.Construct

Construct node.

Type:@aws-cdk/cdk.ConstructNode (readonly)
ref

Inherited from @aws-cdk/cdk.Referenceable

Returns a token to a CloudFormation { Ref } that references this entity based on it’s logical ID.

Type:string (readonly)
addDeletionOverride(path)

Inherited from @aws-cdk/cdk.Resource

Syntactic sugar for addOverride(path, undefined).

Parameters:path (string) – The path of the value to delete
addDependsOn(resource)

Inherited from @aws-cdk/cdk.Resource

Indicates that this resource depends on another resource and cannot be provisioned

unless the other resource has been successfully provisioned.

Parameters:resource (@aws-cdk/cdk.Resource) –
addOverride(path, value)

Inherited from @aws-cdk/cdk.Resource

Adds an override to the synthesized CloudFormation resource. To add a

property override, either use addPropertyOverride or prefix path with

“Properties.” (i.e. Properties.TopicName).

Parameters:
  • path (string) – 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.
addPropertyDeletionOverride(propertyPath)

Inherited from @aws-cdk/cdk.Resource

Adds an override that deletes the value of a property from the resource definition.

Parameters:propertyPath (string) – The path to the property.
addPropertyOverride(propertyPath, value)

Inherited from @aws-cdk/cdk.Resource

Adds an override to a resource property.

Syntactic sugar for addOverride(“Properties.<…>”, value).

Parameters:
  • propertyPath (string) – The path of the property
  • value (any) – The value
getAtt(attributeName) → @aws-cdk/cdk.CfnReference

Inherited from @aws-cdk/cdk.Resource

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:attributeName (string) – The name of the attribute.
Return type:@aws-cdk/cdk.CfnReference
toCloudFormation() → json

Inherited from @aws-cdk/cdk.Resource

Emits CloudFormation for this resource.

Return type:json
options

Inherited from @aws-cdk/cdk.Resource

Options for this resource, such as condition, update policy etc.

Type:@aws-cdk/cdk.ResourceOptions (readonly)
properties

Inherited from @aws-cdk/cdk.Resource

AWS resource properties.

This object is rendered via a call to “renderProperties(this.properties)”.

Protected property

Type:any (readonly)
resourceType

Inherited from @aws-cdk/cdk.Resource

AWS resource type.

Type:string (readonly)
untypedPropertyOverrides

Inherited from @aws-cdk/cdk.Resource

AWS resource property overrides.

During synthesis, the method “renderProperties(this.overrides)” is called

with this object, and merged on top of the output of

“renderProperties(this.properties)”.

Derived classes should expose a strongly-typed version of this object as

a public property called propertyOverrides.

Protected property

Type:any (readonly)
overrideLogicalId(newLogicalId)

Inherited from @aws-cdk/cdk.StackElement

Overrides the auto-generated logical ID with a specific ID.

Parameters:newLogicalId (string) – The new logical ID to use for this stack element.
prepare()

Inherited from @aws-cdk/cdk.StackElement

Automatically detect references in this StackElement

Protected method

creationStackTrace

Inherited from @aws-cdk/cdk.StackElement

Type:string[] (readonly)
logicalId

Inherited from @aws-cdk/cdk.StackElement

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).

Type:string (readonly)
stackPath

Inherited from @aws-cdk/cdk.StackElement

Return the path with respect to the stack

Type:string (readonly)

CfnAlarmProps (interface)

class @aws-cdk/aws-cloudwatch.CfnAlarmProps

Language-specific names:

using Amazon.CDK.AWS.CloudWatch;
import software.amazon.awscdk.services.cloudwatch.CfnAlarmProps;
// CfnAlarmProps is an interface
import { CfnAlarmProps } from '@aws-cdk/aws-cloudwatch';
comparisonOperator

AWS::CloudWatch::Alarm.ComparisonOperator

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-cw-alarm.html#cfn-cloudwatch-alarms-comparisonoperator

Type:string
evaluationPeriods

AWS::CloudWatch::Alarm.EvaluationPeriods

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-cw-alarm.html#cfn-cloudwatch-alarms-evaluationperiods

Type:number or @aws-cdk/cdk.Token
threshold

AWS::CloudWatch::Alarm.Threshold

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-cw-alarm.html#cfn-cloudwatch-alarms-threshold

Type:number or @aws-cdk/cdk.Token
actionsEnabled

AWS::CloudWatch::Alarm.ActionsEnabled

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-cw-alarm.html#cfn-cloudwatch-alarms-actionsenabled

Type:boolean or @aws-cdk/cdk.Token (optional)
alarmActions

AWS::CloudWatch::Alarm.AlarmActions

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-cw-alarm.html#cfn-cloudwatch-alarms-alarmactions

Type:@aws-cdk/cdk.Token or (string or @aws-cdk/cdk.Token)[] (optional)
alarmDescription

AWS::CloudWatch::Alarm.AlarmDescription

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-cw-alarm.html#cfn-cloudwatch-alarms-alarmdescription

Type:string (optional)
alarmName

AWS::CloudWatch::Alarm.AlarmName

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-cw-alarm.html#cfn-cloudwatch-alarms-alarmname

Type:string (optional)
datapointsToAlarm

AWS::CloudWatch::Alarm.DatapointsToAlarm

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-cw-alarm.html#cfn-cloudwatch-alarm-datapointstoalarm

Type:number or @aws-cdk/cdk.Token (optional)
dimensions

AWS::CloudWatch::Alarm.Dimensions

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-cw-alarm.html#cfn-cloudwatch-alarms-dimension

Type:@aws-cdk/cdk.Token or (@aws-cdk/cdk.Token or DimensionProperty)[] (optional)
evaluateLowSampleCountPercentile

AWS::CloudWatch::Alarm.EvaluateLowSampleCountPercentile

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-cw-alarm.html#cfn-cloudwatch-alarms-evaluatelowsamplecountpercentile

Type:string (optional)
extendedStatistic

AWS::CloudWatch::Alarm.ExtendedStatistic

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-cw-alarm.html#cfn-cloudwatch-alarms-extendedstatistic

Type:string (optional)
insufficientDataActions

AWS::CloudWatch::Alarm.InsufficientDataActions

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-cw-alarm.html#cfn-cloudwatch-alarms-insufficientdataactions

Type:@aws-cdk/cdk.Token or (string or @aws-cdk/cdk.Token)[] (optional)
metricName

AWS::CloudWatch::Alarm.MetricName

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-cw-alarm.html#cfn-cloudwatch-alarms-metricname

Type:string (optional)
metrics

AWS::CloudWatch::Alarm.Metrics

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-cw-alarm.html#cfn-cloudwatch-alarm-metrics

Type:@aws-cdk/cdk.Token or (@aws-cdk/cdk.Token or MetricDataQueryProperty)[] (optional)
namespace

AWS::CloudWatch::Alarm.Namespace

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-cw-alarm.html#cfn-cloudwatch-alarms-namespace

Type:string (optional)
okActions

AWS::CloudWatch::Alarm.OKActions

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-cw-alarm.html#cfn-cloudwatch-alarms-okactions

Type:@aws-cdk/cdk.Token or (string or @aws-cdk/cdk.Token)[] (optional)
period

AWS::CloudWatch::Alarm.Period

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-cw-alarm.html#cfn-cloudwatch-alarms-period

Type:number or @aws-cdk/cdk.Token (optional)
statistic

AWS::CloudWatch::Alarm.Statistic

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-cw-alarm.html#cfn-cloudwatch-alarms-statistic

Type:string (optional)
treatMissingData

AWS::CloudWatch::Alarm.TreatMissingData

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-cw-alarm.html#cfn-cloudwatch-alarms-treatmissingdata

Type:string (optional)
unit

AWS::CloudWatch::Alarm.Unit

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-cw-alarm.html#cfn-cloudwatch-alarms-unit

Type:string (optional)

CfnDashboard

class @aws-cdk/aws-cloudwatch.CfnDashboard(scope, id, props)

Language-specific names:

using Amazon.CDK.AWS.CloudWatch;
import software.amazon.awscdk.services.cloudwatch.CfnDashboard;
const { CfnDashboard } = require('@aws-cdk/aws-cloudwatch');
import { CfnDashboard } from '@aws-cdk/aws-cloudwatch';
Extends:

@aws-cdk/cdk.Resource

Parameters:
renderProperties(properties) → string => any

Overrides @aws-cdk/cdk.Resource.renderProperties()

Protected method

Parameters:properties (any) –
Return type:string => any
resourceTypeName

The CloudFormation resource type name for this resource class.

Type:string (readonly) (static)
dashboardName
Type:string (readonly)
propertyOverrides
Type:CfnDashboardProps (readonly)
toString() → string

Inherited from @aws-cdk/cdk.Construct

Returns a string representation of this construct.

Return type:string
validate() → string[]

Inherited from @aws-cdk/cdk.Construct

Validate the current construct.

This method can be implemented by derived constructs in order to perform

validation logic. It is called on all constructs before synthesis.

Protected method

Returns:An array of validation error messages, or an empty array if there the construct is valid.
Return type:string[]
dependencyRoots

Inherited from @aws-cdk/cdk.Construct

The set of constructs that form the root of this dependable

All resources under all returned constructs are included in the ordering

dependency.

Type:@aws-cdk/cdk.IConstruct[] (readonly)
node

Inherited from @aws-cdk/cdk.Construct

Construct node.

Type:@aws-cdk/cdk.ConstructNode (readonly)
ref

Inherited from @aws-cdk/cdk.Referenceable

Returns a token to a CloudFormation { Ref } that references this entity based on it’s logical ID.

Type:string (readonly)
addDeletionOverride(path)

Inherited from @aws-cdk/cdk.Resource

Syntactic sugar for addOverride(path, undefined).

Parameters:path (string) – The path of the value to delete
addDependsOn(resource)

Inherited from @aws-cdk/cdk.Resource

Indicates that this resource depends on another resource and cannot be provisioned

unless the other resource has been successfully provisioned.

Parameters:resource (@aws-cdk/cdk.Resource) –
addOverride(path, value)

Inherited from @aws-cdk/cdk.Resource

Adds an override to the synthesized CloudFormation resource. To add a

property override, either use addPropertyOverride or prefix path with

“Properties.” (i.e. Properties.TopicName).

Parameters:
  • path (string) – 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.
addPropertyDeletionOverride(propertyPath)

Inherited from @aws-cdk/cdk.Resource

Adds an override that deletes the value of a property from the resource definition.

Parameters:propertyPath (string) – The path to the property.
addPropertyOverride(propertyPath, value)

Inherited from @aws-cdk/cdk.Resource

Adds an override to a resource property.

Syntactic sugar for addOverride(“Properties.<…>”, value).

Parameters:
  • propertyPath (string) – The path of the property
  • value (any) – The value
getAtt(attributeName) → @aws-cdk/cdk.CfnReference

Inherited from @aws-cdk/cdk.Resource

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:attributeName (string) – The name of the attribute.
Return type:@aws-cdk/cdk.CfnReference
toCloudFormation() → json

Inherited from @aws-cdk/cdk.Resource

Emits CloudFormation for this resource.

Return type:json
options

Inherited from @aws-cdk/cdk.Resource

Options for this resource, such as condition, update policy etc.

Type:@aws-cdk/cdk.ResourceOptions (readonly)
properties

Inherited from @aws-cdk/cdk.Resource

AWS resource properties.

This object is rendered via a call to “renderProperties(this.properties)”.

Protected property

Type:any (readonly)
resourceType

Inherited from @aws-cdk/cdk.Resource

AWS resource type.

Type:string (readonly)
untypedPropertyOverrides

Inherited from @aws-cdk/cdk.Resource

AWS resource property overrides.

During synthesis, the method “renderProperties(this.overrides)” is called

with this object, and merged on top of the output of

“renderProperties(this.properties)”.

Derived classes should expose a strongly-typed version of this object as

a public property called propertyOverrides.

Protected property

Type:any (readonly)
overrideLogicalId(newLogicalId)

Inherited from @aws-cdk/cdk.StackElement

Overrides the auto-generated logical ID with a specific ID.

Parameters:newLogicalId (string) – The new logical ID to use for this stack element.
prepare()

Inherited from @aws-cdk/cdk.StackElement

Automatically detect references in this StackElement

Protected method

creationStackTrace

Inherited from @aws-cdk/cdk.StackElement

Type:string[] (readonly)
logicalId

Inherited from @aws-cdk/cdk.StackElement

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).

Type:string (readonly)
stackPath

Inherited from @aws-cdk/cdk.StackElement

Return the path with respect to the stack

Type:string (readonly)

CfnDashboardProps (interface)

class @aws-cdk/aws-cloudwatch.CfnDashboardProps

Language-specific names:

using Amazon.CDK.AWS.CloudWatch;
import software.amazon.awscdk.services.cloudwatch.CfnDashboardProps;
// CfnDashboardProps is an interface
import { CfnDashboardProps } from '@aws-cdk/aws-cloudwatch';
dashboardBody

AWS::CloudWatch::Dashboard.DashboardBody

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-cloudwatch-dashboard.html#cfn-cloudwatch-dashboard-dashboardbody

Type:string
dashboardName

AWS::CloudWatch::Dashboard.DashboardName

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-cloudwatch-dashboard.html#cfn-cloudwatch-dashboard-dashboardname

Type:string (optional)

Column

class @aws-cdk/aws-cloudwatch.Column(*widgets)

Language-specific names:

using Amazon.CDK.AWS.CloudWatch;
import software.amazon.awscdk.services.cloudwatch.Column;
const { Column } = require('@aws-cdk/aws-cloudwatch');
import { Column } from '@aws-cdk/aws-cloudwatch';

A widget that contains other widgets in a vertical column

Widgets will be laid out next to each other

Implements:IWidget
Parameters:*widgets (IWidget) –
position(x, y)

Implements @aws-cdk/aws-cloudwatch.IWidget.position()

Place the widget at a given position

Parameters:
  • x (number) –
  • y (number) –
toJson() → any[]

Implements @aws-cdk/aws-cloudwatch.IWidget.toJson()

Return the widget JSON for use in the dashboard

Return type:any[]
height

Implements @aws-cdk/aws-cloudwatch.IWidget.height()

The amount of vertical grid units the widget will take up

Type:number (readonly)
width

Implements @aws-cdk/aws-cloudwatch.IWidget.width()

The amount of horizontal grid units the widget will take up

Type:number (readonly)

ComparisonOperator (enum)

class @aws-cdk/aws-cloudwatch.ComparisonOperator

Language-specific names:

using Amazon.CDK.AWS.CloudWatch;
import software.amazon.awscdk.services.cloudwatch.ComparisonOperator;
const { ComparisonOperator } = require('@aws-cdk/aws-cloudwatch');
import { ComparisonOperator } from '@aws-cdk/aws-cloudwatch';

Comparison operator for evaluating alarms

GreaterThanOrEqualToThreshold
GreaterThanThreshold
LessThanThreshold
LessThanOrEqualToThreshold

ConcreteWidget

class @aws-cdk/aws-cloudwatch.ConcreteWidget(width, height)

Language-specific names:

using Amazon.CDK.AWS.CloudWatch;
import software.amazon.awscdk.services.cloudwatch.ConcreteWidget;
const { ConcreteWidget } = require('@aws-cdk/aws-cloudwatch');
import { ConcreteWidget } from '@aws-cdk/aws-cloudwatch';

A real CloudWatch widget that has its own fixed size and remembers its position

This is in contrast to other widgets which exist for layout purposes.

Implements:

IWidget

Abstract:

Yes

Parameters:
  • width (number) –
  • height (number) –
position(x, y)

Implements @aws-cdk/aws-cloudwatch.IWidget.position()

Place the widget at a given position

Parameters:
  • x (number) –
  • y (number) –
toJson() → any[]

Implements @aws-cdk/aws-cloudwatch.IWidget.toJson()

Return the widget JSON for use in the dashboard

Return type:any[]
Abstract:Yes
height

Implements @aws-cdk/aws-cloudwatch.IWidget.height()

The amount of vertical grid units the widget will take up

Type:number (readonly)
width

Implements @aws-cdk/aws-cloudwatch.IWidget.width()

The amount of horizontal grid units the widget will take up

Type:number (readonly)
x

Protected property

Type:number (optional)
y

Protected property

Type:number (optional)

Dashboard

class @aws-cdk/aws-cloudwatch.Dashboard(scope, id[, props])

Language-specific names:

using Amazon.CDK.AWS.CloudWatch;
import software.amazon.awscdk.services.cloudwatch.Dashboard;
const { Dashboard } = require('@aws-cdk/aws-cloudwatch');
import { Dashboard } from '@aws-cdk/aws-cloudwatch';

A CloudWatch dashboard

Extends:

@aws-cdk/cdk.Construct

Parameters:
add(*widgets)

Add a widget to the dashboard.

Widgets given in multiple calls to add() will be laid out stacked on

top of each other.

Multiple widgets added in the same call to add() will be laid out next

to each other.

Parameters:*widgets (IWidget) –
prepare()

Inherited from @aws-cdk/cdk.Construct

Perform final modifications before synthesis

This method can be implemented by derived constructs in order to perform

final changes before synthesis. prepare() will be called after child

constructs have been prepared.

This is an advanced framework feature. Only use this if you

understand the implications.

Protected method

toString() → string

Inherited from @aws-cdk/cdk.Construct

Returns a string representation of this construct.

Return type:string
validate() → string[]

Inherited from @aws-cdk/cdk.Construct

Validate the current construct.

This method can be implemented by derived constructs in order to perform

validation logic. It is called on all constructs before synthesis.

Protected method

Returns:An array of validation error messages, or an empty array if there the construct is valid.
Return type:string[]
dependencyRoots

Inherited from @aws-cdk/cdk.Construct

The set of constructs that form the root of this dependable

All resources under all returned constructs are included in the ordering

dependency.

Type:@aws-cdk/cdk.IConstruct[] (readonly)
node

Inherited from @aws-cdk/cdk.Construct

Construct node.

Type:@aws-cdk/cdk.ConstructNode (readonly)

DashboardProps (interface)

class @aws-cdk/aws-cloudwatch.DashboardProps

Language-specific names:

using Amazon.CDK.AWS.CloudWatch;
import software.amazon.awscdk.services.cloudwatch.DashboardProps;
// DashboardProps is an interface
import { DashboardProps } from '@aws-cdk/aws-cloudwatch';
dashboardName

Name of the dashboard

Type:string (optional)
Default:Automatically generated name

Dimension (interface)

class @aws-cdk/aws-cloudwatch.Dimension

Language-specific names:

using Amazon.CDK.AWS.CloudWatch;
import software.amazon.awscdk.services.cloudwatch.Dimension;
// Dimension is an interface
import { Dimension } from '@aws-cdk/aws-cloudwatch';

Metric dimension

name

Name of the dimension

Type:string
value

Value of the dimension

Type:any

GraphWidget

class @aws-cdk/aws-cloudwatch.GraphWidget(props)

Language-specific names:

using Amazon.CDK.AWS.CloudWatch;
import software.amazon.awscdk.services.cloudwatch.GraphWidget;
const { GraphWidget } = require('@aws-cdk/aws-cloudwatch');
import { GraphWidget } from '@aws-cdk/aws-cloudwatch';

A dashboard widget that displays metrics

Extends:ConcreteWidget
Parameters:props (GraphWidgetProps) –
toJson() → any[]

Implements @aws-cdk/aws-cloudwatch.ConcreteWidget.toJson()

Return the widget JSON for use in the dashboard

Return type:any[]
position(x, y)

Inherited from @aws-cdk/aws-cloudwatch.ConcreteWidget

Place the widget at a given position

Parameters:
  • x (number) –
  • y (number) –
height

Inherited from @aws-cdk/aws-cloudwatch.ConcreteWidget

The amount of vertical grid units the widget will take up

Type:number (readonly)
width

Inherited from @aws-cdk/aws-cloudwatch.ConcreteWidget

The amount of horizontal grid units the widget will take up

Type:number (readonly)
x

Inherited from @aws-cdk/aws-cloudwatch.ConcreteWidget

Protected property

Type:number (optional)
y

Inherited from @aws-cdk/aws-cloudwatch.ConcreteWidget

Protected property

Type:number (optional)

GraphWidgetProps (interface)

class @aws-cdk/aws-cloudwatch.GraphWidgetProps

Language-specific names:

using Amazon.CDK.AWS.CloudWatch;
import software.amazon.awscdk.services.cloudwatch.GraphWidgetProps;
// GraphWidgetProps is an interface
import { GraphWidgetProps } from '@aws-cdk/aws-cloudwatch';

Properties for a GraphWidget

Extends:MetricWidgetProps
left

Metrics to display on left Y axis

Type:Metric[] (optional)
leftAnnotations

Annotations for the left Y axis

Type:HorizontalAnnotation[] (optional)
leftAxisRange

Range of left Y axis

Type:YAxisRange (optional)
Default:0..automatic
right

Metrics to display on right Y axis

Type:Metric[] (optional)
rightAnnotations

Annotations for the right Y axis

Type:HorizontalAnnotation[] (optional)
rightAxisRange

Range of right Y axis

Type:YAxisRange (optional)
Default:0..automatic
stacked

Whether the graph should be shown as stacked lines

Type:boolean (optional)
height

Inherited from @aws-cdk/aws-cloudwatch.MetricWidgetProps

Height of the widget

Type:number (optional)
Default:Depends on the type of widget
region

Inherited from @aws-cdk/aws-cloudwatch.MetricWidgetProps

The region the metrics of this graph should be taken from

Type:string (optional)
Default:Current region
title

Inherited from @aws-cdk/aws-cloudwatch.MetricWidgetProps

Title for the graph

Type:string (optional)
width

Inherited from @aws-cdk/aws-cloudwatch.MetricWidgetProps

Width of the widget, in a grid of 24 units wide

Type:number (optional)
Default:6

HorizontalAnnotation (interface)

class @aws-cdk/aws-cloudwatch.HorizontalAnnotation

Language-specific names:

using Amazon.CDK.AWS.CloudWatch;
import software.amazon.awscdk.services.cloudwatch.HorizontalAnnotation;
// HorizontalAnnotation is an interface
import { HorizontalAnnotation } from '@aws-cdk/aws-cloudwatch';

Horizontal annotation to be added to a graph

value

The value of the annotation

Type:number
color

Hex color code to be used for the annotation

Type:string (optional)
Default:Automatic color
fill

Add shading above or below the annotation

Type:Shading (optional)
Default:No shading
label

Label for the annotation

Type:string (optional)
Default:No label
visible

Whether the annotation is visible

Type:boolean (optional)
Default:true

IAlarmAction (interface)

class @aws-cdk/aws-cloudwatch.IAlarmAction

Language-specific names:

using Amazon.CDK.AWS.CloudWatch;
import software.amazon.awscdk.services.cloudwatch.IAlarmAction;
// IAlarmAction is an interface
import { IAlarmAction } from '@aws-cdk/aws-cloudwatch';

Interface for objects that can be the targets of CloudWatch alarm actions

alarmActionArn

Return the ARN that should be used for a CloudWatch Alarm action

Type:string (readonly)

IWidget (interface)

class @aws-cdk/aws-cloudwatch.IWidget

Language-specific names:

using Amazon.CDK.AWS.CloudWatch;
import software.amazon.awscdk.services.cloudwatch.IWidget;
// IWidget is an interface
import { IWidget } from '@aws-cdk/aws-cloudwatch';

A single dashboard widget

height

The amount of vertical grid units the widget will take up

Type:number (readonly)
width

The amount of horizontal grid units the widget will take up

Type:number (readonly)
position(x, y)

Place the widget at a given position

Parameters:
  • x (number) –
  • y (number) –
Abstract:

Yes

toJson() → any[]

Return the widget JSON for use in the dashboard

Return type:any[]
Abstract:Yes

Metric

class @aws-cdk/aws-cloudwatch.Metric(props)

Language-specific names:

using Amazon.CDK.AWS.CloudWatch;
import software.amazon.awscdk.services.cloudwatch.Metric;
const { Metric } = require('@aws-cdk/aws-cloudwatch');
import { Metric } from '@aws-cdk/aws-cloudwatch';

A metric emitted by a service

The metric is a combination of a metric identifier (namespace, name and dimensions)

and an aggregation function (statistic, period and unit).

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,

Metric is an abstraction that makes it easy to specify metrics for use in both

alarms and graphs.

Parameters:props (MetricProps) –
static grantPutMetricData([identity])

Grant permissions to the given identity to write metrics.

Parameters:identity (@aws-cdk/aws-iam.IPrincipal (optional)) – The IAM identity to give permissions to.
dimensionsAsList() → @aws-cdk/aws-cloudwatch.Dimension[]

Return the dimensions of this Metric as a list of Dimension.

Return type:Dimension[]
newAlarm(scope, id, props) → @aws-cdk/aws-cloudwatch.Alarm

Make a new Alarm for this metric

Combines both properties that may adjust the metric (aggregation) as well

as alarm properties.

Parameters:
Return type:

Alarm

with(props) → @aws-cdk/aws-cloudwatch.Metric

Return a copy of Metric with properties changed.

All properties except namespace and metricName can be changed.

Parameters:props (MetricCustomization) – The set of properties to change.
Return type:Metric
metricName
Type:string (readonly)
namespace
Type:string (readonly)
periodSec
Type:number (readonly)
statistic
Type:string (readonly)
color
Type:string (optional) (readonly)
dimensions
Type:string => any (optional) (readonly)
label
Type:string (optional) (readonly)
unit
Type:Unit (optional) (readonly)

MetricAlarmProps (interface)

class @aws-cdk/aws-cloudwatch.MetricAlarmProps

Language-specific names:

using Amazon.CDK.AWS.CloudWatch;
import software.amazon.awscdk.services.cloudwatch.MetricAlarmProps;
// MetricAlarmProps is an interface
import { MetricAlarmProps } from '@aws-cdk/aws-cloudwatch';

Properties needed to make an alarm from a metric

evaluationPeriods

The number of periods over which data is compared to the specified threshold.

Type:number
threshold

The value against which the specified statistic is compared.

Type:number
actionsEnabled

Whether the actions for this alarm are enabled

Type:boolean (optional)
Default:true
alarmDescription

Description for the alarm

Type:string (optional)
Default:No description
alarmName

Name of the alarm

Type:string (optional)
Default:Automatically generated name
comparisonOperator

Comparison to use to check if metric is breaching

Type:ComparisonOperator (optional)
Default:GreaterThanOrEqualToThreshold
datapointsToAlarm

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.

Type:number (optional)
Default:evaluationPeriods
evaluateLowSampleCountPercentile

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.

Type:string (optional)
periodSec

The period over which the specified statistic is applied.

Specify time in seconds, in multiples of 60.

Type:number (optional)
Default:300
statistic

What function to use for aggregating.

Can be one of the following:

  • “Minimum” | “min”
  • “Maximum” | “max”
  • “Average” | “avg”
  • “Sum” | “sum”
  • “SampleCount | “n”
  • “pNN.NN”
Type:string (optional)
Default:Average
treatMissingData

Sets how this alarm is to handle missing data points.

Type:TreatMissingData (optional)
Default:TreatMissingData.Missing

MetricCustomization (interface)

class @aws-cdk/aws-cloudwatch.MetricCustomization

Language-specific names:

using Amazon.CDK.AWS.CloudWatch;
import software.amazon.awscdk.services.cloudwatch.MetricCustomization;
// MetricCustomization is an interface
import { MetricCustomization } from '@aws-cdk/aws-cloudwatch';

Properties of a metric that can be changed

color

Color for this metric when added to a Graph in a Dashboard

Type:string (optional)
dimensions

Dimensions of the metric

Type:string => any (optional)
Default:No dimensions
label

Label for this metric when added to a Graph in a Dashboard

Type:string (optional)
periodSec

The period over which the specified statistic is applied.

Specify time in seconds, in multiples of 60.

Type:number (optional)
Default:300
statistic

What function to use for aggregating.

Can be one of the following:

  • “Minimum” | “min”
  • “Maximum” | “max”
  • “Average” | “avg”
  • “Sum” | “sum”
  • “SampleCount | “n”
  • “pNN.NN”
Type:string (optional)
Default:Average
unit

Unit for the metric that is associated with the alarm

Type:Unit (optional)

MetricProps (interface)

class @aws-cdk/aws-cloudwatch.MetricProps

Language-specific names:

using Amazon.CDK.AWS.CloudWatch;
import software.amazon.awscdk.services.cloudwatch.MetricProps;
// MetricProps is an interface
import { MetricProps } from '@aws-cdk/aws-cloudwatch';

Properties for a metric

metricName

Name of the metric.

Type:string
namespace

Namespace of the metric.

Type:string
color

Color for this metric when added to a Graph in a Dashboard

Type:string (optional)
dimensions

Dimensions of the metric

Type:string => any (optional)
Default:No dimensions
label

Label for this metric when added to a Graph in a Dashboard

Type:string (optional)
periodSec

The period over which the specified statistic is applied.

Specify time in seconds, in multiples of 60.

Type:number (optional)
Default:300
statistic

What function to use for aggregating.

Can be one of the following (case insensitive)

  • “minimum” | “min”
  • “maximum” | “max”
  • “average” | “avg”
  • “sum”
  • “samplecount | “n”
  • “pNN.NN”
Type:string (optional)
Default:Average
unit

Unit for the metric that is associated with the alarm

Type:Unit (optional)

MetricWidgetProps (interface)

class @aws-cdk/aws-cloudwatch.MetricWidgetProps

Language-specific names:

using Amazon.CDK.AWS.CloudWatch;
import software.amazon.awscdk.services.cloudwatch.MetricWidgetProps;
// MetricWidgetProps is an interface
import { MetricWidgetProps } from '@aws-cdk/aws-cloudwatch';

Basic properties for widgets that display metrics

height

Height of the widget

Type:number (optional)
Default:Depends on the type of widget
region

The region the metrics of this graph should be taken from

Type:string (optional)
Default:Current region
title

Title for the graph

Type:string (optional)
width

Width of the widget, in a grid of 24 units wide

Type:number (optional)
Default:6

Row

class @aws-cdk/aws-cloudwatch.Row(*widgets)

Language-specific names:

using Amazon.CDK.AWS.CloudWatch;
import software.amazon.awscdk.services.cloudwatch.Row;
const { Row } = require('@aws-cdk/aws-cloudwatch');
import { Row } from '@aws-cdk/aws-cloudwatch';

A widget that contains other widgets in a horizontal row

Widgets will be laid out next to each other

Implements:IWidget
Parameters:*widgets (IWidget) –
position(x, y)

Implements @aws-cdk/aws-cloudwatch.IWidget.position()

Place the widget at a given position

Parameters:
  • x (number) –
  • y (number) –
toJson() → any[]

Implements @aws-cdk/aws-cloudwatch.IWidget.toJson()

Return the widget JSON for use in the dashboard

Return type:any[]
height

Implements @aws-cdk/aws-cloudwatch.IWidget.height()

The amount of vertical grid units the widget will take up

Type:number (readonly)
width

Implements @aws-cdk/aws-cloudwatch.IWidget.width()

The amount of horizontal grid units the widget will take up

Type:number (readonly)

Shading (enum)

class @aws-cdk/aws-cloudwatch.Shading

Language-specific names:

using Amazon.CDK.AWS.CloudWatch;
import software.amazon.awscdk.services.cloudwatch.Shading;
const { Shading } = require('@aws-cdk/aws-cloudwatch');
import { Shading } from '@aws-cdk/aws-cloudwatch';
None

Don’t add shading

Above

Add shading above the annotation

Below

Add shading below the annotation

SingleValueWidget

class @aws-cdk/aws-cloudwatch.SingleValueWidget(props)

Language-specific names:

using Amazon.CDK.AWS.CloudWatch;
import software.amazon.awscdk.services.cloudwatch.SingleValueWidget;
const { SingleValueWidget } = require('@aws-cdk/aws-cloudwatch');
import { SingleValueWidget } from '@aws-cdk/aws-cloudwatch';

A dashboard widget that displays the most recent value for every metric

Extends:ConcreteWidget
Parameters:props (SingleValueWidgetProps) –
toJson() → any[]

Implements @aws-cdk/aws-cloudwatch.ConcreteWidget.toJson()

Return the widget JSON for use in the dashboard

Return type:any[]
position(x, y)

Inherited from @aws-cdk/aws-cloudwatch.ConcreteWidget

Place the widget at a given position

Parameters:
  • x (number) –
  • y (number) –
height

Inherited from @aws-cdk/aws-cloudwatch.ConcreteWidget

The amount of vertical grid units the widget will take up

Type:number (readonly)
width

Inherited from @aws-cdk/aws-cloudwatch.ConcreteWidget

The amount of horizontal grid units the widget will take up

Type:number (readonly)
x

Inherited from @aws-cdk/aws-cloudwatch.ConcreteWidget

Protected property

Type:number (optional)
y

Inherited from @aws-cdk/aws-cloudwatch.ConcreteWidget

Protected property

Type:number (optional)

SingleValueWidgetProps (interface)

class @aws-cdk/aws-cloudwatch.SingleValueWidgetProps

Language-specific names:

using Amazon.CDK.AWS.CloudWatch;
import software.amazon.awscdk.services.cloudwatch.SingleValueWidgetProps;
// SingleValueWidgetProps is an interface
import { SingleValueWidgetProps } from '@aws-cdk/aws-cloudwatch';

Properties for a SingleValueWidget

Extends:MetricWidgetProps
metrics

Metrics to display

Type:Metric[]
height

Inherited from @aws-cdk/aws-cloudwatch.MetricWidgetProps

Height of the widget

Type:number (optional)
Default:Depends on the type of widget
region

Inherited from @aws-cdk/aws-cloudwatch.MetricWidgetProps

The region the metrics of this graph should be taken from

Type:string (optional)
Default:Current region
title

Inherited from @aws-cdk/aws-cloudwatch.MetricWidgetProps

Title for the graph

Type:string (optional)
width

Inherited from @aws-cdk/aws-cloudwatch.MetricWidgetProps

Width of the widget, in a grid of 24 units wide

Type:number (optional)
Default:6

Spacer

class @aws-cdk/aws-cloudwatch.Spacer(props)

Language-specific names:

using Amazon.CDK.AWS.CloudWatch;
import software.amazon.awscdk.services.cloudwatch.Spacer;
const { Spacer } = require('@aws-cdk/aws-cloudwatch');
import { Spacer } from '@aws-cdk/aws-cloudwatch';

A widget that doesn’t display anything but takes up space

Implements:IWidget
Parameters:props (SpacerProps) –
position(_x, _y)

Implements @aws-cdk/aws-cloudwatch.IWidget.position()

Place the widget at a given position

Parameters:
  • _x (number) –
  • _y (number) –
toJson() → any[]

Implements @aws-cdk/aws-cloudwatch.IWidget.toJson()

Return the widget JSON for use in the dashboard

Return type:any[]
height

Implements @aws-cdk/aws-cloudwatch.IWidget.height()

The amount of vertical grid units the widget will take up

Type:number (readonly)
width

Implements @aws-cdk/aws-cloudwatch.IWidget.width()

The amount of horizontal grid units the widget will take up

Type:number (readonly)

SpacerProps (interface)

class @aws-cdk/aws-cloudwatch.SpacerProps

Language-specific names:

using Amazon.CDK.AWS.CloudWatch;
import software.amazon.awscdk.services.cloudwatch.SpacerProps;
// SpacerProps is an interface
import { SpacerProps } from '@aws-cdk/aws-cloudwatch';

Props of the spacer

height

Height of the spacer

Type:number (optional)
Default:: 1
width

Width of the spacer

Type:number (optional)
Default:1

Statistic (enum)

class @aws-cdk/aws-cloudwatch.Statistic

Language-specific names:

using Amazon.CDK.AWS.CloudWatch;
import software.amazon.awscdk.services.cloudwatch.Statistic;
const { Statistic } = require('@aws-cdk/aws-cloudwatch');
import { Statistic } from '@aws-cdk/aws-cloudwatch';

Statistic to use over the aggregation period

SampleCount
Average
Sum
Minimum
Maximum

TextWidget

class @aws-cdk/aws-cloudwatch.TextWidget(props)

Language-specific names:

using Amazon.CDK.AWS.CloudWatch;
import software.amazon.awscdk.services.cloudwatch.TextWidget;
const { TextWidget } = require('@aws-cdk/aws-cloudwatch');
import { TextWidget } from '@aws-cdk/aws-cloudwatch';

A dashboard widget that displays MarkDown

Extends:ConcreteWidget
Parameters:props (TextWidgetProps) –
position(x, y)

Overrides @aws-cdk/aws-cloudwatch.ConcreteWidget.position()

Place the widget at a given position

Parameters:
  • x (number) –
  • y (number) –
toJson() → any[]

Implements @aws-cdk/aws-cloudwatch.ConcreteWidget.toJson()

Return the widget JSON for use in the dashboard

Return type:any[]
height

Inherited from @aws-cdk/aws-cloudwatch.ConcreteWidget

The amount of vertical grid units the widget will take up

Type:number (readonly)
width

Inherited from @aws-cdk/aws-cloudwatch.ConcreteWidget

The amount of horizontal grid units the widget will take up

Type:number (readonly)
x

Inherited from @aws-cdk/aws-cloudwatch.ConcreteWidget

Protected property

Type:number (optional)
y

Inherited from @aws-cdk/aws-cloudwatch.ConcreteWidget

Protected property

Type:number (optional)

TextWidgetProps (interface)

class @aws-cdk/aws-cloudwatch.TextWidgetProps

Language-specific names:

using Amazon.CDK.AWS.CloudWatch;
import software.amazon.awscdk.services.cloudwatch.TextWidgetProps;
// TextWidgetProps is an interface
import { TextWidgetProps } from '@aws-cdk/aws-cloudwatch';

Properties for a Text widget

markdown

The text to display, in MarkDown format

Type:string
height

Height of the widget

Type:number (optional)
Default:2
width

Width of the widget, in a grid of 24 units wide

Type:number (optional)
Default:6

TreatMissingData (enum)

class @aws-cdk/aws-cloudwatch.TreatMissingData

Language-specific names:

using Amazon.CDK.AWS.CloudWatch;
import software.amazon.awscdk.services.cloudwatch.TreatMissingData;
const { TreatMissingData } = require('@aws-cdk/aws-cloudwatch');
import { TreatMissingData } from '@aws-cdk/aws-cloudwatch';

Specify how missing data points are treated during alarm evaluation

Breaching

Missing data points are treated as breaching the threshold

NotBreaching

Missing data points are treated as being within the threshold

Ignore

The current alarm state is maintained

Missing

The alarm does not consider missing data points when evaluating whether to change state

Unit (enum)

class @aws-cdk/aws-cloudwatch.Unit

Language-specific names:

using Amazon.CDK.AWS.CloudWatch;
import software.amazon.awscdk.services.cloudwatch.Unit;
const { Unit } = require('@aws-cdk/aws-cloudwatch');
import { Unit } from '@aws-cdk/aws-cloudwatch';

Unit for metric

Seconds
Microseconds
Milliseconds
Bytes_
Kilobytes
Megabytes
Gigabytes
Terabytes
Bits
Kilobits
Megabits
Gigabits
Terabits
Percent
Count
BytesPerSecond
KilobytesPerSecond
MegabytesPerSecond
GigabytesPerSecond
TerabytesPerSecond
BitsPerSecond
KilobitsPerSecond
MegabitsPerSecond
GigabitsPerSecond
TerabitsPerSecond
CountPerSecond
None

YAxisRange (interface)

class @aws-cdk/aws-cloudwatch.YAxisRange

Language-specific names:

using Amazon.CDK.AWS.CloudWatch;
import software.amazon.awscdk.services.cloudwatch.YAxisRange;
// YAxisRange is an interface
import { YAxisRange } from '@aws-cdk/aws-cloudwatch';

A minimum and maximum value for either the left or right Y axis

max

The maximum value

Type:number (optional)
Default:Automatic
min

The minimum value

Type:number (optional)
Default:Automatic