Skip to Content
CLI & APICommand reference

stackblaze log-drains

List the app's log drains

Usage: stackblaze log-drains|logdrains [options] [command]

List the app's log drains

Options:
  --api-url <url>             StackBlaze API base URL (env STACKBLAZE_API_URL)
  --token <token>             API token, sb_pat_... (env STACKBLAZE_TOKEN)
  -p, --project <name>        Project name
  -e, --env <name>            Environment name (default: production)
  -a, --app <name>            App name
  --json                      Output JSON (same as -o json) (default: false)
  -o, --output <format>       Output format: text or json (choices: "text",
                              "json")
  -h, --help                  Print help

Commands:
  list|ls [options]           List the app's log drains: sources, sink,
                              endpoint, filter
  add [options] <name>        Add a log drain to the app (one rollout)
  remove|rm [options] <name>  Remove a log drain from the app (one rollout)

log-drains list

Usage: stackblaze log-drains list|ls [options]

List the app's log drains: sources, sink, endpoint, filter

Options:
  --api-url <url>        StackBlaze API base URL (env STACKBLAZE_API_URL)
  --token <token>        API token, sb_pat_... (env STACKBLAZE_TOKEN)
  -p, --project <name>   Project name
  -e, --env <name>       Environment name (default: production)
  -a, --app <name>       App name
  --json                 Output JSON (same as -o json) (default: false)
  -o, --output <format>  Output format: text or json (choices: "text", "json")
  -h, --help             Print help

Example

List the app's log drains:

stackblaze log-drains list -p github-demo-cw8z -e dev -a shop-web-xivg
OK github-demo-cw8z/dev/shop-web-xivg log drains
┌────────┬─────────┬──────┬────────────────────────────┬───────────────┐
│ Name   │ Sources │ Sink │ Endpoint                   │ Filter        │
├────────┼─────────┼──────┼────────────────────────────┼───────────────┤
│ errors │ web     │ http │ https://example.com/ingest │ level ≥ error │
└────────┴─────────┴──────┴────────────────────────────┴───────────────┘

With --json, as saved on the app:

stackblaze log-drains list -p github-demo-cw8z -e dev -a shop-web-xivg --json
{
  "pipeline": "github-demo-cw8z",
  "phase": "dev",
  "app": "shop-web-xivg",
  "logDrains": [
    {
      "filter": {
        "minLevel": "error"
      },
      "name": "errors",
      "select": {
        "sources": [
          "web"
        ]
      },
      "sink": {
        "endpoint": "https://example.com/ingest",
        "type": "http"
      }
    }
  ]
}

log-drains add

Usage: stackblaze log-drains add [options] <name>

Add a log drain to the app (one rollout)

Options:
  --api-url <url>        StackBlaze API base URL (env STACKBLAZE_API_URL)
  --token <token>        API token, sb_pat_... (env STACKBLAZE_TOKEN)
  -p, --project <name>   Project name
  -e, --env <name>       Environment name (default: production)
  -a, --app <name>       App name
  --json                 Output JSON (same as -o json) (default: false)
  --type <sink>          Where the logs go (choices: "quickwit", "syslog",
                         "http", "datadog")
  --endpoint <url>       http(s):// URL, or host:port for syslog (optional for
                         datadog)
  --secret <name>        Name of a Secret in the app's namespace holding the
                         sink credentials (never on the command line)
  --source <name>        Log source, repeatable (default: all of web, worker,
                         build, addons) (choices: "web", "worker", "build",
                         "addons")
  --addon <instance>     With --source addons: only these add-on instances
                         (repeatable)
  --stream <name>        Only this stream (default: both) (choices: "stdout",
                         "stderr", "all")
  --min-level <level>    Drop lines below this level (choices: "debug", "info",
                         "warn", "error")
  --include <regex>      Ship only lines matching this pattern
  --exclude <regex>      Drop lines matching this pattern
  --sample-rate <n>      Keep 1 line in N
  -o, --output <format>  Output format: text or json (choices: "text", "json")
  -h, --help             Print help

A drain is saved on the app (spec.logDrains) like the dashboard's Settings →
Log drains does for one app; the server checks the name, sources, sink and
that the endpoint is a public address (platform Quickwit hosts allowed). The
app rolls out with it.

Examples:
  $ stackblaze log-drains add archive --type http --endpoint https://logs.example.com/ingest --secret logs-token
  $ stackblaze log-drains add ops --type syslog --endpoint syslog.example.com:514 --source web --source worker --min-level warn
  $ stackblaze log-drains add dd --type datadog --secret datadog-api-key
May be disabled by your platform admin.

Example

Ship only the web process's error lines to your own HTTP collector. The endpoint has to be a public address:

stackblaze log-drains add errors --type http --endpoint https://example.com/ingest \
  --source web --min-level error -p github-demo-cw8z -e dev -a shop-web-xivg
OK Added log drain errors to github-demo-cw8z/dev/shop-web-xivg
web → http https://example.com/ingest  (level ≥ error)
The app rolls out with the new drain; logs start shipping once the new pods are up.

A host that doesn't resolve is refused:

stackblaze log-drains add errors --type http --endpoint https://logs.example.com/ingest \
  --source web --min-level error -p github-demo-cw8z -e dev -a shop-web-xivg
x  logDrains[0].sink.endpoint must be a public destination (host logs.example.com does not resolve)

log-drains remove

Usage: stackblaze log-drains remove|rm [options] <name>

Remove a log drain from the app (one rollout)

Options:
  --api-url <url>        StackBlaze API base URL (env STACKBLAZE_API_URL)
  --token <token>        API token, sb_pat_... (env STACKBLAZE_TOKEN)
  -p, --project <name>   Project name
  -e, --env <name>       Environment name (default: production)
  -a, --app <name>       App name
  --json                 Output JSON (same as -o json) (default: false)
  -y, --yes              Skip the confirmation prompt (default: false)
  -o, --output <format>  Output format: text or json (choices: "text", "json")
  -h, --help             Print help

May be disabled by your platform admin.

Example

Remove a log drain. Type yes to confirm (or pass -y). The app rolls out without it:

stackblaze log-drains remove errors -p github-demo-cw8z -e dev -a shop-web-xivg
!  Removing log drain errors from github-demo-cw8z/dev/shop-web-xivg: its logs stop shipping there.
Type "yes" to continue: yes
OK Removed log drain errors from github-demo-cw8z/dev/shop-web-xivg

On this page