Skip to content
v2.273.0

GraphWidget Class ​

A dashboard widget that displays metrics.

Example ​

ts
declare const dashboard: cloudwatch.Dashboard;

dashboard.addWidgets(new cloudwatch.GraphWidget({
  // ...
  accountId: '123456789012',
}));

dashboard.addWidgets(new cloudwatch.LogQueryWidget({
  logGroupNames: ['my-log-group'],
  // ...
  accountId: '123456789012',
  queryLines: [
    'fields @message',
  ],
}));
python
# dashboard: cloudwatch.Dashboard


dashboard.add_widgets(cloudwatch.GraphWidget(
    # ...
    account_id="123456789012"
))

dashboard.add_widgets(cloudwatch.LogQueryWidget(
    log_group_names=["my-log-group"],
    # ...
    account_id="123456789012",
    query_lines=["fields @message"
    ]
))
java
Dashboard dashboard;


dashboard.addWidgets(GraphWidget.Builder.create()
        // ...
        .accountId("123456789012")
        .build());

dashboard.addWidgets(LogQueryWidget.Builder.create()
        .logGroupNames(List.of("my-log-group"))
        // ...
        .accountId("123456789012")
        .queryLines(List.of("fields @message"))
        .build());
csharp
// Install: dotnet add package Amazon.CDK.Lib
Dashboard dashboard;


dashboard.AddWidgets(new GraphWidget(new GraphWidgetProps {
    // ...
    AccountId = "123456789012"
}));

dashboard.AddWidgets(new LogQueryWidget(new LogQueryWidgetProps {
    LogGroupNames = new [] { "my-log-group" },
    // ...
    AccountId = "123456789012",
    QueryLines = new [] { "fields @message" }
}));
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
var dashboard Dashboard


dashboard.AddWidgets(cloudwatch.NewGraphWidget(&GraphWidgetProps{
	// ...
	AccountId: jsii.String("123456789012"),
}))

dashboard.AddWidgets(cloudwatch.NewLogQueryWidget(&LogQueryWidgetProps{
	LogGroupNames: []*string{
		jsii.String("my-log-group"),
	},
	// ...
	AccountId: jsii.String("123456789012"),
	QueryLines: []*string{
		jsii.String("fields @message"),
	},
}))

Initializer ​

ts
new GraphWidget(props: GraphWidgetProps)
python
GraphWidget(props: GraphWidgetProps)
java
new GraphWidget(GraphWidgetProps props)
csharp
new GraphWidget(GraphWidgetProps props)
go
NewGraphWidget(Props GraphWidgetProps)

Properties ​

heightnumberheightint | floatheightNumberHeightdoubleHeight*float64required#
The amount of vertical grid units the widget will take up.
warningsstring[]warningstyping.List[str]warningsList<String>Warningsstring[]Warnings*[]*string#
Any warnings that are produced as a result of putting together this widget.
warningsV2{ [key: string]: string }warnings_v2typing.Mapping[str, str]warningsV2Map<String, String>WarningsV2IDictionary<string, string>WarningsV2*map[string]*string#
Any warnings that are produced as a result of putting together this widget.
widthnumberwidthint | floatwidthNumberWidthdoubleWidth*float64required#
The amount of horizontal grid units the widget will take up.

Methods ​

addLeftMetric(metric: IMetric): voiddef add_left_metric(self, metric: IMetric) -> Nonepublic void addLeftMetric(IMetric metric)public void AddLeftMetric(IMetric metric)func AddLeftMetric(Metric IMetric)#
Add another metric to the left Y axis of the GraphWidget.
1 parameter

Parameters

  • metricmetricmetricmetricMetric — the metric to add.
addRightMetric(metric: IMetric): voiddef add_right_metric(self, metric: IMetric) -> Nonepublic void addRightMetric(IMetric metric)public void AddRightMetric(IMetric metric)func AddRightMetric(Metric IMetric)#
Add another metric to the right Y axis of the GraphWidget.
1 parameter

Parameters

  • metricmetricmetricmetricMetric — the metric to add.
position(x: number, y: number): voiddef position(self, x: int | float, y: int | float) -> Nonepublic void position(Number x, Number y)public void Position(double x, double y)func Position(X *float64, Y *float64)#
Place the widget at a given position.
toJson(): any[]def to_json(self, ) -> typing.List[Any]public List<Object> toJson()public object[] ToJson()func ToJson() *[]interface{}#
Return the widget JSON for use in the dashboard.