Skip to content

Logs

Read what your rental or service writes and what Legion did with it, live or over the last 14 days, in the app or through the API.

On this page

Every rental keeps a log: what its container writes, and what Legion did with it. A service shows the logs of all its replicas together.

What is logged

  • Container output: what your container writes to standard output (stdout) and standard error (stderr), as the host's agent reads it from the container engine.

  • Model server: for a Legion model, the model server's own log, such as vLLM's (model_server).

  • Download and start: for a Legion model, Legion's log of downloading the model and starting the server (legion_serve).

  • Legion events: Legion's own events about the rental, as the host's agent reports them; your container does not write these (legion): the image was pulled, the container started, the health check passed or the model is ready, the rental stopped, or it failed and why.

Each line has its time, its source, a level (debug, info, warn or error) and the text. A line with no level is info.

Secrets are redacted, within limits. Before a line leaves the host, Legion replaces the exact values of the rental's environment variables (your variables and secrets, and the variables Legion sets) of 8 characters or more with [redacted], also in their JSON- and URL-escaped forms. A value your workload encodes another way (base64, for example) or prints in parts is not caught, so do not print secrets. Lines Legion adds never name the host or its addresses.

Lines are kept 14 days. You can read any range within those 14 days, and nothing older. Backups of Legion's log store are kept up to 180 days for recovery and cannot be read through Legion.

Limits

  • Each rental may send 50 lines and 8 KiB a second, with bursts of up to a minute's worth. Lines over the limit are not kept, and a Legion event says how many were left out.

  • A line longer than 4096 bytes is cut, and is marked as cut.

  • Your organization may read logs 300 times a minute, and at most 4 reads at once. Past either, a read answers 429 with Retry-After, and the app waits that long before it reads again.

In the app

Open a rental and choose the Logs tab, or open a service and choose its Logs tab.

  • Live: new lines appear every few seconds while you are at the bottom of the list. Scroll up and the list pauses, so lines stay where you are reading them; Jump to latest goes back to the end and carries on.

  • Show: All, Container output (standard output and standard error), Errors (lines of level error only), Model server, Download and start or Legion events (Legion's events about the rental, as the host's agent reports them).

  • Time range: the last 15 minutes, hour, 6 hours, 24 hours, 7 days or 14 days.

  • Search: type text and press Enter to see only the lines that contain it. It is plain text, not a pattern, and every match is highlighted.

  • Replica (services only): all replicas, or one, including replicas that have been replaced. Each line says which replica wrote it.

  • Wrap lines wraps long lines; turn it off to keep each line on one row and scroll sideways inside the list.

  • Copy on a line copies it. Download saves the lines shown as a .log file, one line each: time, source, level and text.

  • Load older reads the lines before the oldest one shown. The page keeps the newest 5,000 lines; past that, download what you see or pick a shorter range.

If the tab says This host's agent cannot send logs yet, the host runs an agent from before logs. Lines appear once the host updates its agent.

Reading logs needs the logs.read permission. Organization owners and members have it.

Through the API

getRentalLogs reads a rental's lines, oldest first:

Shell
curl -s -G "https://api.legion.ambient.xyz/v1/rentals/$RENTAL_ID/logs" \
  --data-urlencode "start=2026-11-19T11:00:00Z" \
  --data-urlencode "source=stdout" \
  --data-urlencode "source=stderr" \
  --data-urlencode "q=out of memory" \
  -H "Authorization: Bearer $LEGION_API_KEY"

getServiceLogs reads a service's replicas merged by time, or one replica with replica (its rental_id, from listServiceReplicas):

Shell
curl -s -G "https://api.legion.ambient.xyz/v1/services/$SERVICE_ID/logs" \
  --data-urlencode "level=warn" \
  -H "Authorization: Bearer $LEGION_API_KEY"
  • start and end bound the range (RFC 3339). Without them it is the last hour; a range spans at most 14 days.

  • source picks the streams (repeat it for several): stdout, stderr, model_server, legion_serve, legion. All by default.

  • level is the lowest level returned, info by default. q is searched as one plain-text phrase, up to 200 characters.

  • A page holds the newest limit lines of the range (200 by default, at most 1000). Pass its next_cursor as cursor to read the lines before them.

  • Follow live: pass a page's tail_cursor as after every few seconds. Each answer holds only the lines written since, oldest first, and a new tail_cursor for the next call. Lines can arrive a few seconds late; a tail never repeats a line, and each line's id stays the same however often it is read.

  • available is false when the host's agent cannot send logs yet; the page is then empty.

Errors: 400 invalid_logs_query or invalid_cursor, 404 for a rental or service that is not your organization's, 429 rate_limited, 502 logs_upstream_error (try again shortly) and 503 logs_unavailable.

For agents

Agents read logs with the MCP tools get_rental_logs and get_service_logs. Both only read. See the tools reference.