Skip to main content

Kubernetes Log Analysis Tool (k-log)

中文版說明文件

A command-line tool that utilizes Large Language Models (LLMs) to analyze collected Kubernetes log content.

Prerequisites

Python Package Installation

  1. Install the package and its dependencies using pip:
    pip install kubernetes-log-analysis==0.1.0
    

Configuration

  1. API Key: This tool requires the GOOGLE_API_KEY for Gemini. Create a file named .env in the directory where you will run k-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.

  2. LLM Model (Optional): You can specify a different LiteLLM compatible model string by setting the LLM_MODEL environment variable in your .env file or globally. The default is gemini/gemini-2.5-flash-preview-04-17.

    LLM_MODEL="gemini/gemini-2.5-flash-preview-04-17"
    

Usage

  1. Ensure your GOOGLE_API_KEY is set (e.g., via the .env file).

  2. Navigate to your Kubernetes log bundle directory (e.g., cd /path/to/k8s-debug-default-20250509034522).

  3. Run the k-log command 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.

Metadata

Release files for kubernetes-log-analysis 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for kubernetes-log-analysis 0.1.0
File Interpreter ABI Platform
kubernetes_log_analysis-0.1.0-py3-none-any.whl Python 3 none any Details

Release files / kubernetes_log_analysis-0.1.0-py3-none-any.whl

Download URL kubernetes_log_analysis-0.1.0-py3-none-any.whl
Size 11.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
dcf658ba293a6486946769fe6b1ed92b44d56c25aa500fb570342c48fbe5ebcd
BLAKE2b-256 checksum
How to use checksums
8081e8a26a7c33876193c9493dcd3baa034a20e9836e3f68e277eebbc590d197
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.9.6

Release history Release notifications | RSS feed

This release

0.1.0 This release

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page