Aliyun SLS SQL Generator

Generate common Aliyun Log Service SQL templates for page-view counts, time bucket aggregation, field grouping, URL filters, event filters, trackId aggregation, and records that contain one event but not another.

SLS SQL generator tool

Generated SQL is a template. Adjust field names and string or number types to match your own SLS log schema.

How to use this tool

Choose a template, enter optional filters such as su, type, trackType, or step, then review the generated SQL. The generator supports PV by minute, custom time buckets, group by field, simple filtered log queries, trackId aggregation, and a template for records with event A but without event B.

The generated SQL is meant as a starting point. Aliyun SLS projects often use different field names and field types, so you should verify whether each field is stored as a string or number before running the query in production.

Example

To count page views by 10-second buckets for a checkout URL, select the time bucket template, choose 10 seconds, and enter /checkout in the su filter. The generated SQL groups logs by a formatted time bucket and orders the result by time.

Frequently asked questions

What is Aliyun SLS SQL?

Aliyun SLS SQL is the query language used in Alibaba Cloud Log Service to filter, aggregate, and analyze log data.

How do I group logs by time bucket?

Use the timestamp field __time__, subtract the remainder for the bucket size, format it, and group by the bucket alias.

How do I filter by URL or event type?

Use su LIKE '%value%' for URL fragments and equality filters such as type = 6 or trackType = 1 for numeric event fields.

Can I run the generated SQL without changes?

Usually you should review it first. Field names, value types, and log table behavior may differ between SLS projects.

Privacy note

Your input is processed locally in your browser and is not uploaded to our server.

Related tools