OpenSearch PPL language
This section contains a basic introduction to querying CloudWatch Logs using OpenSearch PPL. With PPL, you can retrieve, query, and analyze data using piped-together commands, making it easier to understand and compose complex queries. Its syntax is based on Unix pipes, and enables chaining of commands to transform and process data. With PPL, you can filter and aggregate data, and use a rich set of math, string, date, conditional, and other functions for analysis.
You can use OpenSearch PPL only for queries of log groups in the Standard Log Class.
For information about all OpenSearch PPL query commands supported in CloudWatch Logs and detailed information about syntax and restrictions, see Supported PPL commands in the OpenSearch Service Developer Guide.
Command or function | Example query | Description |
---|---|---|
fields |
|
Displays a set of fields which needs projection. |
where |
|
Filters the data based on the conditions that you specify. |
stats |
|
Performs aggregations and calculations |
parse |
|
Extracts a regular expression (regex) pattern from a string and displays the extracted pattern. The extracted pattern can be further used to create new fields or filter data. |
sort |
|
Sort the displayed results by a field name. Use sort -FieldName to sort in descending order. |
eval |
|
Modifies or processes the value of a field and stores it in a different field. This is useful to mathematically modify a column, apply string functions to a column, or apply date functions to a column. |
rename |
|
Renames one or more fields in the search result. |
head |
|
Limits the displayed query results to the first N rows. |
top |
|
Finds the most frequent values for a field. |
dedup |
|
Removes duplicate entries based on the fields that you specify. |
rare |
|
Finds the least frequent values of all fields in the field list. |
trendline |
|
Calculates the moving averages of fields. |
eventStats |
|
Enriches your event data with calculated summary statistics. It analyzes specified fields within your events, computes various statistical measures, and then appends these results to each original event as new fields. |
fieldsummary |
|
Calculates basic statistics for each field (count, distinct count, min, max, avg, stddev, and mean). |
grok |
|
Parses a text field with a grok pattern and appends the results to the search result. |
String functions |
|
Built-in functions in PPL that can manipulate and transform string and text data within PPL queries. For example, converting case, combining strings, extracting parts, and cleaning text. |
Math functions |
|
Built-in functions for performing mathematical calculations and transformations in PPL queries. For example, abs (absolute value), round (rounds numbers), sqrt (square root), pow (power calculation), and ceil (rounds up to nearest integer). |
Date functions |
|
Built-in functions for handling and transforming date and timestamp data in PPL queries. For example, date_add, date_format, datediff, and current_date. |
Condition functions |
|
Built-in functions that check for specific field conditions, and evaluate expressions conditionally. For example, if field1 is null, return field2. |
Math functions |
|
Built-in functions for performing mathematical calculations and transformations in PPL queries. For example, abs (absolute value), round (rounds numbers), sqrt (square root), pow (power calculation), and ceil (rounds up to nearest integer). |
CryptoGraphic functions |
|
To calculate the hash of given field |