Aggregating Metric Streams in a Query
Aggregate metric streams ((grouping()
) returns the combined value of all metric streams for the selected statistic.
If
grouping()
(Aggregate Metric Streams) is used, then only one stream is tracked. Don’t use grouping()
with split notifications.The Aggregate metric streams option is equivalent to grouping()
in the MQL expression. Aggregate all metric streams to return the combined value of all metric streams for the selected statistic. For example, aggregate all metric streams for CPU Utilization to return the combined value across all resources .
By default, a chart represents each metric stream with a line, which results in multiple lines per chart. When you aggregate metric streams, a chart represents all metric streams with a single line, which results in just one line per chart.
For query troubleshooting, see Troubleshooting Queries.
Examples
- Example 1: Aggregate Metric Streams for count()
-
ServiceConnectorHubErrors[1m].grouping().count()
- Example 2: Aggregate Metric Streams for max()
-
IopsRead[1m]{compartmentID = "<compartment_OCID>"}.grouping().max()
In this example, the query returns the maximum (
max()
)IopsRead
metric data at a one-minute interval, filtered to a compartment, with all results aggregated.
This section describes how to aggregate metric streams (use
grouping()
) on the Metrics Explorer page. Aggregate metric streams ((grouping()
) returns the combined value of all metric streams for the selected statistic. For alarm query edits, see Creating an Alarm.- Create a basic query on the Metrics Explorer page.
- If necessary, open the query for editing: Click Edit queries.
- To aggregate metric streams using Basic mode (default), select Aggregate metric streams.
-
To aggregate metric streams by updating the MQL expression, do the following.
- Click Advanced mode.
- Edit the text in Query code editor.
- Click Update Chart.
Use the oci monitoring metric-data summarize-metrics-data command and required parameters to query metric data. Use the
--query-text
parameter to employ thegrouping()
element (part of the MQL expression).oci monitoring metric-data summarize-metrics-data [...] --query-text <mql_expression> [OPTIONS]
For a complete list of flags and variable options for CLI commands, see the Command Line Reference for Monitoring.
Run the SummarizeMetricsData operation to query metric data. Use the
query
attribute to employ thegrouping()
element (part of the MQL expression).