> For the complete documentation index, see [llms.txt](https://docs.contextual.io/documentation-and-resources/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.contextual.io/documentation-and-resources/tenants/tenant-logs/contextual-log-query-language-clql.md).

# Contextual Log Query Language (CLQL)

Available to users in tenants which are on subscription plans that support advanced Agent Log features, the Contextual Log Query Language (CLQL) is a powerful and flexible way to search, filter, and isolate the details you need across Agent Message Logs to gain insights into your tenant's activities.

To get started:

1. Go to **Logs → All Logs** in your tenant, which will default to the Messages tab
2. Enter your query in CLQL Query Editor in the top right of the screen and press Enter or click Search to perform your query\\

   <figure><img src="https://2803907488-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FJF7AoTYz7NHacejws5p9%2Fuploads%2Fgit-blob-83051c2a90927262b50d500fe38b67d15c00c912%2Fimage.png?alt=media" alt=""><figcaption><p>CLQL Query Editor</p></figcaption></figure>

***

## Search Basics

CLQL’s search syntax uses a **pipeline** concept. By default, CLQL:

1. Pulls all log messages from the selected time range for your tenant.
2. Displays the most recent messages at the top

The time-range selector defaults to **Last 24 hours**, but this is a search-window default, not a retention setting. Searchable history is bounded by your tenant's configured retention period: 1, 7, or 30 days. The 1-day tier is the provisioning fallback/default. Selecting a time range that starts before the retained history does not return expired logs.

To narrow your search, add **keywords** and **operators** to refine your results until you find exactly what you need.

***

## Getting Started

Inside the editor (**Logs → All Logs - Message Tab**), a typical search query looks like this:

```graphql
keyword search | where | sort | limit
```

1. **Select a Time Range** from the drop-down (defaults to “Last 24 hours”)
2. Enter a simple key term (e.g. `error`) to match any messages containing that term in any field value
3. Press **Enter** or click **Search**
4. Contextual returns all log messages matching your search query in the **Messages** tab below

**Tip:** All queries should begin with a string or keyword search. You can combine multiple searches with spaces. If your query gets long, use *soft returns* (line breaks) to make it more readable.

## String, Keyword, and Advanced Operator Searches

Dig into the details of String Searches, Keyword Searches, and Advanced Operators.

{% content-ref url="/pages/34na1ygywLQSspWPUObl" %}
[String Searches](/documentation-and-resources/tenants/tenant-logs/contextual-log-query-language-clql/string-searches.md)
{% endcontent-ref %}

{% content-ref url="/pages/iVfgXYJpTfVepUGRzrtZ" %}
[Keyword Searches](/documentation-and-resources/tenants/tenant-logs/contextual-log-query-language-clql/keyword-searches.md)
{% endcontent-ref %}

{% content-ref url="/pages/CLRexX93LyLt51Q49GK6" %}
[Advanced Operators](/documentation-and-resources/tenants/tenant-logs/contextual-log-query-language-clql/advanced-operators.md)
{% endcontent-ref %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.contextual.io/documentation-and-resources/tenants/tenant-logs/contextual-log-query-language-clql.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
