Using filter(x) in a Query

Use filter(x) to remove values from the metric streams in the returned data, where the metric streams are defined by the previous query components.

Example: Remove Values Less than 20
CpuUtilization[1m].mean().filter(x=>x>20)

For query troubleshooting, see Troubleshooting Queries.

  • This section describes how to use filter(x) on the Metrics Explorer page. filter(x) is 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 selecting Edit queries.
    3. Select Advanced mode.
    4. Edit the text in the Query code editor box.

      The following example MQL expression includes only values greater than 20.

      CpuUtilization[1m].mean().filter(x=>x>20)

      The graph from Example Query and Metric Chart now shows only those values higher than 20. In addition to the 85% value at 1:30, a constant 21% value is shown in another metric stream over the time displayed in the graph.

      Manipulated values in a graph.

    5. Select 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 employ the filter(x) element (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 employ the filter(x) element (part of the MQL expression).