This guide introduces Monitoring charts. There are two ways to build charts:
- Building an ad-hoc chart using Metrics Explorer.
- Creating a chart to be added to a dashboard.
Charts created for dashboards are persistent; they become part of a set of monitoring tools. Charts built with Metrics Explorer are transient and used for investigating specific issues. The techniques for building them are the same.
The following screenshot shows a chart that displays a CPU usage metric:
As seen in this screenshot, each time series in the charted metric shows up as a colored line. Each of these is keyed by color to an entry in the legend under the chart.
Before you begin
- To add charts to a dashboard, you must have the Cloud IAM role roles/monitoring.editor. To use Metrics Explorer, you must have the Cloud IAM role roles/monitoring.viewer. See Access Control for more information.
- For an introduction to Stackdriver metrics, see Metrics, Time Series, and Resources.
- To create your own metrics, see custom metrics and logs-based metrics.
Building a new chart with Metrics Explorer
Metrics Explorer lets you build ad-hoc charts for any metric collected by your project. You can use Metrics Explorer to explore data you that you may not necessarily need on a dashboard, although charts built with Metrics Explorer can be saved to dashboards. You can also create a URL for the chart so it can be shared.
To build a new chart using Metrics Explorer:
On the Stackdriver Monitoring console, go to the Resources > Metrics Explorer page:
Select the desired Workspace from the list at the top of the page:
Creating a new chart for a dashboard
To create a new chart on a dashboard, click the Add Chart button on the far right of the dashboard toolbar:
When you are done designing the chart, click the Save button to add it to the dashboard. You can put up to 25 charts on a dashboard.
You can also look at any chart on the dashboard in Metrics Explorer by clicking the Other options button, more_vert, above the graph and selecting the Open in Metrics Explorer option.
Whether you are creating a chart to be installed on a dashboard or building an ad-hoc chart in Metrics Explorer, the chart-definition interface is nearly identical.
The process of designing a chart involves two tasks:
- Specifying the data to appear on the chart.
- Configuring the appearance of the chart.
These task are indicated by the two tabs on a chart-definition page (that is, either the Add Chart page or the Metrics Explorer page), as seen in the following screenshot, taken from the Add Chart page:
- The Metric tab is where you specify the metrics that you want to appear on the chart; this is covered in Selecting Metrics.
- The View options tab is where you specify the appearance of the chart itself; this is covered in Setting View Options.
In addition, a chart on a dashboards gets a name; this is represented by the
Untitled value in the screenshot. Charts in Metrics Explorer
do not have names; this field does not appear on the Metrics Explorer page.
See Titling charts for more information about titling
charts on dashboards.
After you have added a chart to a dashboard, you can edit it using the same interface.
Interacting with charts
Charts in Monitoring are dynamic constructs, not static images. There are many ways to interact with the charts, whether they are on a dashboard or built in Metrics Explorer; these are described in Working with Charts.
You can also select the metric and resource labels you want to see in the legend. See Configuring Legends for more information.
When adding a chart to a dashboard, you can associate a title with the chart. The user interface offers suggestions for titles, based on the metrics specified for the chart, but you can also provide your own. The following screenshot shows a user-provided title as well as a system-suggested title:
If you want to adopt the suggested title, simply click on the blue text in the
suggestion. If you change your mind, you can always replace it later.
If you had your own title and accidentally clicked on the suggestion, you can
undo it with a
Performance and limits related to charts
The performance of charts and dashboards depends in part of the amount of data each displays. In order to keep the performance within acceptable ranges, the following limits apply to charts:
|Charts on a dashboard||25|
|Lines on a chart||300|
These provide upper limits for the number of charts on a dashboard or lines on a chart. However, it is unlikely that most charts with this many lines will be meaningful.
Structural causes of excess data
The amount of data on a chart is driven by the metric supplying the data, and the structure of that metric can have a large impact on the amount of data it carries.
The amount of data that a metric captures in its labels is referred to as the cardinality of the metric. The cardinality is the number of possible combinations of values across all labels.
If a metric has 2 labels, and each label has 5 possible values that are independent of the values of the other label, the cardinality of the metric is 25: the possible combinations of the 5 values from the first label and the 5 values of the second label. If a metric has only 1 label with 500 possible values, the cardinality is 500.
The maximum number of labels in a metric is 10, and the range of values for each label must be bounded. For example, timestamps are a poor choice: even if the range is narrow, the number of possible values is enormous.
As a consumer of charts, there is little you can do about the structure of metrics built into Stackdriver Monitoring. Most of the built-in metrics have been designed to avoid cardinality issues.
If you encounter performance issues when displaying metric data, you can often mitigate the issues by using the techniques described in Reducing chart data.
If the metrics are custom metrics created for your service, you might also be able to ask service developers to change their metric definitions to reduce the number of labels or the number of possible values for them, reducing the cardinality of the metric as a result.
Reducing chart data
To further improve performance, and simultaneously make charts more understandable, you can use the following techniques to reduce the number of lines on your charts:
- Removing unnecessary information by filtering.
- Collapsing related information together by grouping.
- Summarizing information with aggregation.
- Focusing on unusual data with outlier mode.
The legends described in Configuring Legends replace a previous implementation that you could not configure.
Many of the screenshots of charts elsewhere in the Stackdriver documentation show the old legends. In those cases, the style of the legend is not does not matter to the discussion around the screenshot.
However, there are visual differences between the implementations:
The appearance and contents of the legend itself differ.
The old legend had only Name and Value columns:
You can configure the contents of the current legend, for example:
The control on the chart to toggle the legend has changed.
The old Legend Toggle icon in the chart controls was four stacked bars:
The current Legend Toggle icon in the chart controls is three stacked dotted bars.