CHECK STATUS DETAIL ---------------- ------ -------------------------------------------- config ok /path/to/slsb.config.json endpoint ok https://cn-shanghai.log.aliyuncs.com project ok k8s-log-... default logstore ok app-web connection ok connected, N logstores visible output ok format=table, maxColWidth=60
npm run build # tsc -> dist/ npm test# jest npm run typecheck # tsc --noEmit
许可证
ISC
slsb
Read-only Aliyun SLS (Log Service) query CLI for humans and AI agents.
slsb turns a log lookup into a single command with a stable JSON envelope, so both a person in a terminal and an agent parsing stdout get the same predictable result. No MCP server, no interactive paging, no hidden state.
Querying SLS by hand is a stack of things that quietly go wrong: which project, which logstore, which keyword shape, which time window. slsb collapses that into one command and returns:
ok / code / reason on failure, so failures are machine-readable
bounded output — every string field capped, total payload capped, so an agent does not pay for a 5 MB log row
an audit trail — one JSONL line per call, optional but recommended
Bare host or full URL; https:// is added if missing
project
yes
SLS project name
accessKeyId
yes
AK id
accessKeySecretEnv
one of these
Name of an env var holding the secret — preferred
accessKeySecret
one of these
Inline secret; avoid, it ends up in plaintext
securityTokenEnv / securityToken
no
For STS temporary credentials
defaultLogstore
no
Lets you omit --logstore
defaultLine
no
1–100, default 20
defaultQuery
no
Defaults to * (browse mode)
Profiles are always explicit
There is no implicit default profile.query, logstores and doctor require --profile <name> or $SLSB_PROFILE. If neither is given you get a CONFIG error.
This is deliberate. Pointing a log query at the wrong environment is the expensive mistake, and a silent default is exactly how it happens. defaultProfile in the config file is ignored by these commands for that reason — do not rely on it.
The environment is determined by project, not by the logstore name. A sit-* logstore only exists inside the non-production project. Pairing a sit-* logstore with a production project fails with LogStoreNotExist — this is the single most common misconfiguration.
If you run several environments, give each its own profiles and keep the project values apart:
Commands: query <keyword|-> Query SLS logs logstores List logstores in the configured project doctor Check config, connectivity and logstore access profile list List configured profiles (no secrets shown) config path Print the config file path in use config remove-profile <name>
code is one of CONFIG, USAGE, SLS, CONNECTION, UNKNOWN.
Output size limits
Limit
Value
Behaviour
Per string field
4000 chars
Truncated with a …(truncated, N chars) marker
Total payload
512 KB
Row collection stops; truncated: true
Nesting depth
6
Replaced with [array:N] / [object]
Truncation is reported on stderr as a warning: line, deliberately kept out of stdout so stdout | jq still parses. Use --no-truncate to opt out (careful: a single SLS row can hold megabytes).
doctor
doctor runs and reports the individual checks rather than just a verdict:
CHECK STATUS DETAIL ---------------- ------ -------------------------------------------- config ok /path/to/slsb.config.json endpoint ok https://cn-shanghai.log.aliyuncs.com project ok k8s-log-... default logstore ok app-web connection ok connected, N logstores visible output ok format=table, maxColWidth=60
All checks passed.
When any check fails, doctor exits 1, prints Some checks failed., reports "ok": false and "healthy": false, and marks the audit entry "ok": false.
Audit log
Every command can append one JSONL line when audit.path (or --audit-log) is set:
A .env file in the current directory is loaded automatically — useful for keeping SLSB_SECRET out of your shell history.
Exit codes
Code
Meaning
0
Success
1
Error (including a doctor run that found problems)
2
Usage or config error
3
SLS API error
4
Connection error
130
Interrupted
Safety
slsb is read-only: it only calls GetLogs and ListLogStores. It cannot write, delete, or modify anything in SLS or on your machine beyond the optional audit log.
Development
npm run build # tsc -> dist/ npm test# jest npm run typecheck # tsc --noEmit