A tool to analyze Kubernetes log bundles using LLMs.
Project description
Kubernetes Log Analysis Tool (k-log)
A command-line tool that utilizes Large Language Models (LLMs) to analyze collected Kubernetes log content.
Prerequisites
- Python 3.8+
- A directory of Kubernetes log content (generated by
k8s-debug.sh, for details see https://github.com/ap-mic-inc/kubernetes-log-analysis). - Google Gemini API Key (or an API key for other models supported by LiteLLM).
Python Package Installation
- Install the package and its dependencies using pip:
pip install kubernetes-log-analysis==0.1.0
Configuration
-
API Key: This tool requires the
GOOGLE_API_KEYfor Gemini. Create a file named.envin the directory where you will runk-log(or the project root during development) with the following content:GOOGLE_API_KEY="YOUR_GEMINI_API_KEY_HERE"
Alternatively, ensure this environment variable is set globally.
-
LLM Model (Optional): You can specify a different LiteLLM compatible model string by setting the
LLM_MODELenvironment variable in your.envfile or globally. The default isgemini/gemini-2.5-flash-preview-04-17.LLM_MODEL="gemini/gemini-2.5-flash-preview-04-17"
Usage
-
Ensure your
GOOGLE_API_KEYis set (e.g., via the.envfile). -
Navigate to your Kubernetes log bundle directory (e.g.,
cd /path/to/k8s-debug-default-20250509034522). -
Run the
k-logcommand with your query:k-log "What is the current status of the nodes?"
Alternatively, explicitly specify the log directory:
k-log --log-dir /path/to/your/k8s-debug-default-20250509034522 "logs for pod kuberay-operator-6ddb59999c-mggc9"
Example Queries:
k-log "status of nodes"k-log "logs for pod jupyterlab-54698b59b8-bmvgq in namespace default"k-log "describe service kubernetes"k-log "any critical events?"
About the Author
Simon Liu
APMIC MLOps Engineer x Google Developer Expert (GDE) in AI
A technology enthusiast in the field of artificial intelligence solutions, focusing on assisting enterprises in adopting generative AI, MLOps, and large language model (LLM) technologies to drive digital transformation and practical technological implementation.
Currently also a Google Developer Expert (GDE) in the GenAI field, actively participating in technology communities. Through technical articles, speeches, and practical experience sharing, he promotes the application and development of AI technology. To date, he has published over a hundred technical articles on Medium, covering topics such as generative AI, RAG, and AI Agents, and has served multiple times as a speaker at technical seminars, sharing practical applications of AI and generative AI.
Related Links:
- APMIC Official Website: https://www.apmic.ai/
- Personal Social Media Links: https://simonliuyuwei.my.canva.site/link-in-bio
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file kubernetes_log_analysis-0.1.0-py3-none-any.whl.
File metadata
- Download URL: kubernetes_log_analysis-0.1.0-py3-none-any.whl
- Upload date:
- Size: 11.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dcf658ba293a6486946769fe6b1ed92b44d56c25aa500fb570342c48fbe5ebcd
|
|
| MD5 |
59974a909bed9430a7e42155883747f7
|
|
| BLAKE2b-256 |
8081e8a26a7c33876193c9493dcd3baa034a20e9836e3f68e277eebbc590d197
|