Logs

Search a Managed Kubernetes cluster's logs with LogsQL, or follow them live.

What a cluster's logs include

Every cluster's logs include its nodes' system logs. Your pods' container logs and the cluster's Kubernetes events are included only when they're enabled for that cluster. Contact support to enable them.

Permission: logs read

Needs an Application Principal with logs read access. Check that the cluster's logsReady is true in /v1/clusters.

What's in a cluster's logs

Every record has two stream labels: cluster_id, and mks_source, which says where the record came from. Select a source with a stream filter such as _stream:{mks_source="workload-logging"}.

mks_source Contents Included Key fields
system-logging Your nodes' system logs, from journald Always HOSTNAME, SYSTEMD_UNIT, SYSLOG_IDENTIFIER, PRIORITY, PID, COMM
workload-logging Your pods' container output When enabled kubernetes.namespace_name, kubernetes.pod_name, kubernetes.container_name, kubernetes.host, stream
kubernetes-events The cluster's Kubernetes events When enabled type, reason, involvedObject.kind, involvedObject.name, involvedObject.namespace

Every record also has these fields:

Field Contents
_time When the line was written, RFC 3339
_msg The log line, or the event's message
_stream The record's stream labels, for example {cluster_id="...",mks_source="workload-logging"}
_stream_id An ID for the stream. With _time, it tells records apart.

Pod logs

Field Contents
kubernetes.namespace_name, kubernetes.pod_name, kubernetes.container_name The namespace, pod, and container that wrote the line
kubernetes.pod_id The pod's UID
kubernetes.host The node the pod runs on
kubernetes.container_image, kubernetes.container_hash, kubernetes.docker_id The container's image, image digest, and container ID
kubernetes.labels.<label>, kubernetes.annotations.<annotation> The pod's labels and annotations, one field each
stream stdout or stderr. Many programs write all their output to stderr, so stream:=stderr isn't only errors.

Lines a container writes as JSON are parsed. Today the record includes the line's keys as fields, such as level or msg, and _msg holds the line's message key, so a line without one has no log text in _msg. How JSON lines are stored may change: for queries that have to keep working, filter on the kubernetes.* fields and stream.

Kubernetes events

Events are about Kubernetes objects, so they have no kubernetes.* fields. Filter them by the object they're about: involvedObject.namespace, involvedObject.kind, involvedObject.name. Events about cluster-wide objects, such as nodes, have no involvedObject.namespace.

Field Contents
type Normal or Warning. Some components report their own types.
reason A short reason such as Scheduled, Pulled, or BackOff
involvedObject.kind, involvedObject.name, involvedObject.namespace, involvedObject.uid The object the event is about
count, firstTimestamp, lastTimestamp How many times the event occurred, and when
action, eventTime Set by components that use the newer events API
source.component, source.host, reportingComponent, reportingInstance What reported the event
metadata.name, metadata.namespace, metadata.uid, metadata.creationTimestamp The event object's own metadata

Node logs

System log records carry the journal's fields: HOSTNAME (the node), SYSTEMD_UNIT (for example kubelet.service), SYSLOG_IDENTIFIER, PRIORITY (0 emergency to 7 debug, when the sender sets one), PID, COMM, and TRANSPORT (how the line reached the journal, such as stdout, kernel, or audit).

On a cluster without pod logs enabled, system-logging also includes the output of the scheduler add-on's pods, if it's installed. Those records have stream but no journal or kubernetes.* fields.

Example queries

To find Query
One namespace's pod logs _stream:{mks_source="workload-logging"} kubernetes.namespace_name:="ml-training"
What one pod wrote to stderr _stream:{mks_source="workload-logging"} kubernetes.pod_name:="trainer-0" stream:=stderr
Pod log volume by namespace _stream:{mks_source="workload-logging"} | stats by (kubernetes.namespace_name) count()
One node service's logs _stream:{mks_source="system-logging"} SYSTEMD_UNIT:="kubelet.service"
One namespace's events _stream:{mks_source="kubernetes-events"} involvedObject.namespace:="ml-training"
Warning events by reason _stream:{mks_source="kubernetes-events"} type:=Warning | stats by (reason) count()

