This document describes how to work with chart legends. The legend looks like a table positioned beneath the graph. It has one column of colored dots, a configurable number of data columns, and a Value column. The following screenshot shows a chart with a legend:
The column of colored dots keys the lines in the graph to the rows in the legend. The Value column displays the values for the metric being charted, and other columns show the values of chosen metric or resource labels. The dashed bar on the chart indicates the time for which values are displayed.
To access resource-specific dashboards or to apply temporary filters to a dashboard, use the Other options more_vert menu in a legend.
Show and hide legends
You can show or hide the legends of all charts on a dashboard or of each chart individually:
- To show or hide the legends of every chart in a dashboard, in the dashboard toolbar, click settings Settings and then select Show all legends or Hide all legends.
To show or hide the legend of a particular chart, in the chart toolbar, click legend_toggle Toggle Legend .
When the chart width isn't sufficient to display the legend toggle in the chart's toolbar, this option is accessible by using chart's Other options more_vert menu.
Legends for charts that display multiple metric types might be difficult to interpret. By default, the legend columns are selected from the metric and resource labels for the charted metric type. When a chart has multiple metric types, the result is that a specific legend column might not be meaningful for a specific time series.
Example: A chart displays the number of bytes written to and the number of bytes read from virtual machine (VM) instances. Assume that the bytes-read data is filtered to the
us-central1-a
zone. The legend includes azone
column, and the values in that column might be different thanus-central1-a
. The reason is that the bytes-written metric type contains azone
label and that metric data wasn't filtered by zone.Example: A chart displays the number of bytes written to VM instances and the CPU usage for those instances. The legend contains columns for the disk type and storage type. However, the values for those labels are empty for time legend fields. The reason is that the CPU usage metric type doesn't support those labels.
Select legend columns
To change the columns that appear in the legend, click Columns view_column. Clicking the button brings up a configuration panel. This panel lists the metric and resource labels available to display as columns. Required columns have disabled checkboxes. The following screenshot shows the Columns button and the configuration panel for a particular legend:
When the chart is initially created, the system heuristically chooses a set of labels to show by default. You can select or clear labeled columns. The entries for required columns, most typically Value, are disabled and can't be cleared. When you change the configuration, you must have at least one metric or resource label selected.
The legend displays a scrollbar when it has many columns to display, and paginates the legend when there are many rows to display. The following screenshot illustrates a legend with a scrollbar, and arrows for navigating through the pages:
Sort legend rows
You can sort the rows of the legend by any of the columns. Rows can be sorted into ascending or descending order. To sort a row, click the header. The most recently sorted column displays an arrow indicating the sort order. The following screenshot shows a legend that has been sorted by zone in descending order:
Understand legends in "Compare to Past" mode
When you use Compare to Past mode on a chart, the legend is modified to include a second “values” column. The current Value column becomes Today, and the past values column is named appropriately—for example, Last Week. The following screenshot shows a legend for a table comparing current data to that of the last hour:
Configure the name of a legend column
The Legend Template field lets you customize a description for the time series on your chart. These descriptions appear on the tooltip for the chart and on the chart legend in the Name column. By default, the descriptions in the legend are created for you from the values of different labels in your time series. Because the system selects the labels, the results might not be helpful to you. To build a template for descriptions, use this field.
To access the legend template for a chart, in the Google Cloud console, select the Advanced tab in the chart's configuration pane. The legend template is listed under the heading Additional options.
You can enter plain text and templates in the Legend Template field. When you add a template, you add an expression that is evaluated when the legend is displayed.
To add a template, do the following:
- Click Insert a template.
- Select an entry from the menu. After you select an entry, a template is
automatically added. For example, if you select
response_code
, then the template${resource.labels.zone}
is added.
For example, the following screenshot shows a legend template that contains
plain text and the expression ${resource.labels.zone}
:
In the chart legend, the values generated from the template appear in a column with the header Name and in the tooltip:
You can configure the legend template to include multiple text strings and templates; however, the display space available on the tooltip is limited.
Access resource-specific dashboards
When you are viewing a time series, you might want to view more information about the resource against which that time series is written. For some resources, you can go to the management page for that resource by using options in a chart's legend.
To go to the management page for a resource, do the following:
- In the Monitoring navigation panel, click
Dashboards.
- Click the name of the dashboard that you want to view.
- If the Close editor button is shown, then click it.
- Identify the chart and ensure its legend is displayed. If the legend isn't shown, then click legend_toggle Toggle Legend.
Open the management page for the resource:
- Locate the specific time series of interest, then click more_vertMore options.
- Select the option that begins with Manage.
The following is a partial list of resources whose management page you can access from the legend options:
- BigQuery datasets
- Cloud Storage buckets
- Compute Engine disks and instances
- Google Kubernetes Engine clusters, containers, nodes, and pods
- External HTTP(S) load balancer
- Pub/Sub subscriptions and topics
- Cloud Spanner instances
Add filters to a dashboard
To investigate the behavior of one resource in more detail, add temporary filters to your dashboard. These filters apply to all dashboard widgets.
To add temporary filters, click more_vert More options on a chart legend, and make a selection from the menu.
For more information, see Filter a dashboard.