Reference documentation and code samples for the Stackdriver Monitoring V3 Client class Aggregation.
Describes how to combine multiple time series to provide a different view of
the data. Aggregation of time series is done in two steps. First, each time
series in the set is aligned to the same time interval boundaries, then the
set of time series is optionally reduced in number.
Alignment consists of applying the per_series_aligner operation
to each time series after its data has been divided into regular
alignment_period time intervals. This process takes all of the data
points in an alignment period, applies a mathematical transformation such as
averaging, minimum, maximum, delta, etc., and converts them into a single
data point per period.
Reduction is when the aligned and transformed time series can optionally be
combined, reducing the number of time series through similar mathematical
transformations. Reduction involves applying a cross_series_reducer to
all the time series, optionally sorting the time series into subsets with
group_by_fields, and applying the reducer to each subset.
The raw time series data can contain a huge amount of information from
multiple sources. Alignment and reduction transforms this mass of data into
a more manageable and representative collection of data, for example "the
95% latency across the average of all tasks in a cluster". This
representative data can be more easily graphed and comprehended, and the
individual time series data is still available for later drilldown. For more
details, see Filtering and
aggregation.
Generated from protobuf message google.monitoring.v3.Aggregation
The alignment_period specifies a time interval, in seconds, that is used to divide the data in all the time series into consistent blocks of time. This will be done before the per-series aligner can be applied to the data. The value must be at least 60 seconds. If a per-series aligner other than ALIGN_NONE is specified, this field is required or an error is returned. If no per-series aligner is specified, or the aligner ALIGN_NONE is specified, then this field is ignored. The maximum value of the alignment_period is 104 weeks (2 years) for charts, and 90,000 seconds (25 hours) for alerting policies.
↳ per_series_aligner
int
An Aligner describes how to bring the data points in a single time series into temporal alignment. Except for ALIGN_NONE, all alignments cause all the data points in an alignment_period to be mathematically grouped together, resulting in a single data point for each alignment_period with end timestamp at the end of the period. Not all alignment operations may be applied to all time series. The valid choices depend on the metric_kind and value_type of the original time series. Alignment can change the metric_kind or the value_type of the time series. Time series data must be aligned in order to perform cross-time series reduction. If cross_series_reducer is specified, then per_series_aligner must be specified and not equal to ALIGN_NONE and alignment_period must be specified; otherwise, an error is returned.
↳ cross_series_reducer
int
The reduction operation to be used to combine time series into a single time series, where the value of each data point in the resulting series is a function of all the already aligned values in the input time series. Not all reducer operations can be applied to all time series. The valid choices depend on the metric_kind and the value_type of the original time series. Reduction can yield a time series with a different metric_kind or value_type than the input time series. Time series data must first be aligned (see per_series_aligner) in order to perform cross-time series reduction. If cross_series_reducer is specified, then per_series_aligner must be specified, and must not be ALIGN_NONE. An alignment_period must also be specified; otherwise, an error is returned.
↳ group_by_fields
array
The set of fields to preserve when cross_series_reducer is specified. The group_by_fields determine how the time series are partitioned into subsets prior to applying the aggregation operation. Each subset contains time series that have the same value for each of the grouping fields. Each individual time series is a member of exactly one subset. The cross_series_reducer is applied to each subset of time series. It is not possible to reduce across different resource types, so this field implicitly contains resource.type. Fields not specified in group_by_fields are aggregated away. If group_by_fields is not specified and all the time series have the same resource type, then the time series are aggregated into a single output time series. If cross_series_reducer is not defined, this field is ignored.
getAlignmentPeriod
The alignment_period specifies a time interval, in seconds, that is used
to divide the data in all the
time series into consistent blocks of
time. This will be done before the per-series aligner can be applied to
the data.
The value must be at least 60 seconds. If a per-series
aligner other than ALIGN_NONE is specified, this field is required or an
error is returned. If no per-series aligner is specified, or the aligner
ALIGN_NONE is specified, then this field is ignored.
The maximum value of the alignment_period is 104 weeks (2 years) for
charts, and 90,000 seconds (25 hours) for alerting policies.
The alignment_period specifies a time interval, in seconds, that is used
to divide the data in all the
time series into consistent blocks of
time. This will be done before the per-series aligner can be applied to
the data.
The value must be at least 60 seconds. If a per-series
aligner other than ALIGN_NONE is specified, this field is required or an
error is returned. If no per-series aligner is specified, or the aligner
ALIGN_NONE is specified, then this field is ignored.
The maximum value of the alignment_period is 104 weeks (2 years) for
charts, and 90,000 seconds (25 hours) for alerting policies.
An Aligner describes how to bring the data points in a single
time series into temporal alignment. Except for ALIGN_NONE, all
alignments cause all the data points in an alignment_period to be
mathematically grouped together, resulting in a single data point for
each alignment_period with end timestamp at the end of the period.
Not all alignment operations may be applied to all time series. The valid
choices depend on the metric_kind and value_type of the original time
series. Alignment can change the metric_kind or the value_type of
the time series.
Time series data must be aligned in order to perform cross-time
series reduction. If cross_series_reducer is specified, then
per_series_aligner must be specified and not equal to ALIGN_NONE
and alignment_period must be specified; otherwise, an error is
returned.
Returns
Type
Description
int
setPerSeriesAligner
An Aligner describes how to bring the data points in a single
time series into temporal alignment. Except for ALIGN_NONE, all
alignments cause all the data points in an alignment_period to be
mathematically grouped together, resulting in a single data point for
each alignment_period with end timestamp at the end of the period.
Not all alignment operations may be applied to all time series. The valid
choices depend on the metric_kind and value_type of the original time
series. Alignment can change the metric_kind or the value_type of
the time series.
Time series data must be aligned in order to perform cross-time
series reduction. If cross_series_reducer is specified, then
per_series_aligner must be specified and not equal to ALIGN_NONE
and alignment_period must be specified; otherwise, an error is
returned.
Parameter
Name
Description
var
int
Returns
Type
Description
$this
getCrossSeriesReducer
The reduction operation to be used to combine time series into a single
time series, where the value of each data point in the resulting series is
a function of all the already aligned values in the input time series.
Not all reducer operations can be applied to all time series. The valid
choices depend on the metric_kind and the value_type of the original
time series. Reduction can yield a time series with a different
metric_kind or value_type than the input time series.
Time series data must first be aligned (see per_series_aligner) in order
to perform cross-time series reduction. If cross_series_reducer is
specified, then per_series_aligner must be specified, and must not be
ALIGN_NONE. An alignment_period must also be specified; otherwise, an
error is returned.
Returns
Type
Description
int
setCrossSeriesReducer
The reduction operation to be used to combine time series into a single
time series, where the value of each data point in the resulting series is
a function of all the already aligned values in the input time series.
Not all reducer operations can be applied to all time series. The valid
choices depend on the metric_kind and the value_type of the original
time series. Reduction can yield a time series with a different
metric_kind or value_type than the input time series.
Time series data must first be aligned (see per_series_aligner) in order
to perform cross-time series reduction. If cross_series_reducer is
specified, then per_series_aligner must be specified, and must not be
ALIGN_NONE. An alignment_period must also be specified; otherwise, an
error is returned.
Parameter
Name
Description
var
int
Returns
Type
Description
$this
getGroupByFields
The set of fields to preserve when cross_series_reducer is
specified. The group_by_fields determine how the time series are
partitioned into subsets prior to applying the aggregation
operation. Each subset contains time series that have the same
value for each of the grouping fields. Each individual time
series is a member of exactly one subset. The
cross_series_reducer is applied to each subset of time series.
It is not possible to reduce across different resource types, so
this field implicitly contains resource.type. Fields not
specified in group_by_fields are aggregated away. If
group_by_fields is not specified and all the time series have
the same resource type, then the time series are aggregated into
a single output time series. If cross_series_reducer is not
defined, this field is ignored.
The set of fields to preserve when cross_series_reducer is
specified. The group_by_fields determine how the time series are
partitioned into subsets prior to applying the aggregation
operation. Each subset contains time series that have the same
value for each of the grouping fields. Each individual time
series is a member of exactly one subset. The
cross_series_reducer is applied to each subset of time series.
It is not possible to reduce across different resource types, so
this field implicitly contains resource.type. Fields not
specified in group_by_fields are aggregated away. If
group_by_fields is not specified and all the time series have
the same resource type, then the time series are aggregated into
a single output time series. If cross_series_reducer is not
defined, this field is ignored.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-09-04 UTC."],[],[],null,["# Stackdriver Monitoring V3 Client - Class Aggregation (2.1.2)\n\nVersion latestkeyboard_arrow_down\n\n- [2.1.2 (latest)](/php/docs/reference/cloud-monitoring/latest/V3.Aggregation)\n- [2.1.1](/php/docs/reference/cloud-monitoring/2.1.1/V3.Aggregation)\n- [2.0.1](/php/docs/reference/cloud-monitoring/2.0.1/V3.Aggregation)\n- [1.12.1](/php/docs/reference/cloud-monitoring/1.12.1/V3.Aggregation)\n- [1.11.1](/php/docs/reference/cloud-monitoring/1.11.1/V3.Aggregation)\n- [1.10.3](/php/docs/reference/cloud-monitoring/1.10.3/V3.Aggregation)\n- [1.9.0](/php/docs/reference/cloud-monitoring/1.9.0/V3.Aggregation)\n- [1.8.0](/php/docs/reference/cloud-monitoring/1.8.0/V3.Aggregation)\n- [1.7.1](/php/docs/reference/cloud-monitoring/1.7.1/V3.Aggregation)\n- [1.6.0](/php/docs/reference/cloud-monitoring/1.6.0/V3.Aggregation)\n- [1.5.1](/php/docs/reference/cloud-monitoring/1.5.1/V3.Aggregation)\n- [1.4.0](/php/docs/reference/cloud-monitoring/1.4.0/V3.Aggregation)\n- [1.3.2](/php/docs/reference/cloud-monitoring/1.3.2/V3.Aggregation)\n- [1.2.2](/php/docs/reference/cloud-monitoring/1.2.2/V3.Aggregation) \nReference documentation and code samples for the Stackdriver Monitoring V3 Client class Aggregation.\n\nDescribes how to combine multiple time series to provide a different view of\nthe data. Aggregation of time series is done in two steps. First, each time\nseries in the set is *aligned* to the same time interval boundaries, then the\nset of time series is optionally *reduced* in number.\n\nAlignment consists of applying the `per_series_aligner` operation\nto each time series after its data has been divided into regular\n`alignment_period` time intervals. This process takes *all* of the data\npoints in an alignment period, applies a mathematical transformation such as\naveraging, minimum, maximum, delta, etc., and converts them into a single\ndata point per period.\nReduction is when the aligned and transformed time series can optionally be\ncombined, reducing the number of time series through similar mathematical\ntransformations. Reduction involves applying a `cross_series_reducer` to\nall the time series, optionally sorting the time series into subsets with\n`group_by_fields`, and applying the reducer to each subset.\nThe raw time series data can contain a huge amount of information from\nmultiple sources. Alignment and reduction transforms this mass of data into\na more manageable and representative collection of data, for example \"the\n95% latency across the average of all tasks in a cluster\". This\nrepresentative data can be more easily graphed and comprehended, and the\nindividual time series data is still available for later drilldown. For more\ndetails, see [Filtering and\naggregation](https://cloud.google.com/monitoring/api/v3/aggregation).\n\nGenerated from protobuf message `google.monitoring.v3.Aggregation`\n\nNamespace\n---------\n\nGoogle \\\\ Cloud \\\\ Monitoring \\\\ V3\n\nMethods\n-------\n\n### __construct\n\nConstructor.\n\n### getAlignmentPeriod\n\nThe `alignment_period` specifies a time interval, in seconds, that is used\nto divide the data in all the\n[time series](/php/docs/reference/cloud-monitoring/latest/V3.TimeSeries) into consistent blocks of\ntime. This will be done before the per-series aligner can be applied to\nthe data.\n\nThe value must be at least 60 seconds. If a per-series\naligner other than `ALIGN_NONE` is specified, this field is required or an\nerror is returned. If no per-series aligner is specified, or the aligner\n`ALIGN_NONE` is specified, then this field is ignored.\nThe maximum value of the `alignment_period` is 104 weeks (2 years) for\ncharts, and 90,000 seconds (25 hours) for alerting policies.\n\n### hasAlignmentPeriod\n\n### clearAlignmentPeriod\n\n### setAlignmentPeriod\n\nThe `alignment_period` specifies a time interval, in seconds, that is used\nto divide the data in all the\n[time series](/php/docs/reference/cloud-monitoring/latest/V3.TimeSeries) into consistent blocks of\ntime. This will be done before the per-series aligner can be applied to\nthe data.\n\nThe value must be at least 60 seconds. If a per-series\naligner other than `ALIGN_NONE` is specified, this field is required or an\nerror is returned. If no per-series aligner is specified, or the aligner\n`ALIGN_NONE` is specified, then this field is ignored.\nThe maximum value of the `alignment_period` is 104 weeks (2 years) for\ncharts, and 90,000 seconds (25 hours) for alerting policies.\n\n### getPerSeriesAligner\n\nAn `Aligner` describes how to bring the data points in a single\ntime series into temporal alignment. Except for `ALIGN_NONE`, all\nalignments cause all the data points in an `alignment_period` to be\nmathematically grouped together, resulting in a single data point for\neach `alignment_period` with end timestamp at the end of the period.\n\nNot all alignment operations may be applied to all time series. The valid\nchoices depend on the `metric_kind` and `value_type` of the original time\nseries. Alignment can change the `metric_kind` or the `value_type` of\nthe time series.\nTime series data must be aligned in order to perform cross-time\nseries reduction. If `cross_series_reducer` is specified, then\n`per_series_aligner` must be specified and not equal to `ALIGN_NONE`\nand `alignment_period` must be specified; otherwise, an error is\nreturned.\n\n### setPerSeriesAligner\n\nAn `Aligner` describes how to bring the data points in a single\ntime series into temporal alignment. Except for `ALIGN_NONE`, all\nalignments cause all the data points in an `alignment_period` to be\nmathematically grouped together, resulting in a single data point for\neach `alignment_period` with end timestamp at the end of the period.\n\nNot all alignment operations may be applied to all time series. The valid\nchoices depend on the `metric_kind` and `value_type` of the original time\nseries. Alignment can change the `metric_kind` or the `value_type` of\nthe time series.\nTime series data must be aligned in order to perform cross-time\nseries reduction. If `cross_series_reducer` is specified, then\n`per_series_aligner` must be specified and not equal to `ALIGN_NONE`\nand `alignment_period` must be specified; otherwise, an error is\nreturned.\n\n### getCrossSeriesReducer\n\nThe reduction operation to be used to combine time series into a single\ntime series, where the value of each data point in the resulting series is\na function of all the already aligned values in the input time series.\n\nNot all reducer operations can be applied to all time series. The valid\nchoices depend on the `metric_kind` and the `value_type` of the original\ntime series. Reduction can yield a time series with a different\n`metric_kind` or `value_type` than the input time series.\nTime series data must first be aligned (see `per_series_aligner`) in order\nto perform cross-time series reduction. If `cross_series_reducer` is\nspecified, then `per_series_aligner` must be specified, and must not be\n`ALIGN_NONE`. An `alignment_period` must also be specified; otherwise, an\nerror is returned.\n\n### setCrossSeriesReducer\n\nThe reduction operation to be used to combine time series into a single\ntime series, where the value of each data point in the resulting series is\na function of all the already aligned values in the input time series.\n\nNot all reducer operations can be applied to all time series. The valid\nchoices depend on the `metric_kind` and the `value_type` of the original\ntime series. Reduction can yield a time series with a different\n`metric_kind` or `value_type` than the input time series.\nTime series data must first be aligned (see `per_series_aligner`) in order\nto perform cross-time series reduction. If `cross_series_reducer` is\nspecified, then `per_series_aligner` must be specified, and must not be\n`ALIGN_NONE`. An `alignment_period` must also be specified; otherwise, an\nerror is returned.\n\n### getGroupByFields\n\nThe set of fields to preserve when `cross_series_reducer` is\nspecified. The `group_by_fields` determine how the time series are\npartitioned into subsets prior to applying the aggregation\noperation. Each subset contains time series that have the same\nvalue for each of the grouping fields. Each individual time\nseries is a member of exactly one subset. The\n`cross_series_reducer` is applied to each subset of time series.\n\nIt is not possible to reduce across different resource types, so\nthis field implicitly contains `resource.type`. Fields not\nspecified in `group_by_fields` are aggregated away. If\n`group_by_fields` is not specified and all the time series have\nthe same resource type, then the time series are aggregated into\na single output time series. If `cross_series_reducer` is not\ndefined, this field is ignored.\n\n### setGroupByFields\n\nThe set of fields to preserve when `cross_series_reducer` is\nspecified. The `group_by_fields` determine how the time series are\npartitioned into subsets prior to applying the aggregation\noperation. Each subset contains time series that have the same\nvalue for each of the grouping fields. Each individual time\nseries is a member of exactly one subset. The\n`cross_series_reducer` is applied to each subset of time series.\n\nIt is not possible to reduce across different resource types, so\nthis field implicitly contains `resource.type`. Fields not\nspecified in `group_by_fields` are aggregated away. If\n`group_by_fields` is not specified and all the time series have\nthe same resource type, then the time series are aggregated into\na single output time series. If `cross_series_reducer` is not\ndefined, this field is ignored."]]