monitor

package
v0.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 7, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package monitor provides real-time Kubernetes cluster monitoring via a BubbleTea TUI.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ClusterStats

type ClusterStats struct {
	TotalPods      int
	RunningPods    int
	ProblemPods    int
	TotalNodes     int
	ReadyNodes     int
	NotReadyNodes  int
	EventsLast5Min int
	CriticalCount  int
	Connection     ConnectionStatus
	LastError      string // Last connection error message
}

ClusterStats holds cluster statistics

type Config

type Config struct {
	Namespace      string
	SeverityFilter Severity
	Quiet          bool
	AlertSound     bool
	DisableMesh    bool
}

Config holds monitor configuration

type ConnectionStatus added in v0.2.1

type ConnectionStatus int

ConnectionStatus represents the cluster connection state

const (
	ConnectionUnknown     ConnectionStatus = iota // Not yet attempted
	ConnectionOK                                  // Successfully connected
	ConnectionUnreachable                         // Cluster unreachable
)

ConnectionUnknown, ConnectionOK, and ConnectionUnreachable define cluster connection states.

type Model

type Model struct {
	// contains filtered or unexported fields
}

Model holds the bubbletea model

func NewModel

func NewModel(watcher *Watcher) Model

NewModel creates a new bubbletea model

func (*Model) ExportRequested

func (m *Model) ExportRequested() bool

ExportRequested returns whether export was requested

func (*Model) GetState

func (m *Model) GetState() ([]Problem, []RecentEvent, ClusterStats)

GetState returns the current monitoring state (for export)

func (*Model) Init

func (m *Model) Init() tea.Cmd

Init initializes the model

func (*Model) PrintRequested

func (m *Model) PrintRequested() bool

PrintRequested returns whether print mode was requested

func (*Model) Update

func (m *Model) Update(msg tea.Msg) (tea.Model, tea.Cmd)

Update handles messages

func (*Model) View

func (m *Model) View() string

View renders the UI

type Problem

type Problem struct {
	Severity      Severity
	Type          string // OOMKilled, CrashLoop, ImagePull, etc.
	Namespace     string
	PodName       string
	ContainerName string
	Message       string
	Reason        string
	FirstSeen     time.Time
	LastSeen      time.Time
	Count         int
	Details       map[string]string
}

Problem represents an active problem in the cluster

type RecentEvent

type RecentEvent struct {
	Timestamp time.Time
	Severity  Severity
	Type      string
	Namespace string
	Resource  string
	Message   string
}

RecentEvent represents a recent event in the cluster

type Severity

type Severity string

Severity levels for problems

const (
	SeverityFatal    Severity = "FATAL"
	SeverityCritical Severity = "CRITICAL"
	SeverityWarning  Severity = "WARNING"
)

SeverityFatal, SeverityCritical, and SeverityWarning define problem severity levels.

type Watcher

type Watcher struct {
	// contains filtered or unexported fields
}

Watcher watches Kubernetes events and pod status

func NewWatcher

func NewWatcher(clientset kubernetes.Interface, config Config) *Watcher

NewWatcher creates a new cluster watcher

func (*Watcher) GetState

func (w *Watcher) GetState() ([]Problem, []RecentEvent, ClusterStats)

GetState returns current monitoring state

func (*Watcher) GetUpdateChannel

func (w *Watcher) GetUpdateChannel() <-chan struct{}

GetUpdateChannel returns channel for UI updates

func (*Watcher) Start

func (w *Watcher) Start(ctx context.Context) error

Start begins watching cluster events and pods. Performs an initial connectivity probe before starting background watchers.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL