Terminal
Terminal/Skill
Manages Alibaba Cloud SLS projects, logstores, Logtail configs and machine groups from the command line using the Alibaba Cloud CLI.
By Alibaba Cloud
Works with
npx skills add aliyun/aliyun-sls-agent-skills --skill alibabacloud-sls-cli-guidanceCommand-line interface for managing Alibaba Cloud Simple Log Service (SLS) resources including projects, logstores, Logtail configs, machine groups, and other non-query operations.
Before starting, verify that aliyun-cli and sls plugin are installed:
aliyun version
aliyun sls version
Expected output: aliyun-cli-sls 0.1.0 (5e6288421) or similar
If the check fails, follow references/cli-installation-guide.md to install aliyun-cli, then install the sls plugin:
aliyun plugin install --names sls
aliyun plugin update sls
Run aliyun configure list to check if credentials configured.
If no valid profile is shown, STOP here and ask the user to run aliyun configure outside of this session.
Security rules:
aliyun configure list to check credential statusWhen this skill is loaded, generate one random session ID for the session: a 32-character lowercase hex string.
Every aliyun command that calls a cloud API must include this User-Agent flag:
--user-agent "AlibabaCloud-Agent-Skills/alibabacloud-sls-cli-guidance/{session-id}"
Local utility commands do not call cloud APIs and should not include --user-agent, including aliyun version, aliyun configure ..., aliyun plugin ..., and aliyun help ....
Example:
aliyun sls list-project \
--offset 0 --size 50 \
--user-agent "AlibabaCloud-Agent-Skills/alibabacloud-sls-cli-guidance/a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6"
Use the alibabacloud-sls-query skill for all log query and analysis tasks. It covers SLS query & analysis syntax (index search, SQL, SPL), scenario examples, troubleshooting, and end-to-end query workflows — it is the required skill for querying SLS logs.
Use alibabacloud-sls-query when the user asks to:
get-logs-v2, query syntax, index/statistics prerequisitesIf the skill is already available, use it directly. If not, see alibabacloud-sls-query-installation to install and load it.
For project, logstore, index management, Logtail config, machine group, put-logs, and other non-query SLS operations, stay in this skill and refer to the reference docs below. Read the corresponding reference file first before executing any of them.
| Reference | Related commands | Description |
|---|---|---|
| project | list-project create-project get-project update-project delete-project | Manage SLS projects |
| logstore | list-log-stores create-log-store get-log-store update-log-store delete-log-store | Manage logstores within a project |
| index | get-index create-index update-index delete-index | Configure indexes to enable query and SQL analytics |
| put-json-logs | put-json-logs | Write logs to a logstore |
| logtail-config | create-logtail-pipeline-config update-logtail-pipeline-config get-logtail-pipeline-config list-logtail-pipeline-config delete-logtail-pipeline-config | Manage Logtail pipeline configs for log collection (file input, JSON/delimiter/regex parsing, multiline, time extraction) |
| machine-group | create-machine-group update-machine-group get-machine-group list-machine-group delete-machine-group apply-config-to-machine-group remove-config-from-machine-group get-applied-configs | Manage machine groups and apply Logtail configs to them |
aliyun help sls
aliyun help sls <apiName>
Add --cli-dry-run to validate parameters without executing:
aliyun sls list-project --offset 0 --size 50 --cli-dry-run
All commands return JSON by default. Use --cli-query with JMESPath expressions to filter output:
aliyun sls list-project --cli-query "projects[*].name"
--cli-dry-run: Validate command without execution--cli-query <jmespath>: Filter output with JMESPath--region <region>: Override region--help: Show command helpWhen a command fails or returns unexpected results, read references/troubleshooting.md for the full checklist, including:
ProjectNotExist, Unauthorized, InvalidParameter, etc.)ProjectNotExist)Do not use deprecated APIs — use the current replacement so behavior stays supported and predictable.
| Deprecated | Use instead |
|---|---|
get-logs | get-logs-v2 |
Obtain explicit user approval before any delete — delete operations are irreversible.
Use --cli-dry-run first for destructive operations (delete, update).
Update APIs require full parameters — first call the corresponding Get API to retrieve current parameters, then include all meaningful parameters in the update call (including unchanged ones). Omitting parameters may reset them to defaults.
If a command fails: follow references/troubleshooting.md.
Use skill alibabacloud-sls-query for log query and analysis.