Skip to content

Kubernetes

k8s

Fetches pod logs using the kubectl CLI. Requires kubectl to be installed and configured on the machine running Cruncher.

binaryLocation string

Path to the kubectl binary. Defaults to "kubectl" (resolved from PATH).

context string

The kubectl context to use (e.g. my-cluster). If omitted, the current context in ~/.kube/config is used.

namespace string

The Kubernetes namespace to query. Defaults to "default".

podFilter string

A substring filter applied to pod names when listing pods. Only pods whose name contains this string will be shown and queried.

podOverride object

Per-pod overrides. Keyed by pod name.

  • messageFieldName - The field to use as the display message for that pod’s logs. Useful when a pod emits JSON logs with a non-standard message key.

Example:

podOverride:
my-pod-7d9f8b6c4-xk2pq:
messageFieldName: message
logPatterns array

A list of regex patterns used to extract structured fields from log lines.


Each entry has the form:

- name: <pattern_name>
pattern: <regex>
applyTo: [pod-name]
exclude: [pod-name]
applyToAll: false
messageFieldName: <field_name>

  • name - A human-readable name for this pattern.
  • pattern - A regex with named capture groups (e.g. (?P<level>[^ ]+)). Captured groups become log fields.
  • applyTo - List of pod names to apply this pattern to.
  • exclude - List of pod names to exclude from this pattern.
  • applyToAll - If true, applies to all pods regardless of applyTo.
  • messageFieldName - Which captured field to use as the display message.

Each log entry emits the following fields:

FieldDescription
_timeTimestamp of the log line
_rawOriginal log line (with ANSI codes)
ansi_free_lineLog line with ANSI codes stripped
podPod name
podNamespaceKubernetes namespace
containerContainer name within the pod
phasePod phase (Running, Succeeded, etc.)
(captured groups)Any named capture groups from logPatterns

The following dropdowns are available in the Cruncher UI to filter results:

ParamDescription
podFilter by pod name
namespaceFilter by namespace
containerFilter by container name
phaseFilter by pod phase
  • kubectl logs does not support --until-time, so the toTime bound is enforced in-process by filtering log timestamps after fetching.
  • Multi-container pods: each container is queried independently and results are merged in timestamp order.
cruncher.config.yaml
profiles:
default:
connectors: [k8s]
connectors:
- name: k8s
type: k8s
params: {}
cruncher.config.yaml
profiles:
default:
connectors: [k8s]
connectors:
- name: k8s
type: k8s
params:
context: my-cluster # kubectl context name
namespace: production
podFilter: backend # only show pods whose name contains "backend"
podOverride:
backend-7d9f8b6c4-xk2pq: # a pod with JSON logs using "message" as the text field
messageFieldName: message
logPatterns:
- name: json-logs
pattern: '^\{.*\}$'
applyToAll: true # parse JSON fields from all pods
messageFieldName: msg
- name: nginx-access
pattern: '^(?P<client_ip>[^ ]+) - - \[(?P<time>[^\]]+)\] "(?P<method>[A-Z]+) (?P<path>[^ ]+) [^"]+" (?P<status>\d+) (?P<bytes>\d+)'
applyTo:
- frontend-864b9c5d5d-plbhd # apply only to this pod
messageFieldName: path