Skip to content

Log drains

A log drain exports your project logs to your own systems. Set it up in the dashboard under Integrations > Log drains (project admins) or with the Management API. A project can have up to 5 drains.

Type What is sent
http POST JSON { project_id, drain_id, records: [...] }, signed with HMAC-SHA256 using the Standard Webhooks headers webhook-id, webhook-timestamp, webhook-signature. Optional authorization header value.
loki Loki push API (/loki/api/v1/push), one stream per source with labels job, project_id and source.
s3 gzip NDJSON objects <prefix>YYYY/MM/DD/HHMMSS-<id>.ndjson.gz, about one per minute. Works with S3, MinIO and R2 (SigV4, path-style by default).

Datadog and OTLP are not built in yet: put a collector in front (a Loki or HTTP receiver).

  • api: one record per request (method, route, redacted path, status, duration, IP).
  • auth: audit events.
  • functions: the Edge Functions host sends the console lines of your code plus one invocation record per call (status, result, duration and CPU time; never request bodies or secrets).
  • flows (Cloud): run lifecycle records run.started, run.step, run.completed, run.failed and run.cancelled with run_id, flow, version, trigger, attempt, step, error_code and duration_ms. Never the input, output, step results or error messages.
GET /v1/projects/:ref/log-drains
POST /v1/projects/:ref/log-drains
GET /v1/projects/:ref/log-drains/:id
PATCH /v1/projects/:ref/log-drains/:id
DELETE /v1/projects/:ref/log-drains/:id
POST /v1/projects/:ref/log-drains/:id/test # sends one sample record now
{ "type": "http", "name": "siem", "sources": ["api", "auth"], "url": "https://logs.example.com/ingest", "authorization": "Bearer ..." }
{ "type": "loki", "name": "loki", "sources": ["api"], "url": "https://loki.example.com/loki/api/v1/push" }
{ "type": "s3", "name": "archive", "sources": ["api", "auth"],
"s3": { "endpoint": "https://s3.eu-west-1.amazonaws.com", "region": "eu-west-1", "bucket": "my-logs", "prefix": "base/",
"access_key_id": "...", "secret_access_key": "..." } }

Credentials are write-only: they are encrypted and never returned. The http signing secret (whsec_...) is returned once on create and again when you pass rotate_secret to PATCH.

  • Drains never block requests. Records go to a bounded in-memory queue (20,000 records or 32 MB per drain), limited to 2,000 records per second and 32 KB per record. Overload drops records and counts them by reason in the drain stats.
  • Failed batches retry with exponential backoff and jitter (1 s to 60 s), 6 attempts. 4xx answers (except 408 and 429) and blocked destinations are not retried.
  • Delivery is best effort: records still in the queue when a process stops are lost.
  • Egress follows the instance SSRF policy: private addresses are refused unless the administrator allows them.
  • Sensitive data is redacted before sending: authorization, cookie, password, secret, token and API key fields, secret query parameters, Bearer, Basic and JWT strings. Emails are masked.

Compute base64(HMAC-SHA256(key, "<webhook-id>.<webhook-timestamp>.<raw body>")), where the key is the base64-decoded part of whsec_..., and compare it with the value after v1, in webhook-signature. Reject timestamps older than 5 minutes.