This document describes how you can explore metric data by building a temporary chart with Metrics Explorer. For example, to view the CPU utilization of a virtual machine (VM), you can use Metrics Explorer to construct a chart that displays the most recent data.
You can create simple charts, such as those that chart a single metric type, and complex charts, such as those that chart multiple metric types. After you create a chart with Metrics Explorer, you can discard it, save it to a custom dashboard, save its configuration, or share it.
The following screenshot shows a single metric type—the CPU Utilization of a VM instance—charted on the Metrics Explorer page:
The previous screenshot shows three lines, each line shows the time-series data for a specific VM.
Chart a single metric type
To configure a chart to display a single metric by using Metrics Explorer, do the following:
In the Google Cloud console, select Monitoring or click the following button:
Go to MonitoringIn the navigation pane, select
Metrics Explorer .
Specify the data to appear on the chart. To use a menu-driven interface or to enter a Monitoring filter, select the Configuration tab. To use the Monitoring Query Language (MQL), select the MQL tab.
Configuration tab
To configure a chart, complete the following steps:
Select the time series data that you want to view
Select a resource and metric by doing one of the following:
To chart a metric type, such as the CPU utilization of a VM, do the following:
- Expand the Select a metric menu.
- (Optional) To limit the number of choices, enter the metric or resource name in the filter bar. For example, to chart the request latency for a VM instance, you might enter "latency".
Use the menus to select a specific resource and metric. For example, you might make the following choices:
- In the Active resources menu, select VM instance.
- In the Active metric categories menu, select uptime_check.
- In the Active metrics menu, select Request latency.
- Click Apply.
(Optional) To specify a subset of data to display, select Add filter and complete the dialog. For example, you can view data for one zone by applying a filter. You can add multiple filters. For more information, see Filter charted data.
To chart a service-level objective or the count of processes running on VMs, enter a Monitoring filter:
- Click help_outline Help on the Select a metric menu.
- Select Direct filter mode.
- Enter a Monitoring filter in the text box.
For more information, see Select metrics when using Metrics Explorer
(Optional) Group and align time series
- To display every time series, leave the Group By and Aggregator fields clear.
- To group time series by a label, use the Group By field. Selecting a value for this field automatically selects a value for the Aggregator field.
- To specify how to combine time series, set the Aggregator field. For example, if the Group by field is empty and the Aggregator field is set to mean, then the chart displays the average of the time series.
- To configure how the individual time series are processed, select Advanced Options.
For more information, see Choose how to display charted data.
MQL tab
Enter your query into the query editor. For example, to chart the CPU Utilization of the VM instances in your Google Cloud project, use the following query:
fetch gce_instance | metric 'compute.googleapis.com/instance/cpu/utilization' | group_by 1m, [value_utilization_mean: mean(value.utilization)] | every 1m
The following documents provide information about MQL:
PromQL tab
Enter your query into the query editor. For example, to chart the average CPU utilization of the VM instances in your Google Cloud project, use the following query:
avg(compute_googleapis_com:instance_cpu_utilization)
For more information about using PromQL, see PromQL in Cloud Monitoring.
If you've charted a quota metric type or a metric type that has a
Distribution
value type, then update the chart style and time range. For other metric types, changing the default values is optional.For quota metric types, use the following settings:
- Set the time range to be at least one week because these metrics typically report one sample per day.
- In the Metrics Explorer toolbar, select Line chart, and then select Stacked area chart from the menu.
For distribution-valued metric types, use the following settings:
- In the Metrics Explorer toolbar, select Line chart, and then select Heatmap chart. For more information, see Distribution metrics.
(Optional) To add a threshold to the chart, view only outliers, compare current data to past data, or change the color setting, select settings Settings. For more information about your options, see Set view options.
Chart multiple metric types
In some situations, you might want to display time series from different metric types on the same chart. For example, to compare the read and write loads on a VM, configure a chart to display the number of bytes read and the number of bytes written.
To chart multiple metrics, you must use the Configuration tab. The MQL interface in Metrics Explorer doesn't support charting multiple metrics.
To display multiple metrics on a chart, do the following:
- In the Google Cloud console, select Monitoring
or click the following button:
Go to Monitoring - In the navigation pane, select
Metrics Explorer .
- Select the Configuration tab.
-
Select a resource and metric by doing one of the following:
To chart a metric type, such as the CPU utilization of a VM, do the following:
- Expand the Select a metric menu.
- (Optional) To limit the number of choices, enter the metric or resource name in the filter bar. For example, to chart the request latency for a VM instance, you might enter "latency".
Use the menus to select a specific resource and metric. For example, you might make the following choices:
- In the Active resources menu, select VM instance.
- In the Active metric categories menu, select uptime_check.
- In the Active metrics menu, select Request latency.
- Click Apply.
(Optional) To specify a subset of data to display, select Add filter and complete the dialog. For example, you can view data for one zone by applying a filter. You can add multiple filters. For more information, see Filter charted data.
To chart a service-level objective or the count of processes running on VMs, enter a Monitoring filter:
- Click help_outline Help on the Select a metric menu.
- Select Direct filter mode.
- Enter a Monitoring filter in the text box.
For more information, see Select metrics when using Metrics Explorer
(Optional) Group and align time series:
- To display every time series, leave the Group By and Aggregator fields clear.
- To group time series by a label, use the Group By field. Selecting a value for this field automatically selects a value for the Aggregator field.
- To specify how to combine time series, set the Aggregator field. For example, if the Group by field is empty and the Aggregator field is set to mean, then the chart displays the average of the time series.
- To configure how the individual time series are processed, select Advanced Options.
For more information, see Choose how to display charted data.
For each additional metric type, do the following:
Select Add another metric.
The first time you click Add another metric, the selections that you previously made are shown in the expandable Time series A pane. Also, the Time series B pane opens. This pane contains the configuration fields that you complete to chart the second metric.
The following screenshot illustrates this behavior:
To specify the metric to add to the chart, use the configuration options in the new pane. For example, for the second metric, use the fields in the Time series B pane.
Chart a ratio of metrics
Monitoring the number of errors reported might be useful; however, it is more likely that you need to monitor the rate of errors. That is, you want to know how many errors occurred as measured against the total number of responses. To meet this requirement, you can configure a chart to display the ratio of two metrics. For references to examples and for information about anomalies that can occur when you chart ratios of metrics, see Ratios of metrics.
To display a ratio of metrics on a chart, do the following:
In the Google Cloud console, select Monitoring or click the following button:
Go to MonitoringIn the navigation pane, select
Metrics Explorer .
Specify the data to appear on the chart. To use a menu-driven interface or to enter a Monitoring filter, select the Configuration tab. To use the MQL, select the MQL tab:
Configuration tab
Configure the numerator:
- To select a resource and metric, use the menus.
- (Optional) To restrict which time series are shown, add filters.
- (Optional) Update the grouping fields and alignment parameters.
Select Add another metric.
When you click Add another metric, the selections that you previously made are shown in the Time series A pane. Also, the Time series B pane opens. This pane contains the configuration fields that you complete to chart the second metric.
The following screenshot illustrates this behavior:
Configure the denominator:
To select a resource and metric for the denominator, use the menus in the Time Series-B pane.
Both metrics must have the same metric kind. For example, if the metric for Time Series-A is a GAUGE metric, then the metric you select for Time Series-B must be a GAUGE metric.
(Optional) To restrict which time series are shown, add filters.
Ensure that the value of the Minimum alignment period field is the same for both metrics.
Set the grouping parameters for the second metric.
We recommend that the grouping fields for the second metric match the values for Time Series-A. For example, you might group both metrics by the
zone
label.You aren't required to use the same grouping for both metrics; however, you can only group by labels that are common to both metrics.
Enable Display metrics as ratio.
When you make this selection, the label Time Series-A is renamed Numerator, and the label Time Series-B is renamed Denominator.
(Optional) To change which metric is the numerator, click Swap numerator.
(Optional) Expand Show ratio options to configure the secondary aggregation options.
MQL tab
Enter your query into the query editor. For example, to chart the CPU Utilization of the VM instances in your Google Cloud project, use the following query:
fetch gce_instance | metric 'compute.googleapis.com/instance/cpu/utilization' | group_by 1m, [value_utilization_mean: mean(value.utilization)] | every 1m
The following documents provide information about MQL:
PromQL tab
Enter your query into the query editor. For example, to chart the ratio of average latency of your
my_summary_latency_seconds
metric, use the following query:sum without (instance)(rate(my_summary_latency_seconds_sum[5m])) / sum without (instance)(rate(my_summary_latency_seconds_count[5m]))
For more information about using PromQL, see PromQL in Cloud Monitoring.
Save a chart for future reference
Metrics Explorer lets you create a chart that you can use to explore a metric. However, the charts created by this tool aren't persistent. When you navigate away from the Metrics Explorer page, the chart is discarded.
To save a chart you've configured with Metrics Explorer for future reference, add the chart to a custom dashboard or save the chart's URL:
To add the chart to a custom dashboard, do one of the following:
If you use the Google Cloud console to manage your custom dashboards, then select Save Chart in the Metrics Explorer toolbar, and complete the dialog. You can save the chart to an existing custom dashboard or you can create a dashboard.
If you use the Cloud Monitoring API to manage your custom dashboards, then update the JSON file that defines the dashboard and its contents. You can access the JSON representation from the more_vert More options menu that is located in the Metrics Explorer toolbar.
For detailed information about using the API to manage your custom dashboards, see Manage dashboards by API.
To keep a reference to the chart configuration, save the chart URL. Because the chart URL encodes the chart configuration, when you paste this URL into a browser the chart you configured is displayed.
To obtain the chart's URL, select more_vert More options in the Metrics Explorer toolbar, and then select Share by URL.
Save a chart's configuration
When you manage custom dashboards by using the Cloud Monitoring API, you can use Metrics Explorer to help you construct the data you provide to the API:
To generate the JSON representation for a chart that you plan to add to a dashboard, configure the chart with Metrics Explorer. You can then use options within Metrics Explorer to view and copy the chart's JSON representation.
To identify the syntax for a Monitoring filter, which is used with the Cloud Monitoring API, use the menu-driven interface of Metrics Explorer to configure the chart. After you select the metric and filters, switch to direct filter mode to view the equivalent Monitoring filter.
What's next
- Select metrics with Metrics Explorer
- View information about your user-defined metrics
- Add dashboard widgets
- Set view options
- Work with charts