All Products
Search
Document Center

Simple Log Service:SPL instructions and functions

Last Updated:Aug 15, 2025

This topic describes SPL instructions.

Parameter types

The following table describes the parameter types used in SPL instructions.

Parameter type

Description

Bool

A Boolean parameter. When you use SPL, this parameter works as a switch.

Char

An ASCII character parameter. It must be enclosed in single quotation marks (''). For example, 'a' represents the character a, '\t' represents the tab character, '\11' represents the ASCII character corresponding to the octal number 11, and '\x09' represents the ASCII character corresponding to the hexadecimal number 09.

Integer

An integer parameter.

String

A string parameter. It must be enclosed in single quotation marks (''). For example, 'this is a string'.

RegExp

An RE2 regular expression parameter. It must be enclosed in single quotation marks (''). For example, '([\d.]+)'.

For more information about the syntax, see Syntax.

JSONPath

A JSON path parameter. It must be enclosed in single quotation marks (''). For example, '$.body.values[0]'.

For more information about the syntax, see JsonPath.

Field

A field name parameter. For example, | project level, content.

If a field name contains special characters other than letters, digits, and underscores, enclose the field name in double quotation marks (""). For example, | project "a:b:c".

Note

For more information about the case sensitivity of field names, see General reference.

FieldPattern

A combination of a field name and a wildcard character, or a field name parameter. The wildcard character (*) is supported, which matches zero or more characters. It must be enclosed in double quotation marks (""). For example, | project "__tag__:*".

Note

For more information about the case sensitivity of field names, see General reference.

SPLExp

An SPL expression parameter.

SQLExp

An SQL expression parameter.

SPL instruction list

Instruction category

Instruction name

Description

Data transformation

Write processor

Consume processor

Scan mode (SCAN)

Logtail collection

Control instructions

.let

Defines a named dataset. For more information about SPL datasets, see General reference.

×

×

×

Field operation instructions

project

Retains fields that match a specified pattern and renames specified fields. During execution, all field retention expressions are processed before renaming expressions.

project-away

Removes fields that match a specified pattern and retains all other fields.

project-rename

Renames specified fields and retains all other fields.

expand-values

Expands the first-layer JSON object of a specified field to generate multiple results.

×

×

×

SQL calculation instructions for structured data

extend

Creates new fields by calculating the results of SQL expressions. For a list of supported SQL functions, see List of SQL functions supported by SPL.

where

Filters data based on an SQL expression and retains data entries that meet the expression. For a list of SQL functions supported by the where instruction, see List of SQL functions supported by SPL.

Semi-structured data extraction instructions

parse-regexp

Extracts information that matches regular expression groups from a specified field.

parse-csv

Extracts information in CSV format from a specified field.

parse-json

Extracts first-layer JSON information from a specified field.

parse-kv

Extracts key-value pair information from a specified field.

New data transformation instructions

pack-fields

Packs log fields and outputs them to a new field through JSON serialization. This instruction is suitable for scenarios that require structured transmission, such as building an API request body.

×

×

log-to-metric

Converts the log format to the metric storage format.

×

×

×

×

metric-to-metric

Further processes existing metric data, such as adding, modifying, or removing tags.

×

×

×

×

Aggregation instructions

stats

An instruction for statistical analysis of logs, similar to SQL aggregate functions such as COUNT, SUM, and AVG. It performs statistics, grouping, and aggregation operations on specific fields in log data.

×

×

×

×

sort

Sorts query results. It supports sorting field values or statistical results in ascending (asc) or descending (desc) order. It is an important tool for quickly locating key data and generating ordered reports in log analysis.

×

×

×

×

limit

Limits the number of log rows returned in query results. This is a core instruction for controlling data volume. Using the limit instruction prevents performance issues or resource waste from large query results. It is suitable for scenarios such as log analysis and real-time monitoring.

×

×

×

×

Function overview

SPL instructions support most SQL functions. However, the availability and applicable scenarios for specific functions are described in the corresponding function documentation.

Classification

Description

Common functions

Aggregate functions

Perform summary calculations on the target dataset to generate a single statistical result.

String functions

Process text data, including search, replace, substring, concatenate, and format.

Date and time functions

Perform format conversion, grouping, and aggregation on dates and times in logs.

JSON functions

Process JSON objects, including extraction, transformation, and statistics.

Regular expression functions

Pattern matching and text processing.

Year-on-year and month-on-month functions

Calculate relative changes in time series data.

Array functions and operators

Perform addition, deletion, modification, query, traversal, and transformation on arrays.

Map mapping functions and operators

Operate on key-value pairs.

Mathematical calculation functions

Numerical calculations, rounding, random numbers, trigonometric functions, and more.

Mathematical statistics functions

Data distribution analysis and numerical calculations.

Type conversion functions

Handle conversions between data types.

Window functions

Aggregation or sorting based on data windows.

IP functions

Parse and calculate IP addresses.

URL functions

Parse URL structures.

Estimation functions

Predict data or fill in missing values.

Binary functions

Process binary data types.

Bitwise operation functions

Directly operate on binary bits.

Spatial geometry functions

Process spatial geometries.

Geographic functions

Geographic location analysis and map calculations.

Color functions

Color representation and conversion.

HyperLogLog functions

Perform statistical processing on large datasets, sacrificing accuracy to save memory.

Comparison operators

Determine the size relationship of parameters, applicable to any comparable data type (double, bigint, varchar, timestamp, and date).

Logical operators

Combine multiple Boolean conditions to control logical flow.

Unit conversion functions

Convert units of data size or time intervals.

Window funnel functions

Analyze user behavior, app traffic, product goal conversion, and other data.

Lambda expressions

Define lambda expressions in SQL analytic statements and SPL statements, and pass them to specified functions to enrich the expression of functions.

Conditional expressions

Return different values based on conditional branches.