class Dashboard (construct)
Language | Type name |
---|---|
.NET | Amazon.CDK.AWS.CloudWatch.Dashboard |
Go | github.com/aws/aws-cdk-go/awscdk/v2/awscloudwatch#Dashboard |
Java | software.amazon.awscdk.services.cloudwatch.Dashboard |
Python | aws_cdk.aws_cloudwatch.Dashboard |
TypeScript (source) | aws-cdk-lib » aws_cloudwatch » Dashboard |
Implements
IConstruct
, IDependable
, IResource
A CloudWatch dashboard.
Example
import * as cw from 'aws-cdk-lib/aws-cloudwatch';
const dashboard = new cw.Dashboard(this, 'Dash', {
defaultInterval: Duration.days(7),
variables: [new cw.DashboardVariable({
id: 'region2',
type: cw.VariableType.PATTERN,
label: 'RegionPattern',
inputType: cw.VariableInputType.INPUT,
value: 'us-east-1',
defaultValue: cw.DefaultValue.value('us-east-1'),
visible: true,
})],
});
Initializer
new Dashboard(scope: Construct, id: string, props?: DashboardProps)
Parameters
- scope
Construct
- id
string
- props
Dashboard
Props
Construct Props
Name | Type | Description |
---|---|---|
dashboard | string | Name of the dashboard. |
default | Duration | Interval duration for metrics. You can specify defaultInterval with the relative time(eg. cdk.Duration.days(7)). |
end? | string | The end of the time range to use for each widget on the dashboard when the dashboard loads. |
period | Period | Use this field to specify the period for the graphs when the dashboard loads. |
start? | string | The start of the time range to use for each widget on the dashboard. |
variables? | IVariable [] | A list of dashboard variables. |
widgets? | IWidget [][] | Initial set of widgets on the dashboard. |
dashboardName?
Type:
string
(optional, default: automatically generated name)
Name of the dashboard.
If set, must only contain alphanumerics, dash (-) and underscore (_)
defaultInterval?
Type:
Duration
(optional, default: When the dashboard loads, the defaultInterval time will be the default time range.)
Interval duration for metrics. You can specify defaultInterval with the relative time(eg. cdk.Duration.days(7)).
Both properties defaultInterval
and start
cannot be set at once.
end?
Type:
string
(optional, default: When the dashboard loads, the end date will be the current time.)
The end of the time range to use for each widget on the dashboard when the dashboard loads.
If you specify a value for end, you must also specify a value for start. Specify an absolute time in the ISO 8601 format. For example, 2018-12-17T06:00:00.000Z.
periodOverride?
Type:
Period
(optional, default: Auto)
Use this field to specify the period for the graphs when the dashboard loads.
Specifying Auto
causes the period of all graphs on the dashboard to automatically adapt to the time range of the dashboard.
Specifying Inherit
ensures that the period set for each graph is always obeyed.
start?
Type:
string
(optional, default: When the dashboard loads, the start time will be the default time range.)
The start of the time range to use for each widget on the dashboard.
You can specify start without specifying end to specify a relative time range that ends with the current time. In this case, the value of start must begin with -P, and you can use M, H, D, W and M as abbreviations for minutes, hours, days, weeks and months. For example, -PT8H shows the last 8 hours and -P3M shows the last three months. You can also use start along with an end field, to specify an absolute time range. When specifying an absolute time range, use the ISO 8601 format. For example, 2018-12-17T06:00:00.000Z.
Both properties defaultInterval
and start
cannot be set at once.
variables?
Type:
IVariable
[]
(optional, default: No variables)
A list of dashboard variables.
widgets?
Type:
IWidget
[][]
(optional, default: No widgets)
Initial set of widgets on the dashboard.
One array represents a row of widgets.
Properties
Name | Type | Description |
---|---|---|
dashboard | string | ARN of this dashboard. |
dashboard | string | The name of this dashboard. |
env | Resource | The environment this resource belongs to. |
node | Node | The tree node. |
stack | Stack | The stack in which this resource is defined. |
dashboardArn
Type:
string
ARN of this dashboard.
dashboardName
Type:
string
The name of this dashboard.
env
Type:
Resource
The environment this resource belongs to.
For resources that are created and managed by the CDK (generally, those created by creating new class instances like Role, Bucket, etc.), this is always the same as the environment of the stack they belong to; however, for imported resources (those obtained from static methods like fromRoleArn, fromBucketName, etc.), that might be different than the stack they were imported into.
node
Type:
Node
The tree node.
stack
Type:
Stack
The stack in which this resource is defined.
Methods
Name | Description |
---|---|
add | Add a variable to the dashboard. |
add | Add a widget to the dashboard. |
apply | Apply the given removal policy to this resource. |
to | Returns a string representation of this construct. |
Variable(variable)
addpublic addVariable(variable: IVariable): void
Parameters
- variable
IVariable
Add a variable to the dashboard.
Widgets(...widgets)
addpublic addWidgets(...widgets: IWidget[]): void
Parameters
- widgets
IWidget
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.
RemovalPolicy(policy)
applypublic applyRemovalPolicy(policy: RemovalPolicy): void
Parameters
- policy
Removal
Policy
Apply the given removal policy to this resource.
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
).
String()
topublic toString(): string
Returns
string
Returns a string representation of this construct.