Monitoring and metrics
Health check
A 200 means the process is up and serving. It doesn't check Redis or your app: Cabby keeps
answering 200 while it retries a lost Redis connection, so watch the metrics and the log for
those. --health-path moves the endpoint. The Docker image runs this check itself
(cabby-healthcheck), reading the host, port and path from CABBY_HOST, CABBY_PORT and
CABBY_HEALTH_PATH.
Prometheus
--metrics_http turns the endpoint on, at the path you give it:
INF Serve metrics at http://localhost:9090/metrics context=metrics
Without --metrics_port, the metrics share the main port, the one clients reach. A port of their
own keeps them private, and stops with Cabby; --metrics_host sets the address it listens on.
The names start with anycable_go_, so dashboards built for AnyCable keep working.
--metrics_namespace=cabby renames them to cabby_*. --metrics_tags adds labels to every
metric:
# HELP cabby_clients_num The number of active clients
# TYPE cabby_clients_num gauge
cabby_clients_num{env="dev"} 0
That's --metrics_namespace=cabby --metrics_tags=env:dev. A tag key that can't be a label name
is written with _ for its other characters (app-name as app_name); StatsD keeps it as given.
curl the endpoint for the full list, each metric with its description.
StatsD
Cabby sends every metric every --metrics_rotate_interval seconds (15), prefixed with
anycable_go., or cabby. with --metrics_namespace=cabby. --statsd_prefix sets another
prefix, and --statsd_tags_format writes tags as datadog (the default), influxdb or
graphite. With the namespace and a tag:
cabby.clients_num:0|g|#env:dev
--metrics_log writes the same numbers to the log at each interval, and --metrics_log_filter
picks which ones.
Recovery metrics
Five counters show how clients catch up after a reconnect (History, recovery and presence). Each request counts on the node that serves it; Pusher clients move none of them.
| Metric | Counts |
|---|---|
history_requests_total |
Requests for missed messages: over WebSocket, SSE (Last-Event-ID, history_since) and Durable Streams |
rejected_history_requests_total |
Those answered with reject_history, or 410 Gone on Durable Streams |
history_msg_total |
Messages sent from history |
restored_sessions_total |
Sessions restored ("restored":true) |
failed_session_restores_total |
Restores asked for that didn't happen: the client starts a new session |
What to alert on
The names below leave out the prefix (anycable_go_, or cabby_ with the namespace).
| Metric | Type | Watch for |
|---|---|---|
clients_num |
gauge | A sudden drop: Cabby, the proxy or the network in front of it |
failed_auths_total |
counter | A rise: connect rejects clients, tokens expired, or the app is unreachable |
rpc_error_total, rpc_timeout_total |
counter | Any steady rate: calls to your app fail |
rpc_pending_num |
gauge | Close to rpc_capacity_num: your app answers slower than clients arrive |
failed_broadcast_msg_total |
counter | Any: broadcasts Cabby couldn't read |
disconnected_slow_clients_total |
counter | A rise: clients that don't read what Cabby writes, cut off past --ws_max_pending_size, over WebSocket, SSE, Durable Streams or Pusher |
timeout_server_msg_total |
counter | A rise: writes to clients that timed out |
disconnect_queue_discarded_total |
counter | Any: disconnect calls dropped because the queue was full |
rejected_history_requests_total |
counter | A rise: clients can't get missed messages back and must load the state from your app. Messages left the history too soon (--history_limit, --history_ttl), the broker lost its state (a new epoch), the broker fails (its errors below), or nodes don't share a broker |
failed_session_restores_total |
counter | A rise: clients are authenticated again, as new sessions. Sessions expired (--sessions_ttl), were restored already or are still connected, the broker lost them or fails, or nodes don't share a broker |
The brokers have their own:
| Metric | Broker |
|---|---|
sqlite_write_errors_total, sqlite_dropped_total |
SQLite |
redis_broker_errors_total, redis_broker_timeouts_total |
Redis |
postgres_errors_total, postgres_dropped_total, postgres_unpublished_total |
PostgreSQL |
For capacity, watch clients_num, broadcast_streams_num and server_msg_total. On Linux,
goroutines_num is the number of the process's threads and mem_sys_bytes its resident memory;
on other systems both are 0.
Logs
The log is text by default; --log_format=json writes one JSON object per line. --debug adds
the details of every connection and command, and is what Troubleshooting
asks for. Sensitive values, such as signed stream names, are masked in the log;
CABBY_FILTER_LOGS=false shows them.