Queries with a stats pipe return one record per group, with the count in a count(*) field. To see every field a source has, query it with a small limit and look at a record.

Query logs

Returns the records that match a query between start and end, up to limit records.

Python SDK

import datetime
import vpcloud_client
from vpcloud_client.models.logs_query_request import LogsQueryRequest
from vpcloud_client.results import decode_json_lines

configuration = vpcloud_client.Configuration()
end = datetime.datetime.now(datetime.timezone.utc)
with vpcloud_client.ApiClient(configuration) as api_client:
    logs = vpcloud_client.LogsApi(api_client)
    response = logs.query_logs(CLUSTER_ID, LogsQueryRequest(
        query='_stream:{mks_source="workload-logging"} kubernetes.namespace_name:="ml-training" stream:=stderr',
        start=end - datetime.timedelta(hours=1),
        end=end,
        limit=100,
    ))
    for line in decode_json_lines(response.lines_json):
        print(line["_time"], line["kubernetes.pod_name"], line["_msg"])

REST API

curl -X POST "$OBS_URL/v1/clusters/$CLUSTER_ID/logs/query" -H "Authorization: Bearer $OBS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"query": "_stream:{mks_source=\"workload-logging\"} kubernetes.namespace_name:=\"ml-training\" stream:=stderr",
       "start": "2026-11-10T09:00:00Z", "end": "2026-11-10T10:00:00Z", "limit": 100}'
{
  "linesJson": [
    "eyJfdGltZSI6IjIwMjYtMTEtMTBUMDk6MTI6MDMuNDE4WiIsIl9zdHJlYW0iOiJ7Y2x1c3Rlcl9pZD1cIjBiN2Y5ZTJjLTVkNDEtNGE4ZS05YzNmLTZlMmExZDhiNGY3MFwiLG1rc19zb3VyY2U9XCJ3b3JrbG9hZC1sb2dnaW5nXCJ9IiwiX21zZyI6ImNoZWNrcG9pbnQgd3JpdGUgZmFpbGVkOiBubyBzcGFjZSBsZWZ0IG9uIGRldmljZSIsImt1YmVybmV0ZXMubmFtZXNwYWNlX25hbWUiOiJtbC10cmFpbmluZyIsImt1YmVybmV0ZXMucG9kX25hbWUiOiJ0cmFpbmVyLTAiLCJrdWJlcm5ldGVzLmNvbnRhaW5lcl9uYW1lIjoidHJhaW5lciIsImt1YmVybmV0ZXMuaG9zdCI6Im5vZGUtMSIsInN0cmVhbSI6InN0ZGVyciJ9"
  ]
}

Each item in linesJson is the base64 of one JSON log record. Decode them with base64 -d, or with the SDK's decode_json_lines.

Tail logs live

The Python SDK's tail yields matching lines as they're written: for following a training job, or feeding your own alerting.

from vpcloud_client.streaming import tail

query = '_stream:{mks_source="workload-logging"} kubernetes.namespace_name:="ml-training"'
with tail(configuration, query, cluster_id=CLUSTER_ID, reconnect=True) as stream:
    for event in stream:
        print(event.line["_time"], event.line["kubernetes.pod_name"], event.line["_msg"])
Option What it does
query A LogsQL filter. "*" matches every line.
cluster_id Required. The cluster to follow.
since Starts from this time (a timezone-aware datetime) instead of now.
reconnect Reconnects a dropped stream and resumes after the last line it delivered.
cursor Resumes a stream you stopped, from the last event's cursor.
  • atail is the asyncio version.
  • A client that falls too far behind is disconnected with resource_exhausted rather than silently missing lines. Process lines quickly, or hand them to a queue.
  • Leaving the with block, or breaking out of the loop, closes the stream.

Was this page helpful?

What went wrong?

↑↓ Navigate↵ Open⌘↵ New tabesc Close