Nesting Queries in an MQL Expression
Nest multiple queries in a single MQL expression for querying metric data in Monitoring.
In a nested query, the alarm portion appears at the beginning (surrounded with parentheses), followed by the optional group function and required statistic.
For query troubleshooting, see Troubleshooting Queries.
- Example 1: Sum of Hosts with CPU utilization Greater than 80 Percent
(CpuUtilization[1m].max() > 80).grouping().sum()
- Example 2: Sum of Availability Domains with a Success Rate Lower than 0.99
(SuccessRate[1m].groupBy(availabilityDomain).mean() < 0.99).grouping().sum()
- Example 3: Count of Hosts with Up Time Greater than Zero
(metric[1h].groupBy(host).min() > 0).grouping().count()
This section describes how to nest queries within a single MQL expression on the Metrics Explorer page. Nesting is available in Advanced mode (MQL) only. For alarm query edits, see Editing the MQL Expression When Creating an Alarm.
- If the query isn't open, open it by clicking Edit queries.
- Click Advanced mode.
- Edit the text in the Query code editor box.
- Click Update Chart.
Use the oci monitoring metric-data summarize-metrics-data command and required parameters to query metric data. Use the
--query-textparameter to nest multiple queries (within 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
queryattribute to nest multiple queries (within the MQL expression).