Logs and debugging
Read and search logs, check resource use, diagnose problems, and open a shell in your app.
stackblaze logs
Prints the linked app's logs, oldest first. By default it shows recent lines from the running app, falling back to the log store for the last --minutes when there are none.
stackblaze logs [options]-f streams new lines until you press Ctrl+C and reconnects after network drops. --search queries the durable log store with --query, --level and --minutes. --follow and --search cannot be combined. Build logs are separate: see stackblaze builds logs.
JSON: the default mode prints one document with a logs array; --search prints hits and num_hits; --follow prints one JSON object per line as it arrives.
| Flag | Description |
|---|---|
-n, --limit <n> | Show the newest n lines (with -f, print the last n first; with --search, default 100) |
-f, --follow | Stream live logs |
--search | Search the log store instead of the live buffer |
-q, --query <text> | Full-text query (--search) |
--level <level> | Log level filter (--search) |
--minutes <n> | Look-back window in minutes (default 60) |
--container <name> | web (default) or worker |
Also accepts the scope flags (-p, --project, -e, --env, -a, --app) and the output flags (-o, --output, --json), plus --token, --api-url and --org. Common flags
Examples
stackblaze logs -n 200
stackblaze logs -f
stackblaze logs -f -n 50 -a worker
stackblaze logs --search -q "timeout" --level error --minutes 180stackblaze metrics
Without --since, prints the current CPU (millicores) and memory (MiB) of each running instance of the linked app. With --since, shows the history over that window for all instances combined: CPU, memory, requests and latency, each as a sparkline with now, average and max.
stackblaze metrics [--since <window>] [-w, --watch] [--interval <seconds>]--json prints the raw series (timestamps in milliseconds). --watch refreshes the history until Ctrl-C; with --json it prints one document per refresh (NDJSON).
| Flag | Description |
|---|---|
--since <window> | History window: 30m, 1h, 24h or 7d (max 7d) |
-w, --watch | Refresh the history until Ctrl-C (default window 1h) |
--interval <seconds> | Seconds between --watch refreshes (default 30) |
Also accepts the scope flags (-p, --project, -e, --env, -a, --app) and the output flags (-o, --output, --json), plus --token, --api-url and --org. Common flags
Examples
stackblaze metrics -a api
stackblaze metrics --since 24h
stackblaze metrics --since 1h --watch
stackblaze metrics --since 7d --jsonstackblaze events
Prints the linked app's recent platform events (reason and message), newest 20 by default, with warnings marked. Useful when an app does not start. Events of the deploy placeholder are hidden and counted; --all shows them.
stackblaze events [--all] [-n <limit>]| Flag | Description |
|---|---|
--all | Include the deploy placeholder's events (hidden by default) |
-n, --limit <n> | Show the newest n events (default 20) |
Also accepts the scope flags (-p, --project, -e, --env, -a, --app) and the output flags (-o, --output, --json), plus --token, --api-url and --org. Common flags
Examples
stackblaze events -a api
stackblaze events --all -n 50stackblaze diagnose
Collects the app's configuration, metrics, recent logs and add-on state, and reports findings and hints.
stackblaze diagnose [--scale <window>] [--log-minutes <n>]| Flag | Description |
|---|---|
--scale <window> | Metrics window: 2h (default), 24h or 7d |
--log-minutes <n> | Log search window in minutes |
Also accepts the scope flags (-p, --project, -e, --env, -a, --app) and the output flags (-o, --output, --json), plus --token, --api-url and --org. Common flags
Examples
stackblaze diagnose --scale 24hstackblaze ssh
Opens an interactive terminal inside a running instance of the linked app, over the API: no SSH keys and no open ports. Console must be enabled for your organization (Platform → Console & SSH); if it is not, ssh says so. Exits with the remote session's exit code.
stackblaze ssh [--pod <name>] [--container <name>] [--command <cmd> [--timeout <seconds>]]With --command, the command runs once and ssh exits with its exit code, so it works in scripts. A session that sends nothing at all fails after 20 seconds, and a session that closes without an exit status exits 255.
| Flag | Description |
|---|---|
--pod <name> | Instance to connect to (default: the app's first web instance) |
--container <name> | web (default) or worker; without a web container, the first one |
--command <cmd> | Run this command instead of an interactive sh, and exit with its exit code |
--timeout <seconds> | With --command: give up after this many seconds (default: no limit) |
Also accepts the scope flags (-p, --project, -e, --env, -a, --app), plus --token, --api-url and --org. Common flags
Examples
stackblaze ssh
stackblaze ssh --command bash --container worker
stackblaze ssh --command "node scripts/migrate.js" --timeout 300