Using groupBy(x) in a Query
Use the optional groupBy(x)
element when querying metric data in Monitoring.
Aggregate query results by group to plot a value for each group. This option returns the combined value of all metric streams in each specified group for the selected statistic. Each group's combined value is plotted as a single line on the metric chart. This option is helpful when you want to identify trends by group rather than individual resource.
For query troubleshooting, see Troubleshooting Queries.
Examples
- Example 1: Group by Fault Domain
-
CpuUtilization[1m].groupBy(faultDomain).mean()
- Example 2: Group by Resource Group
-
CpuUtilization[1m].groupBy(resourceGroup).mean()
This section describes how to use
groupBy(x)
on the Metrics Explorer page.groupBy(x)
is available in Advanced mode (MQL) only. For alarm query edits, see Creating a Basic Alarm.Use the oci monitoring metric-data summarize-metrics-data command and required parameters to query metric data. Use the
--query-text
parameter to employ thegroupBy(x)
element (part of the MQL expression).oci monitoring metric-data summarize-metrics-data --query-text <mql_expression> [...]
For a complete list of parameters and values for CLI commands, see the Command Line Reference for Monitoring.
Run the SummarizeMetricsData operation to query metric data. Use the
query
attribute to employ thegroupBy(x)
element (part of the MQL expression).