GraphWidget Class
A dashboard widget that displays metrics.
Example
ts
declare const dashboard: cloudwatch.Dashboard;
const hiddenSearch = new cloudwatch.SearchExpression({
expression: "SEARCH('{AWS/EC2,InstanceId} MetricName=\"CPUUtilization\"', 'Average', 300)",
label: 'EC2 CPU Utilization',
visible: false,
});
dashboard.addWidgets(new cloudwatch.GraphWidget({
left: [hiddenSearch],
}));
python
# dashboard: cloudwatch.Dashboard
hidden_search = cloudwatch.SearchExpression(
expression="SEARCH('{AWS/EC2,InstanceId} MetricName=\"CPUUtilization\"', 'Average', 300)",
label="EC2 CPU Utilization",
visible=False
)
dashboard.add_widgets(cloudwatch.GraphWidget(
left=[hidden_search]
))
java
Dashboard dashboard;
SearchExpression hiddenSearch = SearchExpression.Builder.create()
.expression("SEARCH('{AWS/EC2,InstanceId} MetricName=\"CPUUtilization\"', 'Average', 300)")
.label("EC2 CPU Utilization")
.visible(false)
.build();
dashboard.addWidgets(GraphWidget.Builder.create()
.left(List.of(hiddenSearch))
.build());
csharp
// Install: dotnet add package Amazon.CDK.Lib
Dashboard dashboard;
var hiddenSearch = new SearchExpression(new SearchExpressionProps {
Expression = "SEARCH('{AWS/EC2,InstanceId} MetricName=\"CPUUtilization\"', 'Average', 300)",
Label = "EC2 CPU Utilization",
Visible = false
});
dashboard.AddWidgets(new GraphWidget(new GraphWidgetProps {
Left = new [] { hiddenSearch }
}));
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
var dashboard Dashboard
hiddenSearch := cloudwatch.NewSearchExpression(&SearchExpressionProps{
Expression: jsii.String("SEARCH('{AWS/EC2,InstanceId} MetricName=\"CPUUtilization\"', 'Average', 300)"),
Label: jsii.String("EC2 CPU Utilization"),
Visible: jsii.Boolean(false),
})
dashboard.AddWidgets(cloudwatch.NewGraphWidget(&GraphWidgetProps{
Left: []IMetric{
hiddenSearch,
},
}))
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
The amount of vertical grid units the widget will take up.
warningsmay be undefinedstring[]warningsmay be undefinedtyping.List[str]warningsmay be undefinedList<String>Warningsmay be undefinedstring[]Warningsmay be undefined*[]*string#Any warnings that are produced as a result of putting together this widget.
warningsV2may be undefined{ [key: string]: string }warnings_v2may be undefinedtyping.Mapping[str, str]warningsV2may be undefinedMap<String, String>WarningsV2may be undefinedIDictionary<string, string>WarningsV2may be undefined*map[string]*string#Any warnings that are produced as a result of putting together this widget.
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.