Skip to main content
This recipe puts the K8s Watcher to work on an application myapp in the namespace production, in three setups:

Option 1: local monitoring

1

Check cluster access

The watcher uses ~/.kube/config with its current context (or --kubeconfig); it does not read KUBECONFIG.
2

Start the watcher

3

Ask

Every prompt carries the deployment status, pods, events, recent error logs, HPA, node health and active alerts. /watch status prints the one-line state.

Tune it

Several workloads, other kinds, Prometheus metrics

Targets with problems get full detail, healthy ones a single line, within maxContextChars. Prometheus scraping reads pod IPs over plain HTTP, so from a laptop it only works if your network routes to pod IPs; otherwise the other data still flows and the metrics section is simply absent.

One-shot for alert handlers

Each run collects once (up to 10 seconds) before asking, so the answer reflects the current state.

Option 2: team server with a watcher (Helm)

1

Install the server with a watcher

  • server.token is required: in a pod the server listens on every interface and refuses to start without a credential.
  • The server log reaches kubectl logs on its own: in a pod the server also writes it to stderr as JSON lines. The file copy in the pod rotates at 20 MB with 3 backups (logging.*), which fits the pod’s 200Mi data volume.
  • An empty watcher.namespace watches default. A namespace other than the release’s (production here, outside monitoring) makes the chart create a ClusterRole automatically. For several workloads, or a StatefulSet, DaemonSet, Job or CronJob (kind), use watcher.targets in a values file (see Helm watcher values).
2

Check it

3

Connect

The server adds the watcher context to every prompt, so each teammate just asks. CHATCLI_ALLOW_INSECURE=true is needed because this server is plaintext; for anything beyond a port-forward turn on TLS and connect with --tls --ca-cert.
Distribute access with one token per person by switching to JWTs (security.jwtSecretRef), so each caller has its own identity and rate-limit bucket; see Server authentication.

Incident workflow

The comparison works within watcher.window (default 2 hours). /watch status in this session queries the server’s watcher (K8s Watcher (remote): …). For scripts against the server:

Option 3: autonomous AIOps (operator)

The operator provisions the server from an Instance, reads the watcher’s alerts over StreamAlerts, and drives Anomaly → Issue → AIInsight → RemediationPlan. It dials the server over TLS with a credential, so the Instance needs both.
1

Install the operator

2

Create the Secrets

Follow Your first Instance for the three Secrets in the namespace chatcli: chatcli-api-keys (provider key), chatcli-server-token (key token) and chatcli-tls (tls.crt, tls.key, ca.crt, valid for chatcli.chatcli.svc.cluster.local).
3

Create the Instance with a watcher

Without server.token (or another credential) the operator does not create the Deployment (AuthenticationConfigured=False); without TLS it cannot reach the server (ServerReachable=False). namespace is required on every target. The pipeline uses the first ready Instance in the cluster.
4

Follow the pipeline

A crash-looping pod raises HighRestartCount (and OOMKilled when that is the cause); the operator records an Anomaly, correlates it into an Issue, asks the server for an analysis (AnalyzeIssue), and remediates from a matching Runbook, AI-suggested actions, or an agentic observe-decide-act loop (AgenticStep, up to spec.aiops.agenticMaxSteps, default 10). The full flow, approvals and safety limits are in AIOps Platform.
5

(Optional) Add a Runbook

A manual Runbook that matches the Issue is used before AI-generated actions.

Troubleshooting

Checklist

  • kubectl access and RBAC for pods, pods/log, events, workloads
  • Local (chatcli watch) or shared (chatcli server / Helm watcher.*)
  • Single target (--deployment) or targets.yaml (--config / --watch-config)
  • Optional metricsPort and metricsFilter for Prometheus scraping
  • Interval and window fit the scenario; maxContextChars for many targets
  • Server: credential set, TLS before exposing it
  • Test: “Is the deployment healthy?”