Skip to content
v2.278.0

MetricWidgetProps Struct ​

Basic properties for widgets that display metrics.

Example ​

ts
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import { aws_cloudwatch as cloudwatch } from 'aws-cdk-lib';
const metricWidgetProps: cloudwatch.MetricWidgetProps = {
  accountId: 'accountId',
  height: 123,
  region: 'region',
  title: 'title',
  width: 123,
};
python
# The code below shows an example of how to instantiate this type.
# The values are placeholders you should change.
from aws_cdk import aws_cloudwatch as cloudwatch

metric_widget_props = cloudwatch.MetricWidgetProps(
    account_id="accountId",
    height=123,
    region="region",
    title="title",
    width=123
)
java
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import software.amazon.awscdk.services.cloudwatch.*;

MetricWidgetProps metricWidgetProps = MetricWidgetProps.builder()
        .accountId("accountId")
        .height(123)
        .region("region")
        .title("title")
        .width(123)
        .build();
csharp
// Install: dotnet add package Amazon.CDK.Lib
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
using Amazon.CDK.AWS.CloudWatch;

var metricWidgetProps = new MetricWidgetProps {
    AccountId = "accountId",
    Height = 123,
    Region = "region",
    Title = "title",
    Width = 123
};
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import "github.com/aws/aws-cdk-go/awscdk"

metricWidgetProps := &MetricWidgetProps{
	AccountId: jsii.String("accountId"),
	Height: jsii.Number(123),
	Region: jsii.String("region"),
	Title: jsii.String("title"),
	Width: jsii.Number(123),
}

Properties ​

accountIdoptionalstringaccount_idoptionalstraccountIdoptionalStringAccountIdoptionalstringAccountIdoptional*string #
The AWS account ID where the metrics are located.

Default: Current account

notes

This enables cross-account functionality for CloudWatch dashboards. Before using this feature, ensure that proper cross-account sharing is configured between the monitoring account and source account.

For more information, see: https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch-Unified-Cross-Account.html

heightoptionalnumberheightoptionalint | floatheightoptionalNumberHeightoptionaldoubleHeightoptional*float64 #
Height of the widget.

Default: 6 for Alarm and Graph widgets. 3 for single value widgets where most recent value of a metric is displayed.

regionoptionalstringregionoptionalstrregionoptionalStringRegionoptionalstringRegionoptional*string #
The region the metrics of this graph should be taken from.

Default: Current region

titleoptionalstringtitleoptionalstrtitleoptionalStringTitleoptionalstringTitleoptional*string = None #
Title for the graph.
widthoptionalnumberwidthoptionalint | floatwidthoptionalNumberWidthoptionaldoubleWidthoptional*float64 = 6 #
Width of the widget, in a grid of 24 units wide.