Get v1sandboxes logs
ListSandboxLogs returns one page of a sandbox’s stored stdout and stderr lines, ordered by (timestamp, event_id). Stored logs stay readable while the sandbox runs and after it ends, until retention_expires_at; unlike StreamLogs, a terminal sandbox is served. The creating user, or a caller with the sandbox_admin action in the sandbox’s organization, can read them. A caller who cannot see the sandbox gets the same error as GetSandbox, whether or not logs exist.
Collection is best effort: lines can be missing, for example when a sandbox ends within about a minute of writing them or when output arrives faster than it can be collected. Lines longer than the collection line limit are not stored whole. A line that is a JSON object is stored as normalized JSON: duplicate keys keep their first value, and whitespace, number formatting, and escapes are normalized. Bodies are stored as written, without redaction, so do not write secrets to stdout or stderr. Stored logs are not subject to legal hold.
Each line is stored for a fixed time after it was written, and reads end 30 days after the sandbox ends. A sandbox that ran up to 16 days keeps its full history for those 30 days; a longer sandbox keeps its full history while it runs, and afterwards its oldest lines expire first.
Pagination is keyset and weakly consistent: a line that arrives late, behind the page cursor, appears only in a new first-page request. A sandbox whose images are still being built returns an empty page.
Errors:
- INVALID_ARGUMENT (CWSANDBOX_INVALID_REQUEST): a field is out of range, the container names a platform sidecar, or page_token is malformed, expired, or does not match the request.
- FAILED_PRECONDITION (CWSANDBOX_LOGS_NOT_ENABLED): the sandbox has no stored logs to serve. Stored logs were not enabled for it when it was created, or are not enabled for the organization.
- FAILED_PRECONDITION (CWSANDBOX_LOGS_DELETED): the sandbox’s stored logs were deleted.
- FAILED_PRECONDITION (CWSANDBOX_LOG_RETENTION_EXPIRED): the stored logs are past their retention deadline.
- FAILED_PRECONDITION (CWSANDBOX_LOG_QUERY_TOO_EXPENSIVE): the query exceeds a cost limit and fails the same way on retry. Narrow the time range, or remove text_contains.
- RESOURCE_EXHAUSTED (CWSANDBOX_LOG_QUERY_LIMIT_EXCEEDED) with RetryInfo: too many stored-log calls are in flight, or the query met transient pressure. Retry after the delay.
- UNAVAILABLE (CWSANDBOX_LOG_BACKEND_UNAVAILABLE) with RetryInfo: the stored-log backend is unavailable. Retry after the delay.
- UNAVAILABLE (CWSANDBOX_FEATURE_FLAG_UNAVAILABLE): whether stored logs are enabled could not be determined. Retry later.
- UNAVAILABLE (CWSANDBOX_BACKEND_UNAVAILABLE) with RetryInfo: the sandbox’s stored-log state could not be read. Retry after the delay.
- UNIMPLEMENTED (CWSANDBOX_NOT_IMPLEMENTED): the deployment does not serve stored logs.
承認
クエリパラメータ
Inclusive start of the time range. Defaults to one hour before the earlier of endTime and the effective read window's end. A request covers at most 24 hours and is narrowed to the read window. That window starts five minutes before log collection began and ends five minutes after the sandbox's terminal time (or the request time for a running sandbox). A range outside that window returns no lines.