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.
- 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, set to 20 hours for absence detection period
-
CpuUtilization[1m]{resourceId = "<resource_identifier>"}.groupBy(resourceId).absent(20)
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.
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.