Skip to content

tobifroe/klog

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

klog

License: MIT Coverage Status

klog is a tool that allows you to tail logs of multiple Kubernetes pods simultaneously.

Features

  • Multi-pod log streaming: Stream logs from multiple pods simultaneously with color-coded output
  • Dynamic pod discovery: Automatically discover and stream logs from newly spawned pods
  • Multiple resource types: Monitor Deployments, StatefulSets, DaemonSets, Jobs, and CronJobs
  • Configurable refresh: Set custom intervals for pod discovery (default: 30 seconds)
  • Log filtering: Filter logs to show only lines containing specific text
  • JSON log formatting: Automatically format and colorize JSON log entries

Installation

Cargo

You can build and install klog using cargo:

# Using Cargo
cargo install klog

Homebrew

brew tap tobifroe/homewbrew-klog
brew install klog

Nix

Klog is packaged in nixpkgs.

nix-shell -p klog-rs

Manual installation

Alternatively, grab a pre-built binary for your OS from the releases page. Curently, there are x86_64 binaries provided for Windows, MacOS and Linux.

Usage

klog will use your current sessions kubecontext.

klog [OPTIONS] --namespace <NAMESPACE> --pods <PODS>...

# Example
klog -n my-namespace -p pod1 pod2 pod3 -f

Options

-n, --namespace <NAMESPACE>           Namespace to use
-d, --deployments <DEPLOYMENTS>...    Deployment to log
-s, --statefulsets <STATEFULSETS>...  Statefulsets to log
    --daemonsets <DAEMONSETS>...      Daemonsets to log
    --jobs <JOBS>...                  Jobs to log
    --cronjobs <CRONJOBS>...          CronJobs to log
-p, --pods <PODS>...                  Pods to log
-f, --follow                          Follow log?
    --filter <FILTER>                 Filter [default: ]
    --refresh-interval <SECONDS>      Refresh interval for discovering new pods (0 to disable) [default: 30]
-h, --help                            Print help
-V, --version                         Print version

Examples

Basic Usage

To tail logs from pods pod1, pod2, pod3 and deployment my-service in the my-namespace namespace and follow the logs, run:

klog -n my-namespace -p pod1 pod2 pod3 -d my-service --follow

Dynamic Pod Discovery

klog automatically discovers and streams logs from newly spawned pods. By default, it checks for new pods every 30 seconds:

# Monitor a deployment and automatically pick up new pods
klog -n my-namespace -d my-service --follow

# Custom refresh interval (check every 10 seconds)
klog -n my-namespace -d my-service --refresh-interval 10 --follow

# Disable automatic discovery (original behavior)
klog -n my-namespace -d my-service --refresh-interval 0 --follow

Multiple Resource Types

You can monitor multiple types of Kubernetes resources simultaneously:

# Monitor deployments, statefulsets, and daemonsets
klog -n my-namespace -d app1 app2 -s db-cluster -daemonsets logging-agent --follow

Filtering Logs

Filter logs to show only lines containing specific text:

# Only show log lines containing "ERROR"
klog -n my-namespace -d my-service --filter "ERROR" --follow

Acknowledgements

  • Clap for argument parsing.
  • Kube for Kubernetes API interactions.
  • Tokio for asynchronous runtime.

About

klog is a tool that allows you to tail logs of multiple Kubernetes pods simultaneously.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •  

Languages