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: Greater than 80 Percent for Mean CPU Utilization
CpuUtilization[1m].mean() > 80
Example 2: Between 60 and 80 Percent for Mean CPU Utilization
CpuUtilization[1m].mean() in (60, 80)
Example 3: Greater than 1 for Errors
ServiceConnectorHubErrors[1m].count() > 1
Example 4: Greater than 85 for 90th Percentile CPU Utilization (Selecting an Availability Domain and Grouping by Pool)
CpuUtilization[1m]{availabilityDomain = "VeBZ:PHX-AD-1"}.groupBy(poolId).percentile(0.9) > 85
Example 5: At Least 20 for Minimum CPU Utilization (Selecting Either "ol8" or "ol7")
CpuUtilization[1m]{resourceDisplayName =~ "ol8|ol7"}.min() >= 20
Example 6: At Least 30 for Minimum CPU Utilization (Selecting Instance Names Beginning with "instance-2023-")
CpuUtilization[1m]{resourceDisplayName =~ "instance-2023-*"}.min() >= 30
Example 7: Absence of CPU Utilization Metrics for Specified Resource
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> [...]

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