A query always starts with a log type and can include one or more conditions to filter the results.
Query Format
Use the following format to search logs:
logtype="logtype_name" and conditions
Where:
logtype - Specifies the type of logs to search.
logtype_name - The display name of the log type, such as access, execute, application, or schedule.
conditions - Additional criteria used to filter matching logs.
Example:
logtype="access" and request_uri contains "/api"
This query returns Access Logs where the request URI contains /api.
The query language supports logical, numeric, string, and null-check operators for filtering logs.
Operator | Description |
and | Adds another condition that must also match. |
or | Adds an alternative condition. |
isEmpty | Finds logs where the selected field has no value. |
isNotEmpty | Finds logs where the selected field has a value. |
Operator | Description |
> | Greater than |
< | Less than |
= | Equal to |
>= | Greater than or equal to |
<= | Less than or equal to |
Example:
logtype="access" and time_taken > 5000
Returns logs where the request took more than 5000 milliseconds.
Operator | Description |
= | Exact match |
!= | Does not match |
contains | Contains the specified text. |
Example:
logtype="application" and message contains "timeout"
Returns application logs containing the word timeout.
Aggregation operators are used to summarize and analyze log data.
Examples include:
count
count_distinct
sum
avg
groupby
histo
timeslice
For detailed information, refer to Aggregation Queries.
The query language supports two main types of queries:
Log Fetch Queries
Aggregation Queries
Log Fetch Queries are used to retrieve logs that match specific criteria.
Syntax:
When specifying time-based values in queries, use the following notation:
Time Unit | Notation |
1 Second | 1s |
1 Minute | 1m |
1 Hour | 1h |
1 Day | 1d |
Examples:
Find Access Logs where the request took less than 10 seconds:
logtype="access" and time_taken < 10s
Retrieve logs containing specific text:
logtype="application" and message contains "validation failed"
Aggregation Queries are used to summarize and analyze log data rather than displaying individual log records.
These queries help answer questions such as:
How many logs match a condition?
Which module generated the most failures?
Which request URI is accessed most frequently?
What is the average execution time?
How many requests, executions, or scheduled activities occurred during a specific time interval (for example, every minute, hour, or day)?
Format :
logtype="logtype_name" and condition groupby field_name timeslice interval
For detailed information, refer to Aggregation Queries.
Always start with a logtype.
Use and to narrow results.
Use or to broaden results.
Use contains for partial text searches.
Use exact matches (=) when searching for specific values.
Use auto-suggestions to discover available fields and supported values.
Retrieve all Access Logs:
logtype="access"
Get access details for a specific user:
logtype="access" and zuid="5873965"
Get successful requests:
logtype="access" and status>=200 and status<300
Get server error requests:
logtype="access" and status>=400
Aggregation queries help you analyze and summarize log data instead of retrieving individual log records.
They are useful when you need insights such as counts, trends, distributions, performance metrics, and frequently occurring values.
For example, aggregation queries can help answer questions such as:
How many failed executions occurred?
Which module generated the most failures?
What is the average execution time?
How many unique users accessed a service?
How has activity changed over time?
Aggregation queries use aggregation operators to summarize or group matching logs.
Examples:
Count matching logs:
logtype="access" count
Group logs by a field:
logtype="access" groupby status
Analyze activity over time:
logtype="access" timeslice 1h
The Logs query language supports two types of aggregation:
Metric Aggregation
Bucket Aggregation
Metric aggregations calculate values from matching logs and return summarized results.
Supported Operators
Operator | Description |
count | Returns the number of matching log records. |
count_distinct | Returns the count of unique values in a field. |
sum | Returns the total value of a field. |
min | Returns the minimum value of a field. |
max | Returns the maximum value of a field. |
avg | Returns the average value of a field. |
sd | Returns the standard deviation of a field. |
stats | Returns minimum, maximum, average, sum, variance, and standard deviation values. |
percentile | Returns percentile ranges for a field. |
top | Returns sample or frequently occurring values from a field. |
Metric aggregations are commonly used for performance analysis, usage statistics, and identifying trends in numeric data.
Bucket aggregations group logs into categories or intervals.
Supported Operators
Operator | Description |
groupby | Groups logs by unique values in a field. |
distinct | Returns unique values from a field. |
histo | Groups numeric values into intervals or ranges. |
timeslice | Groups logs into time intervals. |
Option | Description |
sort | Sorts aggregation results. |
limit | Limits the number of results returned. |
having | Filters aggregation results after grouping. |
The having operator is not supported with the histo operator.
The groupby operator groups logs based on a selected field.
Syntax:
logtype="logtype_name" groupby field_name
Multiple groupby Fields
logtype="logtype_name" groupby field1, field2
You can group results using up to 4 fields in a single query.Sort by field value:
logtype="access" groupby zuid sort _field desc
Sort by count:
logtype="access" groupby zuid sort _count asc
Limiting Results:
logtype="access" groupby zuid limit 100
Filtering Aggregated Results:
logtype="access" groupby request_url having _count > 1000
groupby can only be used on supported fields.
Results sorted by _count cannot be paginated.
String values longer than 100 characters may be truncated.
Counts and top values may be approximate in very large datasets.
In large datasets, grouped counts and top values may be approximate due to the distributed nature of log indexing and aggregation.
The histo operator groups numeric values into intervals.
Syntax:
logtype="logtype_name" histo field_name interval
Example:
logtype="access" histo time_taken 1000
logtype="access" histo time_taken range(10,10 to 100,100 to 1000,1000)
This groups values into:
Less than 10 ms
10 ms to 100 ms
100 ms to 1000 ms
Greater than 1000 ms
The timeslice operator groups logs into time intervals.
Supported Units
Time Unit | Notation |
1 Second | 1s |
1 Minute | 1m |
1 Hour | 1h |
1 Day | 1d |
Syntax:
logtype="logtype_name" timeslice interval
Example:
logtype="access" timeslice 1h
Sort by count:
logtype="access" timeslice 5m sort _count
Sort by interval:
logtype="access" timeslice 5m sort _field desc
Aggregation results can be sorted using calculated values.
Example:
logtype="access" groupby request_url sort avg(time_taken) desc
logtype="access" groupby request_url having _count > 1000 sort avg(time_taken) desc
The count operator can only be used at the end of a query.
Valid:
logtype="execute" and status="failed" count
Invalid:
logtype="execute" count and status="failed"
After the count operator, no additional criteria or aggregation operators can be added.
The count and count_distinct operators cannot be used together in the same query.
Find the maximum time taken to process a request
logtype="access" max(time_taken)
Get maximum and minimum processing time for card creation requests
logtype="access" and request_url contains "/job" and method contains "post" max(time_taken)
min(time_taken)
Get unique URLs that took more than 10 seconds to process
logtype="access" and time_taken > 10s groupby request_url
Get frequently accessed request URLs with count
logtype="access" count(request_url) groupby request_url
Get frequently accessing remote IP for each module
logtype="access" distinct(zuid) groupby _zl_host
Get log distribution over time
logtype="access" and request_url contains "/job" timeslice 1h