Kubelog is a CLI tool to fetch and enhance Kubernetes pod logs. It simplifies the retrieval and parsing of Kubernetes pod logs, providing enhanced formatting and filtering options for efficient troubleshooting.
-
🎯 Smart Log Parsing
- Automatic detection of JSON and plain text log formats
- Intelligent timestamp parsing across multiple formats
- Log level detection (DEBUG, INFO, WARN, ERROR, FATAL)
- Structured field parsing for JSON logs
-
🎨 Beautiful Output Formatting
- Color-coded log levels and timestamps
- Consistent timestamp formatting
- Highlighted error and warning messages
- Clean key-value formatting for JSON fields
- Logger type identification (e.g., logrus, zap)
-
🚀 Kubernetes Integration
- Easy container selection with interactive prompts
- Support for multi-container pods
- Previous container logs with
-p
flag - Real-time log following with
-f
flag - Container status indicators
-
⚡ Performance
- Efficient log streaming
- Smart container name completion
- Optimized log parsing
brew tap dantech2000/tap
brew install kubelog
- Go 1.16 or later
- Access to a Kubernetes cluster
- kubectl configured with the appropriate context
- just command runner (optional, but recommended)
-
Clone the repository:
git clone https://github.com/dantech2000/kubelog.git
-
Navigate to the project directory:
cd kubelog
-
Build the binary:
# Using just (recommended, includes version information) just build-version # Or using Go directly go build -o bin/kubelog main.go
-
(Optional) Move the binary to a directory in your PATH:
sudo mv bin/kubelog /usr/local/bin/
To fetch logs from a pod:
kubelog logs [pod-name] -n [namespace]
Options:
-n, --namespace
: Specify the Kubernetes namespace (default is "default")-c, --container
: Specify the container name (if pod has multiple containers)-f, --follow
: Follow the log output (similar totail -f
)-l, --level
: Filter logs by level (DEBUG, INFO, WARN, ERROR)
Example:
kubelog logs my-pod -n my-namespace -c my-container -f -l INFO
To list containers in a pod:
kubelog containers [pod-name] -n [namespace]
Options:
-n, --namespace
: Specify the Kubernetes namespace (default is "default")
Example:
kubelog containers my-pod -n my-namespace
To display version information:
kubelog version
Options:
-s, --short
: Display only the version number-o, --output
: Output format (json or yaml)
Examples:
# Display full version information
kubelog version
# Display only version number
kubelog version --short
# Get version info in JSON format
kubelog version --output json
# Get version info in YAML format
kubelog version --output yaml
just --list
Common commands:
just build-version
: Build with version informationjust test
: Run testsjust lint
: Run linterjust fmt
: Format codejust clean
: Clean build artifactsjust deps
: Install dependenciesjust cross-compile
: Build for multiple platforms
-
Update the version in
lib/version.go
-
Commit your changes:
git add . git commit -m "Bump version to X.Y.Z"
-
Create and push a new tag:
git tag -a vX.Y.Z -m "Release vX.Y.Z" git push origin vX.Y.Z
This will trigger the GitHub Actions workflow which will:
- Build the project
- Create a GitHub release
- Upload the binaries
- Update the Homebrew tap
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add some amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.