Skip to content
Kapten
Esc
↑↓navigate↵open⌘Jpreview

Query environment logs

Returns the environment’s log entries that match the query, read through Kapten’s agent on its cluster.

POST/project/{project_id}/environment/{environment_id}/logs
Authorization
AuthorizationBearer token (JWT) · headerrequired

JWT token passed in the Authorization header using the Bearer <token> format.

Path parameters
project_iduuidrequired

The unique identifier for the project

environment_iduuidrequired

The unique identifier of the environment

Request body
requiredapplication/json
querystringrequired

The user-provided LogsQL query fragment.

limitinteger<int32>

Maximum number of most recent log entries to return.

min 1 · max 1000 · default: 200
Responses
200

Environment logs retrieved successfully

recordslogs_query_entry[]required
Show properties
Array of logs_query_entry
msgobject | string | number | boolean | any[] | nullrequired

The normalized log payload as an arbitrary JSON value.

Show properties
One of:
object
object
string
string
number
number
boolean
boolean
any[]
Array of any
any
timestringrequired

The RFC3339 or RFC3339Nano timestamp returned by Victoria Logs.

levelstring

The log level, or an empty string when missing from the source record.

project_idstring

The Kapten project identifier associated with the log entry when present in the source record.

environment_idstring

The Kapten environment identifier associated with the log entry when present in the source record.

component_idstring

The Kapten component identifier associated with the log entry when present in the source record.

component_typestring

The Kapten component type associated with the log entry when present in the source record.

component_run_idstring
component_kindstring
sourcestring
Allowed:control_planeagentbuilder
stepstring
phasestring
backendstring
backend_stepstring
run_statusstring
duration_msinteger<int64>
error_kindstring
metadataobject
eventstring
Allowed:kapten.build.phase
event_versioninteger<int32>
platformstring
Allowed:linux/amd64linux/arm64
publicationstring
Allowed:child_manifestfinal_index
default

Error

codeinteger<int32>required
messagestringrequired
reasonstring

Optional stable machine-readable reason for programmatic error handling

Request
curl -X POST 'https://api.kapten.io/project/497f6eca-6276-4993-bfeb-53cbbbba6f08/environment/497f6eca-6276-4993-bfeb-53cbbbba6f08/logs' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -H 'Accept: application/json' \
  -H 'Content-Type: application/json' \
  -d '{
  "query": "string",
  "limit": 200
}'
Response
{
  "records": [
    {
      "msg": {},
      "time": "string",
      "level": "string",
      "project_id": "string",
      "environment_id": "string",
      "component_id": "string",
      "component_type": "string",
      "component_run_id": "string",
      "component_kind": "string",
      "source": "control_plane",
      "step": "string",
      "phase": "string",
      "backend": "string",
      "backend_step": "string",
      "run_status": "string",
      "duration_ms": 0,
      "error_kind": "string",
      "metadata": {},
      "event": "kapten.build.phase",
      "event_version": 0,
      "platform": "linux/amd64",
      "publication": "child_manifest"
    }
  ]
}

Was this page helpful?