Create a CloudWatch graph with a search expression
On the CloudWatch console, you can access search capability when you add a graph to a dashboard, or by using the Metrics view.
You can't create an alarm based on a SEARCH expression. This is because search expressions return multiple time series, and an alarm based on a math expression can watch only one time series.
To add a graph with a search expression to an existing dashboard
-
Open the CloudWatch console at https://console.amazonaws.cn/cloudwatch/
. -
In the navigation pane, choose Dashboards and select a dashboard.
-
Choose Add widget.
-
Choose either Line or Stacked area and choose Configure.
-
On the Graphed metrics tab, choose Add a math expression.
-
For Details, enter the search expression that you want. For example,
SEARCH('{AWS/EC2,InstanceId} MetricName="CPUUtilization"', 'Average')
-
(Optional) To add another search expression or math expression to the graph, choose Add a math expression
-
(Optional) After you add a search expression, you can specify a dynamic label to appear on the graph legend for each metric. Dynamic labels display a statistic about the metric and automatically update when the dashboard or graph is refreshed. To add a dynamic label, choose Graphed metrics and then Dynamic labels.
By default, the dynamic values you add to the label appear at the beginning of the label. You can then click the Label value for the metric to edit the label. For more information, see Use dynamic labels.
-
(Optional) To add a single metric to the graph, choose the All metrics tab and drill down to the metric you want.
-
(Optional) To change the time range shown on the graph, choose either custom at the top of the graph or one of the time periods to the left of custom.
(Optional) Horizontal annotations help dashboard users quickly see when a metric has spiked to a certain level or whether the metric is within a predefined range. To add a horizontal annotation, choose Graph options and then Add horizontal annotation:
For Label, enter a label for the annotation.
For Value, enter the metric value where the horizontal annotation appears.
For Fill, specify whether to use fill shading with this annotation. For example, choose
Above
orBelow
for the corresponding area to be filled. If you specifyBetween
, anotherValue
field appears, and the area of the graph between the two values is filled.For Axis, specify whether the numbers in
Value
refer to the metric associated with the left y-axis or the right y-axis if the graph includes multiple metrics.You can change the fill color of an annotation by choosing the color square in the left column of the annotation.
Repeat these steps to add multiple horizontal annotations to the same graph.
To hide an annotation, clear the check box in the left column for that annotation.
To delete an annotation, choose x in the Actions column.
(Optional) Vertical annotations help you mark milestones in a graph, such as operational events or the beginning and end of a deployment. To add a vertical annotation, choose Graph options and then Add vertical annotation:
For Label, enter a label for the annotation. To show only the date and time on the annotation, keep the Label field blank.
For Date, specify the date and time where the vertical annotation appears.
For Fill, specify whether to use fill shading before or after a vertical annotation or between two vertical annotations. For example, choose
Before
orAfter
for the corresponding area to be filled. If you specifyBetween
, anotherDate
field appears, and the area of the graph between the two values is filled.
Repeat these steps to add multiple vertical annotations to the same graph.
To hide an annotation, clear the check box in the left column for that annotation.
To delete an annotation, choose x in the Actions column.
-
Choose Create widget.
-
Choose Save dashboard.
To use the Metrics view to graph searched metrics
-
Open the CloudWatch console at https://console.amazonaws.cn/cloudwatch/
. -
In the navigation pane, choose Metrics.
-
In the search field, enter the tokens to search for: for example,
cpuutilization t2.small
.Results that match your search appear.
-
To graph all of the metrics that match your search, choose Graph search.
or
To refine your search, choose one of the namespaces that appeared in your search results.
-
If you selected a namespace to narrow your results, you can do the following:
-
To graph one or more metrics, select the check box next to each metric. To select all metrics, select the check box in the heading row of the table.
-
To refine your search, hover over a metric name and choose Add to search or Search for this only.
-
To view help for a metric, select the metric name and choose What is this?.
The selected metrics appear on the graph.
-
-
(Optional) Select one of the buttons in the search bar to edit that part of the search term.
-
(Optional) To add the graph to a dashboard, choose Actions and then Add to dashboard.