Skip to main content

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 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.

Related Links:

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

kubernetes_log_analysis-0.1.0-py3-none-any.whl (11.8 kB view details)

Uploaded Python 3

File details

Details for the file kubernetes_log_analysis-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for kubernetes_log_analysis-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 dcf658ba293a6486946769fe6b1ed92b44d56c25aa500fb570342c48fbe5ebcd
MD5 59974a909bed9430a7e42155883747f7
BLAKE2b-256 8081e8a26a7c33876193c9493dcd3baa034a20e9836e3f68e277eebbc590d197

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page