Aggregating Metric Streams in a Query

Aggregating metric streams returns 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.

The Aggregate metric streams option is equivalent to grouping() in the MQL expression.


If you aggregate metric streams, then only one stream is tracked. Don’t aggregate metric streams with split notifications.

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.


Example 1: Aggregate Metric Streams for count()

In example 1, the query returns the count (count()) of errors at a one-minute interval, with all results aggregated.

Example 2: Aggregate Metric Streams for max()
IopsRead[1m]{compartmentID = "<compartment_OCID>"}.grouping().max()

In example 2, 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 on the Metrics Explorer page. For alarm query edits, see Creating a Basic Alarm.

    1. Create a basic query on the Metrics Explorer page.
    2. If the query isn't open, open it by clicking Edit queries.
    3. To aggregate metric streams by using Basic mode (default), select Aggregate metric streams.
    4. To aggregate metric streams by updating the MQL expression, follow these steps:
      1. Click Advanced mode.
      2. Edit the text in the Query code editor box.
    5. 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 the grouping() 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 the grouping() element (part of the MQL expression).