Architecture
- Single-Target (legacy)
- Multi-Target (current)
ResourceWatcher has its own collectors (including an optional PrometheusCollector) and all share a single Kubernetes clientset, minimizing connections.
Usage Modes
- Single Resource
- Multiple Resources (YAML)
- Server with Watcher
Multi-Target Configuration File
Target Fields
Complete Flags
chatcli watch
chatcli server (watcher flags)
What Is Collected
Collectors per Target
Node Health Collector
TheNodeCollector automatically monitors the health of nodes where the targetβs pods are running:
- Discovers nodes β via pod label selector, identifies which nodes the pods are scheduled on
- Collects conditions β all 5 official Kubernetes conditions (
Ready,DiskPressure,MemoryPressure,PIDPressure,NetworkUnavailable) - Collects metrics β node CPU and memory via metrics-server (when available)
- Pod capacity β counts active pods vs node maximum capacity
- Cordoned β detects nodes marked as
unschedulable
Node context is included in the summary sent to the LLM, enabling the AI to correlate pod problems with infrastructure:
Prometheus Collector (New)
ThePrometheusCollector 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
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)
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:
- Single-Target
- Multi-Target
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
/metricsin Prometheus text format
RBAC
- Single-namespace (Role + RoleBinding)
AIOps Integration
K8s Watcher alerts automatically feed into the Operatorβs AIOps pipeline. When the Operator detects alerts viaGetAlerts RPC, it creates Anomaly CRs that are correlated into Issues, analyzed by AI, and automatically remediated.
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
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