Skip to main content
The K8s Watcher allows ChatCLI to monitor multiple deployments simultaneously, collecting infrastructure and application metrics, logs, events, and pod status. The context is automatically injected into LLM prompts with intelligent budget management to avoid exceeding the context window.

Architecture

Each ResourceWatcher has its own collectors (including an optional PrometheusCollector) and all share a single Kubernetes clientset, minimizing connections.

Usage Modes

Multi-Target Configuration File

Target Fields

Complete Flags

chatcli watch

chatcli server (watcher flags)

What Is Collected

Collectors per Target

Node Health Collector

The NodeCollector automatically monitors the health of nodes where the target’s pods are running:
  1. Discovers nodes β€” via pod label selector, identifies which nodes the pods are scheduled on
  2. Collects conditions β€” all 5 official Kubernetes conditions (Ready, DiskPressure, MemoryPressure, PIDPressure, NetworkUnavailable)
  3. Collects metrics β€” node CPU and memory via metrics-server (when available)
  4. Pod capacity β€” counts active pods vs node maximum capacity
  5. Cordoned β€” detects nodes marked as unschedulable
Alerts emitted: Node context is included in the summary sent to the LLM, enabling the AI to correlate pod problems with infrastructure:

Prometheus Collector (New)

The PrometheusCollector scrapes Prometheus metrics directly from pods:
  • Discovers deployment pods and selects 1 Ready pod
  • Makes HTTP GET to http://podIP:port/path (timeout: 5s)
  • Parses the Prometheus text exposition format (stdlib, no dependencies)
  • Filters by configured glob patterns
  • Ignores NaN, Inf, and comment lines
Glob filter examples:

Context Budget Management (MultiSummarizer)

With multiple targets, the MultiSummarizer ensures the context does not exceed the LLM window:

Algorithm

1

Scores each target

0 = healthy, 1 = warning, 2 = critical
  • Critical: CrashLoopBackOff, OOMKilled, critical alerts
  • Warning: replicas < desired, error logs, warning alerts
  • Healthy: everything ok
2

Sorts by priority

Critical first, then warning, then healthy.
3

Allocates context

  • Score >= 1 β€” full context (~1-3 KB per target)
  • Score == 0 β€” compact one-liner (~80 chars per target)
4

Compresses if exceeding maxContextChars

Compresses healthy targets first.
5

Omits if still exceeding

Omits healthy targets when necessary.

Example with 20 Targets (2 with issues)

Total budget: ~2 KB (detail) + 18 x 80 chars (compact) = ~3.5 KB, within the 8 KB limit.

Anomaly Detection

Alerts are included in the context sent to the LLM and influence the budget priority of the MultiSummarizer.

Observability Store

Collected data is stored in a ring buffer per target with a configurable time window:
  • Snapshots: Complete periodic state (pods, deployment, HPA, events, metrics, app metrics)
  • Logs: Recent logs from each pod with classification (info/warning/error)
  • Alerts: Detected anomalies with severity and timestamps

Automatic Rotation

Data older than the time window (--window) is automatically discarded, keeping memory usage constant regardless of the number of targets.

/watch Command

Inside interactive ChatCLI (local or remote), use /watch to see the status:

One-Shot with K8s Context

Example Questions

Requirements

  • Kubernetes Cluster: Access via kubeconfig or in-cluster config
  • RBAC Permissions: Read access to pods, events, logs, deployments, HPA, ingresses
  • metrics-server (optional): For CPU/memory collection
  • Prometheus endpoints (optional): Apps that expose /metrics in Prometheus text format

RBAC

AIOps Integration

K8s Watcher alerts automatically feed into the Operator’s AIOps pipeline. When the Operator detects alerts via GetAlerts RPC, it creates Anomaly CRs that are correlated into Issues, analyzed by AI, and automatically remediated.
See AIOps Platform for the complete flow.
Starting with AIOps Platform v2, Watcher alerts also feed into:
  • NotificationPolicy for automatic routing to Slack, PagerDuty, OpsGenie, Email, Webhook and Teams
  • ApprovalPolicy for approval gates before production remediations
  • ServiceLevelObjective for burn rate and error budget calculation
  • NoiseReducer for suppression of repetitive, seasonal and flapping alerts
See the full AIOps Platform documentation for details.

Next Steps

Server Mode

Configure the server with watcher

K8s Operator

K8s Operator (AIOps)

AIOps Platform

AIOps Platform (deep-dive)

Deploy on Kubernetes

Deploy on Kubernetes