This page describes how to use the metric-selection tool to specify a target metric for an alerting policy. The chart next to the Target region gives you visual feedback on the data being captured by the target.
The Target region uses the same metric selector that is used in Metrics Explorer and for creating charts. If you are already familiar with it, you can skip this page.
Selecting a metric
To select a metric, use the Find resource type and metric field to choose one resource type and one metric type. You can specify them in either order. To begin, click in the field. This brings up one or two lists, based on any prior selections. The lists are indicated by headers, Resource types and Metrics, as seen in the following screenshot:
You can select an entry in two ways:
- By selecting entries from the lists.
- By typing directly to search the lists for matching candidates, including custom metrics.
To search for custom metrics, type
custom in the search box.
The following screenshot shows the incomplete search term
with the possible completions available for selection:
Hovering over an item on either list brings up a tooltip that displays the information in the item's descriptor. For information on descriptors for metric types or monitored resources, see the metrics list or the monitored resource list.
When at least one resource type and metric pair is selected, the chart shows all the available time series, and additional items appear below the specifed metric on the Metric tab. The following screenshot shows the Metric tab after a metric has been specified:
You can reduce the amount of data included by specifying filter criteria, so that only time series that meet some set of criteria are used. Filtering lets you restrict the number of time series from your chosen metrics that contribute data. This results in fewer lines on the chart that displays this metric, which can improve the performance of the chart.
You can supply multiple filtering criteria. The corresponding chart shows only
the time series that meet all of the criteria, a logical
When you click in the Filter field, a panel containing lists of criteria by which you can filter appears. In broad strokes, you can filter by resource group, by name, by resource label, and by metric label.
The following screenshot shows the known filter-by labels for a project:
You can select from the lists or type to find matches. Additionally, you can create filters for data that has not yet appeared; such filter criteria won't appear on the selection list, but you can manually specify filters that you know will be valid in the future.
After you choose a label on which to filter, you have to specify the rest of the filter: a value or range of values and a comparison. The filter field supports regular expressions, so you can use wildcards and set up conditions for values. Using regular expressions is more computationally expensive than simple wildcarding.
For example, the following screenshot sets up a filter on the
label. This supports two simple comparisons, equal (
!=), and the use of a regular expression (
=~) for more complex
For numeric values, greater-than (
>) and less-than (
<) are also
After you choose a comparison operator, you can choose a value from a list of the available values. The following screenshot uses the names of zones:
You can choose one of these; you can type in a wildcard variant; or you can type in a value that does not currently exist but that you expect to exist at some point.
The following screenshot shows a filter that uses a wildcard to match any
times series from any of the
You can specify multiple filter criteria, and you can use the same filter type
multiple times. This lets you specify a filter for a range of values. For
example, specifying both
x > 100 and
x < 500 establishes a "between" range,
filtering for time series in which x is between 100 and 500.
Currently, all of the filter criteria must be met; they constitute a logical
The Group By option lets you group time series by resource and metric labels, and then aggregate the data within those groups. This creates a single new time series for each group-by value, and the new time series represents all the members of the group. This reduces the number of lines on the chart displaying the metric, which can improve the performance of the chart.
Suppose, for example, you want to examine logging load but only at a regional level; that is, you don't care about the number of entries from specific servers. You can group time series by zone, and then chart the total, average, or other measure for each zone.
The default option for reducing a group of time series to one is to sum them. You do not set this manually, but you can change it; see Aggregation for more information about other choices.
The following screenshot shows a grouping by zone. The choice of
Aggregation is the default.
This creates a new time series for each zone, with values computed from the sum of all the values for individual time series in that zone.
You can group by multiple labels, as well. When you group by multiple labels, you get a time series for each combination of labels. The order in which you specify the labels does not matter. To remove a group-by condition, you must:
- Delete the group-by labels.
- Set the aggregation method back to
The Aggregation option lets you combine time series based on common statistics. This results in fewer lines on the chart displaying the metric, which can improve the performance of the chart.
Click in the field to see a list of the available aggregation options. These are the computations, or reducers, that can be used to combine the time series. The following screenshot shows some of the reducers available for the specified metric:
The reducers available depend on the type of values the metric captures, but they commonly include choices like mean, max or min, standard deviation, assorted percentile values, and so forth.
When used without filtering or grouping, aggregation is applied across all the
time series in a metric, reducing them to a single time series consisting of the
mean, sum, or other measure as calculated across all the time series.
For more information on aggregation, see
in the API reference.
You can also use aggregation in conjunction with the Filter and the Group By options.
The Group By option automatically applies aggregation to compute statistics
within each group. The lines on a Group By chart already represent
aggregations. By default, Group By uses the
sum aggregation choice. You
can choose any of the other aggregation options for a Group By label.
Filtering reduces the number of time series in the selected metric to those that meet some set of criteria. You can then apply aggregation to those lines. As with the unfiltered metric, aggregation of a filtered metric will reduce all of the lines to one that reflects the chosen aggregation statistic
Below the Aggregation option is Show more options. Clicking this bar opens an additional configuration panel:
When you have multiple time series that already represent aggregations, like the examples illustrating the Group By option, you can then aggregate across them by choosing a secondary aggregation statistic. This further reduces the number of lines on the chart displaying the metric, which helps performance.
A time series is a set of data points in temporal order. To align a time series is to break the data points into regular buckets of time, the alignment period. Multiple time series must be aligned before they can be combined. Alignment is a prerequisite to aggregation.
When a time series is aligned, some technique must be chosen for creating
a value for the time series at each alignment interval, for example,
the mean response time per alignment interval. The default aligner used
with the Group By and Aggregation options is
The Aligner option lets you change the default aligner for your selected metric to another valid option.
Valid aligner choices depend on the kind and type of metric data a time
series stores. That is, aligner choice depends on the
of the time series. Some aligners both align the data temporally and convert it
from one metric kind or type to another.
For more information on the available aligners, see
in the API reference.
Stackdriver Monitoring uses two built-in sets of alignment periods, providing two different granularities. Each set determines the duration of the alignment period for different data-reporting periods:
Fine-grained alignment intervals
|Data-reporting period||Alignment interval|
|Less than 23 hours||1 minute|
|Greater than 23 hours||5 minutes|
|Greater than 6 days||1 hour|
In this case, alignment intervals are short, and they are used for for longer periods of time. This results in a greater number of alignment points for a reporting period than with the coarse-grained intervals.
Coarse-grained alignment intervals
|Data-reporting period||Alignment interval|
|Less than 20 minutes||1 minute|
|Greater than 20 minutes||5 minutes|
|Greater than 5 hours||30 minutes|
|Greater than 23 hours||2 hours|
|Greater than 6 days||1 day|
|Greater than 23 days||2 days|
In this case, alignment intervals are longer in general, and they are used for shorter periods of time, resulting in fewer total alignment points for a reporting period than with the fine-grained intervals.
Different chart types use different granularities, and time series are realigned, for example, when you zoom in or out, which changes the data-reporting period. Users cannot choose the granularity or override the alignment-interval value.
To hide the Secondary Aggregation and Aligner options, click Hide more options at the bottom of the pane. This does not clear any selected options. If you change or remove grouping, for example, forgotten choices for these hidden options can cause unexpected effects.