Graph a metric
You can select metrics and create graphs of the metric data using the CloudWatch console.
CloudWatch supports the following statistics on metrics: Average
,
Minimum
, Maximum
, Sum
, and SampleCount
.
For more information, see Statistics.
You can view your data at different levels of detail. For example, you can choose a one-minute view, which can be useful when troubleshooting. Or, choose a less detailed, one-hour view. That can be useful when viewing a broader time range (for example, 3 days) so that you can see trends over time. For more information, see Periods.
If you are using an account that is set up as a monitoring account in CloudWatch cross-account observability, you can graph metrics from the source accounts linked to this monitoring account. For more information, see CloudWatch cross-account observability.
Creating a graph
To graph a metric
-
Open the CloudWatch console at https://console.aws.amazon.com/cloudwatch/
. -
In the navigation pane, choose Metrics, All metrics.
-
In the Browse tab, enter a search term in the search field, such as a metric name, account ID, or resource name.
For example, if you search for the
CPUUtilization
metric, you see the namespaces and dimensions with this metric. -
Select one of the results for your search to view the metrics.
-
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.
(Optional) To change the type of graph, choose the Options tab. You can then choose between a line graph, stacked area chart, number display, gauge, bar chart, or pie chart.
Choose the Graphed metrics tab.
(Optional) To change the statistic used in the graph, choose the new statistic in the Statistic column next to the metric name.
For more information about CloudWatch statistics, see CloudWatch statistics definitions. For more information about the pxx percentile statistics, see Percentiles.
(Optional) To add an anomaly detection band that shows expected values for the metric, choose the anomaly detection icon under Actions next to the metric.
CloudWatch uses up to two weeks of the metric's recent historical data to calculate a model for expected values. It then displays this range of expected values as a band on the graph. CloudWatch adds a new row under the metric to display the anomaly detection band math expression, labeled ANOMALY_DETECTION_BAND. If recent historical data exists, you immediately see a preview anomaly detection band, which is an approximation of the anomaly detection band generated by the model. It takes up to 15 minutes for the actual anomaly detection band to appear.
By default, CloudWatch creates the upper and lower bounds of the band of expected values with a default value of 2 for the band threshold. To change this number, change the value at the end of the formula under Details for the band.
(Optional) Choose Edit model to change how the anomaly detection model is calculated. You can exclude past and future time periods from being used in the training for calculating the model. It is critical to exclude unusual events system as system outage, deployments, and holidays from the training data. You can also specify the time zone to use for the model for daylight saving time changes.
For more information, see Using CloudWatch anomaly detection.
To hide the model from the graph, remove the checkmark from the line with the
ANOMALY_DETECTION_BAND
function or choose theX
icon. To delete the model entirely, choose Edit model, Delete model.-
(Optional) As you choose metrics to graph, 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, Add dynamic label.
By default, the dynamic values that you add to the label appear at the beginning of the label. You can then choose the Label value for the metric to edit the label. For more information, see Use dynamic labels.
-
To view more information about the metric being graphed, pause the mouse over the legend.
Horizontal annotations can help graph users more efficiently 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 the Options tab 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.
-
To get a URL for your graph, choose Actions, Share. Copy the URL to save or share.
-
To add your graph to a dashboard, choose Actions, Add to dashboard.
Creating a graph of metrics from another data source
You can create a graph that displays resources from data sources other than CloudWatch. For more information about creating connections to these other data sources, see Query metrics from other data sources.
To graph a metric from another data source
-
Open the CloudWatch console at https://console.aws.amazon.com/cloudwatch/
. -
In the navigation pane, choose Metrics, All metrics.
-
Choose the Multi source query tab.
-
For Data source, select the data source that you want to use.
If you haven't already created a connection to the data source that you want, select Create and manage data sources, then choose Create and manage data sources. For information about the rest of this data source creation process, see Connect to a prebuilt data source with a wizard.
-
The wizard or query editor prompts you for the information necessary for the query. The workflow is different for each data source, and is tailored to the data source. For example, for Amazon Managed Service for Prometheus; and Prometheus data sources, a PromQL query editor box with a query helper appear.
-
When you have finished constructing the query, choose Graph query.
The graph is populated with metrics from the query.
(Optional) Horizontal annotations can help graph users more efficiently 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 the Options tab 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) To add this graph to a dashboard, choose Actions, Add to dashboard.
Updating a graph
To update your graph
-
To change the name of the graph, choose the pencil icon.
-
To change the time range, select one of the predefined values or choose custom. For more information, see Modify the time range or time zone format for a graph.
-
To change the statistic, choose the Graphed metrics tab. Choose the column heading or an individual value and then choose one of the statistics or predefined percentiles, or specify a custom percentile (for example,
p95.45
). -
To change the period, choose the Graphed metrics tab. Choose the column heading or an individual value and then choose a different value.
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.
-
To change the refresh interval, choose Refresh options and then select Auto refresh or choose 1 Minute, 2 Minutes, 5 Minutes, or 15 Minutes.
Duplicating a metric
To duplicate a metric
-
Choose the Graphed metrics tab.
-
For Actions, choose the Duplicate icon.
-
Update the duplicate metric as needed.