Specifying a Predicate in a Query

Specify a predicate for querying metric data in Monitoring.

While typically used with alarms, you can also use predicates in queries for custom metric charts.

For valid predicate operators in MQL expressions, see Predicate Operators.

For query troubleshooting, see Troubleshooting Queries.

Examples
Example 1: Mean CPU Utilization Greater than 80 Percent (Threshold Predicate)
CpuUtilization[1m].mean() > 80
Example 2: Mean CPU Utilization Between 60 and 80 Percent (Threshold Predicate)
CpuUtilization[1m].mean() in (60, 80)
Example 3: Errors Greater than 1 (Threshold Predicate)
ServiceConnectorHubErrors[1m].count() > 1
Example 4: 90th Percentile CPU Utilization Greater than 85 (Threshold Predicate, Selecting an Availability Domain and Grouping by Pool)
CpuUtilization[1m]{availabilityDomain="VeBZ:PHX-AD-1"}.groupBy(poolId).percentile(0.9) > 85
Example 5: No CPU Utilization Metrics Emitted (Absence Predicate)
CpuUtilization[1m]{resourceId = "<resource_identifier>"}.groupBy(resourceId).absent()
absent() description: Returns true (1) if the metric is absent for the entire interval. Returns false (0) if the metric is present during the interval. Is ignored after two hours, not generating any values.
  • This section describes how to specify a predicate in a query on the Metrics Explorer page. On this page, predicates are available in Advanced mode (MQL) only. 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. Click Advanced mode.
    4. Edit the text in the Query code editor box.
      Example 1: Threshold Predicate
      > 80 is the threshold predicate in the following MQL expression.
      CpuUtilization[1m].mean() > 80
      The graph from Example Query and Metric Chart now shows a single value. The 85% value resolves to true (1) to indicate that it satisfies the MQL expression. (If no values exceeded 80, then the graph on the Metrics Explorer page would show "no data.")
      Threshold in a graph, Metrics Explorer page.
      Example 2: Absence Predicate
      absent() is the absence predicate in the following MQL expression.
      CpuUtilization[1m].absent()
      The graph from Example Query and Metric Chart now shows a "1" value for a metric stream. The "1" value in the graph indicates that the compute instance corresponding to this metric stream didn't emit CpuUtilization metric data until 1:30.
      Absent metric data in a graph, Metrics Explorer page.

      For valid predicate operators in MQL expressions, see Predicate Operators.

    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 specify a predicate (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 specify a predicate (part of the MQL expression). For an example, see SummarizeMetricsDataDetails.