Latest IP Integration:OTEL Collector for Rivian
Back to Resources
Blog

Mastering OCI Logging Analytics Query Language: A Beginner's Guide

Cam Jones·March 10, 2025

In a previous blog post, we introduced Logging Analytics and walked through setting up your first logging source. Now, it's time to dive into the OCI Logging Analytics Query Language — a powerful query language that enables you to filter, aggregate, and transform log data to uncover meaningful insights.

Understanding Query Language Components

The query language comprises several key elements:

  • Search Strings — Used to find specific keywords in logs. You can leverage REGEX or Boolean operators for precise filtering.
  • Commands — Perform operations on log records, such as creating new fields, calculating values, or generating statistics. For example, the stats command aggregates results. Commands are highlighted blue in the query editor.
  • Functions — Transform data, such as counting unique occurrences of a field using distinctcount. Functions are highlighted green.
  • Operators — Logical operators like and, or, and not in help refine queries further. These appear in purple.
  • Arguments — Specific parameters that modify functions.
  • Function Clauses — Allow renaming fields or making values more readable. These are highlighted orange.

Query Example: Aggregating Log Records

Consider the following query:

* | stats count as logrecords by 'Log Source' | sort -logrecords

Breaking It Down:

  1. * — This wildcard pulls all log records (our search string).
  2. | — The pipe operator chains commands together.
  3. stats count as logrecords by 'Log Source'
    • stats aggregates the results.
    • count calculates the total number of log records per Log Source.
    • as logrecords renames the count field to logrecords for better readability.
  4. | sort -logrecords — Sorts the results in descending order.

Query Execution and Visualization

When you run this query in OCI Logging Analytics, you'll see a structured table of log sources ranked by the number of log records.

Beyond just text-based queries, OCI provides an intuitive UI that simplifies analysis:

  1. Auto-complete suggestions — When typing "error," OCI suggests relevant fields and terms, speeding up query writing.

OCI Logging Analytics auto-complete suggestions

  1. Visualization options — Easily switch between tables, pie charts, histograms, and other formats to better interpret your data.

OCI Logging Analytics visualization options

Unlocking the Full Potential of Logging Analytics

OCI Logging Analytics Query Language is a powerful tool for filtering, transforming, and visualizing your log data. Whether you're troubleshooting issues or monitoring system performance, mastering queries will help you extract meaningful insights efficiently.

We've only scratched the surface — stay tuned for our next posts, where we'll explore more advanced use cases and best practices for OCI Logging Analytics.

Not Sure Where to Start?

Take our free OTEL Maturity Assessment to identify gaps and get a personalized action plan.

Take the Free Assessment