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.

Examples

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.

    1. Create a basic query on the Metrics Explorer page.
    2. If the query isn't open, open it by clicking Edit queries.
    3. Click Advanced mode.
    4. 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 nest multiple queries (within 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 nest multiple queries (within the MQL expression).