Skip to content

Channel health monitoring with alerts and auto-restart - #207

Open
gluk-w wants to merge 3 commits into
mainfrom
feat/channel-monitoring
Open

Channel health monitoring with alerts and auto-restart#207
gluk-w wants to merge 3 commits into
mainfrom
feat/channel-monitoring

Conversation

@gluk-w

@gluk-w gluk-w commented Aug 11, 2026

Copy link
Copy Markdown
Owner

Summary

Detects when an OpenClaw instance's chat channels (Slack, Telegram, Discord, ...) stop responding — including the common failure mode where the process is alive but a Slack Socket Mode / Telegram poller connection is silently wedged — and escalates instead of failing silently.

  • Background monitor polls each running instance's OpenClaw gateway (channels.status over the existing Gateway SSH tunnel) and classifies per-channel health (healthy / stale / disconnected / not running), persisted plus in-memory
  • GET /instances/{id}/channels/health endpoint and channel_health summary on instance responses
  • Channel Health panel on the Agent detail Settings tab; "Warning" indicator with tooltip on the agent list for unhealthy/unreachable agents
  • Escalation on sustained failure: webhook alert after 3 consecutive failing checks, opt-in auto-restart after 5 (circuit breaker: max 3/hour + 10m cooldown), recovery notification with outage duration
  • Alert webhook works with bare Slack incoming webhooks; optional bearer token encrypted at rest; Send Test button in Settings → Misc
  • channel_health_events audit table doubling as outage history
  • Config: CLAWORC_CHANNEL_HEALTH_* env vars for interval/thresholds; alerts and auto-restart toggles are UI-editable settings

Test plan

  • Unit tests: health evaluation and payload parsing, escalator state machine (thresholds, cooldown, circuit breaker, recovery), webhook sender (payload/bearer/retry/skip), monitor listener
  • go build / go vet / go test pass; vite build passes
  • Manual: lower thresholds via env, break a channel in a running instance, observe alert → auto-restart → recovery webhooks and the events endpoint

🤖 Generated with Claude Code

Stan Misiurev and others added 3 commits August 6, 2026 11:39
Control plane now polls each running instance's OpenClaw gateway
(channels.status WS RPC over the existing Gateway tunnel) to detect
channels that are disconnected, wedged (stale sockets), or not running,
catching the known failure mode where the process is alive but a Slack
Socket Mode / Telegram poller connection is silently dead.

- internal/channelhealth: background monitor (60s interval, bounded
  concurrency), health evaluation with 30m stale threshold, persisted
  per-channel status + in-memory snapshot
- GET /api/v1/instances/{id}/channels/health + channel_health summary
  on instance responses
- Channel Health panel on Agent detail Settings tab and warning
  indicator on the agent list for unhealthy/unreachable instances
- CLAWORC_CHANNEL_HEALTH_ENABLED / CLAWORC_CHANNEL_HEALTH_INTERVAL
- docs/channel-monitoring.md spec + end-user page

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CfW5Dn8yEsULgbKzmcjbZ7
… auto-restart

The channel health monitor now feeds every snapshot to an escalator that
tracks consecutive failing checks (overall unhealthy/unreachable) per
instance and acts on sustained outages instead of only displaying them:

- Webhook alert (channel_failure) after 3 consecutive failing checks,
  once per incident; recovery notification with outage duration when the
  incident closes. Payloads include a human-readable text field so Slack
  incoming webhooks work as-is; optional bearer token encrypted at rest.
- Opt-in auto-restart (default off) after 5 consecutive failing checks,
  reusing the existing async restart flow, capped at 3 restarts per
  rolling hour per instance with a 10m post-restart cooldown.
- channel_health_events audit table + GET /instances/{id}/channels/health/events.
- Settings: Channel Health Alerts card (Misc tab) with webhook URL,
  token, toggles, and a Send Test button (POST /settings/channel-alerts/test).
- Thresholds via CLAWORC_CHANNEL_HEALTH_{ALERT_THRESHOLD,RESTART_THRESHOLD,
  RESTART_MAX_PER_HOUR,RESTART_COOLDOWN}.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CfW5Dn8yEsULgbKzmcjbZ7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant