/ktop-graph

A terminal tool to visualise kubectl top as a graph

Primary LanguageGo

Kube top monitor

A real-time terminal dashboard for monitoring Kubernetes pod resource usage with beautiful ASCII graphs. It graphs kubectl top data for the time it is active.

I was not able to find any tool which shows graph of kubectl top command in terminal for the time it is active. I wanted a very simple tool, nothing like prometheus and grafana. It also seemed like a good opportunity to build a terminal tool, hence this.

Running Directly

make run ARGS='-n {namespace}'
make run ARGS='-n {namespace} -l app={selector} -interval 1s'

Compile and Run

make tidy
make release
./bin/ktop-graph -n {namespace}

Command Line Options

Usage: ktopg [options]

Options:
  -n, --namespace string    Kubernetes namespace (default "default")
  -l, --selector string     Label selector (e.g., "app=web,env=prod")
      --interval duration   Polling interval (default 2s)
      --history int         Max data points to keep (default 1800)
      --top int            Show top N pods by CPU usage (default 6)
      --alt                Use alternate screen buffer
  -h, --help               Show this help message

Requirements:

  • Kubernetes cluster with kubectl configured
  • kubectl binary in PATH
  • Terminal with color support
  • Go 1.24.5

Date Flow:

┌─────────────┐    ┌──────────────┐    ┌─────────────┐
│   kubectl   │───▶│  collector   │───▶│    data     │
│     top     │    │   (polling)  │    │   (store)   │
└─────────────┘    └──────────────┘    └─────────────┘
                                              │
┌─────────────┐    ┌──────────────┐          │
│  terminal   │◀───│     tui      │◀─────────┘
│  (output)   │    │ (rendering)  │
└─────────────┘    └──────────────┘

If terminal crashes or leaves terminal unusable, try:

reset #or
stty sane; tput rs1; clear