k8s_logs
Fetch logs from a Kubernetes pod to debug container issues. Specify pod name, optional namespace, container, and tail lines for targeted log retrieval.
Instructions
Fetch logs from a pod.
Read-only: runs kubectl logs only — never mutates the cluster, idempotent.
Requires read access to pod logs; raises on kubectl failure (e.g. pod
NotFound, container not yet started, Forbidden). Output is truncated to
~50 KB.
Args: pod: Pod name (required). namespace: Target namespace. container: Container name in multi-container pods. tail: Lines from the tail (default 100, hard max 1000). since: Look-back window like "5m", "1h"; only logs newer than this. previous: If True, fetch the previous container instance's logs (post-crash). context: kubeconfig context.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| pod | Yes | Pod name (required, exact match, ^[a-zA-Z0-9._-]{1,253}$). | |
| tail | No | Number of lines from the end of the log. Default 100; clamped to 1..1000 (values above 1000 are capped). | |
| since | No | Only logs newer than this relative window. Format ^\d+[smhd]$ (e.g. "5m", "1h", "2d"). Omit for no time bound. | |
| context | No | kubeconfig context name; omit to use the current context. | |
| previous | No | If true, fetch the PREVIOUS (crashed/restarted) container instance's logs — use to debug a CrashLoopBackOff. Default false. | |
| container | No | Container name — required only for multi-container pods; omit for single-container pods. | |
| namespace | No | Target namespace; omit to use the default namespace. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |