All Products
Search
Document Center

Simple Log Service:SPL instructions and functions

Last Updated:Jun 08, 2026

SPL provides instructions for field operations, data extraction, filtering, aggregation, and data transformation. Each instruction supports specific processing scenarios such as data transformation, Ingest Processor, Consumer Processor, scan mode, and Logtail collection.

Parameter types

SPL instructions use the following parameter types.

Parameter type

Description

Bool

A Boolean parameter that acts as a switch in SPL.

Char

An ASCII character parameter, enclosed in single quotation marks (''). Examples: 'a' for the character a, '\t' for the tab character, '\11' for the ASCII character of octal 11, and '\x09' for the ASCII character of hexadecimal 09.

Integer

An integer parameter.

String

A string parameter, enclosed in single quotation marks (''). Example: 'this is a string'.

RegExp

An RE2 regular expression parameter, enclosed in single quotation marks (''). Example: '([\d.]+)'.

RE2 syntax details: Syntax.

JSONPath

A JSON path parameter, enclosed in single quotation marks (''). Example: '$.body.values[0]'.

JSONPath syntax details: JsonPath.

Field

A field name parameter. Example: | project level, content.

Enclose field names that contain special characters (other than letters, digits, and underscores) in double quotation marks (""). Example: | project "a:b:c".

Note

Field name case sensitivity rules are documented in General reference.

FieldPattern

A field name or wildcard pattern. The wildcard (*) matches zero or more characters. Enclose patterns in double quotation marks (""). Example: | project "__tag__:*".

Note

Field name case sensitivity rules are documented in General reference.

SPLExp

An SPL expression parameter.

SQLExp

An SQL expression parameter.

SPL instruction list

Instruction category

Instruction name

Description

Data transformation

Ingest Processor

Consumer Processor

Scan mode (SCAN)

Logtail collection

Control instruction

.let

Defines a named dataset. SPL dataset details are covered in General reference.

Yes

×

×

×

Field operation instruction

project

Retains fields matching a specified pattern and renames specified fields. Field retention expressions are processed before renaming expressions.

Supported

Supported

Supported

Supported

Supported

project-away

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

Supported

Supported

Supported

Supported

project-rename

Renames specified fields and retains all other fields.

Supported

Supported

Supported

Supported

Supported

expand-values

Expands the top-level JSON object of a specified field into multiple results.

Supported

×

Supported

Unsupported

×

SQL calculation instruction for structured data

extend

Creates new fields from SQL expression results. Supported SQL functions are listed in List of SQL functions supported by SPL.

Supported

Supported

Supported

Supported

Supported

where

Filters data by an SQL expression and retains matching entries. Supported SQL functions are listed in List of SQL functions supported by SPL.

Supported

Supported

Supported

Supported

Semi-structured data extraction instruction

parse-regexp

Extracts information matching regular expression groups from a specified field.

Supported

Supported

parse-csv

Extracts information in CSV format from a specified field.

Supported

Supported

Supported

parse-json

Extracts top-level JSON fields from a specified field.

Supported

Supported

Supported

parse-kv

Extracts key-value pair information from a specified field.

Supported

Supported

Supported

Supported

Supported

New data transformation instruction

pack-fields

Packs log fields into a new field through JSON serialization. Suitable for structured transmission scenarios such as building API request bodies.

×

Supported

×

log-to-metric

Converts log format to time series storage format.

Supported

×

×

×

×

metric-to-metric

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

Supported

×

×

×

×

Aggregation instruction

stats

Performs statistical analysis on log fields, similar to SQL aggregate functions such as COUNT, SUM, and AVG. Supports grouping and aggregation on specific fields.

×

×

Unsupported

Supported

×

sort

Sorts query results by field values or statistical results in ascending (asc) or descending (desc) order.

×

×

×

Supported

×

limit

Limits the number of log rows returned in query results. Use limit to control data volume and avoid performance issues from large result sets.

×

×

×

Supported

×

Function overview

SPL instructions support most SQL functions. Availability and applicable scenarios for each function are described in their respective documentation.

Category

Description

Common functions

Aggregate functions

Computes a single result from a set of input values.

String functions

Finds, replaces, extracts, concatenates, and formats text data.

Date and time functions

Converts, truncates, and aggregates date and time values.

JSON functions

Extracts, transforms, and queries data from JSON objects and arrays.

Regular expression functions

Matches, extracts, and replaces text using regular expressions.

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

Compares time-series data across different time periods.

Array functions and operators

Accesses, filters, and transforms array elements.

map functions and operators

Operates on key-value pairs (maps).

Mathematical functions

Rounds, generates random numbers, and performs trigonometric calculations.

Mathematical and statistical functions

Analyzes data distributions with correlation, regression, and probability functions.

Type conversion functions

Converts values from one data type to another.

Window functions

Computes aggregations or rankings over a sliding window of rows.

IP functions

Parses and processes IP addresses.

URL functions

Extracts components from URLs.

Estimation functions

Approximates distinct counts, percentiles, and histograms for large datasets.

Binary functions

Operates on binary data.

Bitwise operation functions

Performs bitwise operations on integers.

Spatial geometry functions

Operates on spatial geometry objects.

Geographic functions

Performs geospatial analysis and calculations.

Color functions

Creates and manipulates color representations.

HyperLogLog functions

Estimates cardinality on large datasets with minimal memory.

Comparison operators

Compares values across types (double, bigint, varchar, timestamp, date) and returns a boolean.

Logical operators

Combines multiple boolean expressions to control logical flow.

Unit conversion functions

Converts data sizes or time intervals between different units.

Window funnel functions

Tracks sequential user actions for conversion funnel analysis.

lambda expressions

Defines inline functions for higher-order array operations in SQL or SPL.

Conditional expressions

Returns different values based on a specified condition.