Skip to content

kx logs

Streams logs for an indexed resource. Deployments, StatefulSets, DaemonSets, Jobs and Services aggregate logs across the pods they own.

kubectl’s own flags pass through. --since is the exception: it is read here first, so it takes the day spelling kx uses everywhere else (7d) as well as the ones kubectl understands.

A flag kx doesn’t know is refused; put it after -- to pass it through to kubectl.

Usage

kx logs [OPTIONS] <index>... [kubectl flags]

Arguments

ArgumentDescription
<index>...Row number from the current listing, or @name for a mark; kx state or kx mark shows them

Options

OptionDescription
--since stringOnly logs newer than this; s, m, h or d: 90s, 30m, 12h, 7d

Passthrough options

OptionDescription
--all-containersGet all containers’ logs in the pod(s).
--all-podsGet logs from all pod(s). Sets prefix to true.
-c, --container stringPrint the logs of this container
-f, --followSpecify if the logs should be streamed.
--ignore-errorsIf watching / following pod logs, allow for any errors that occur to be non-fatal
--insecure-skip-tls-verify-backendSkip verifying the identity of the kubelet that logs are requested from. In theory, an attacker could provide invalid log content back. You might want to use this if your kubelet serving certificates have expired.
--limit-bytes int64Maximum bytes of logs to return. Defaults to no limit.
--max-log-requests intSpecify maximum number of concurrent logs to follow when using by a selector. Defaults to 5.
--pod-running-timeout durationThe length of time (like 5s, 2m, or 3h, higher than zero) to wait until at least one pod is running
--prefixPrefix each log line with the log source (pod name and container name)
-p, --previousIf true, print the logs for the previous instance of the container in a pod if it exists.
-l, --selector stringSelector (label query) to filter on, supports ‘=’, ‘==’, ‘!=’, ‘in’, ’notin’.(e.g. -l key1=value1,key2=value2,key3 in (value3)). Matching objects must satisfy all of the specified label constraints.
--since-time stringOnly return logs after a specific date (RFC3339). Defaults to all logs. Only one of since-time / since may be used.
--tail int64Lines of recent log file to display. Defaults to -1 with no selector, showing all log lines otherwise 10, if a selector is provided.
--timestampsInclude timestamps on each line in the log output
…kubectl’s global flags too: --context, --kubeconfig, --as and the rest; kubectl options lists them

Global options

OptionDescription
--no-colorDisable styled output
-h, --helpShow this message and exit

Examples

kx logs 1
kx logs 1 2
kx logs 1 -f --tail=100
kx logs 1 --since 7d
kx logs 1 --previous
kx logs 1..3
kx logs 3..
kx logs @api -f