Operations¶
What to watch, where to look, and how to upgrade and recover a farm.
Health endpoints¶
The gateway serves:
| Endpoint | Answers | Used for |
|---|---|---|
GET /healthz |
200 ok while the process runs |
Liveness probe |
GET /readyz |
200 ready, or 503 redis unreachable |
Readiness probe |
GET /wd/hub/status |
{"value": {"ready": true, "message": "Hearth is ready"}} |
Grid-style status for Selenium tooling |
None of them needs a key. Browser pods answer GET /healthz on port 3000 for their readiness
probe.
Metrics¶
The gateway serves Prometheus metrics at GET /metrics (no key, on the same port as everything
else). Each gateway replica counts its own requests, so scrape every pod, not the Service.
| Metric | Type | Labels | Meaning |
|---|---|---|---|
hearth_sessions_total |
counter | pool, outcome |
Session requests by outcome |
hearth_queue_wait_seconds |
histogram | pool |
Time a session waited for a browser or device (buckets 0.05 s to 300 s) |
hearth_pool_ready |
gauge | pool, kind |
Idle browsers or devices ready for a session |
hearth_pool_busy |
gauge | pool, kind |
Browsers or devices serving a session |
hearth_pool_queued |
gauge | pool, kind |
Session requests waiting |
kind is browser or device. The pool gauges are read from Redis at scrape time, so every
replica reports the same values; aggregate them with max, not sum.
outcome is one of:
| Outcome | Meaning |
|---|---|
started |
The session started |
team_limit |
Refused: the team was at its maxSessions |
queue_timeout |
Refused: no browser or device became free within the queue timeout |
pod_error |
The browser pod refused or failed the session start |
device_error |
The device could not be prepared, or Appium refused the session |
Useful queries:
# Sessions started per minute, per pool
sum by (pool) (rate(hearth_sessions_total{outcome="started"}[5m])) * 60
# Share of requests refused because pools were full
sum(rate(hearth_sessions_total{outcome="queue_timeout"}[15m]))
/ sum(rate(hearth_sessions_total[15m]))
# 95th percentile wait for a browser
histogram_quantile(0.95, sum by (le, pool) (rate(hearth_queue_wait_seconds_bucket[10m])))
Pool sizes are also in the custom resources' status (kubectl get browserpools), in
GET /api/pools and in hearth status.
Prometheus Operator and Grafana¶
metrics:
serviceMonitor:
enabled: true # a ServiceMonitor for the gateway's /metrics
interval: 30s
dashboard:
enabled: true # a ConfigMap labelled grafana_dashboard: "1"
The ServiceMonitor needs the Prometheus Operator's CRDs in the cluster. The dashboard ConfigMap is
picked up by Grafana's dashboard sidecar; the JSON is also in charts/hearth/dashboards/hearth.json
if you import dashboards by hand.
Not built yet
Metrics from the operator and OpenTelemetry traces are planned.
Logs¶
Every binary logs to stdout. Set HEARTH_LOG_FORMAT=json for one JSON object per line, and
RUST_LOG for the level (default info, with the binary's own messages at debug). The chart
does not expose these yet; patch the Deployment's environment if you need them.
kubectl -n hearth logs deploy/hearth-gateway --tail=200
kubectl -n hearth logs deploy/hearth-operator --tail=200
kubectl -n hearth logs <browser pod>
What to look for:
| Where | Message | Means |
|---|---|---|
| gateway | session allocated (with team, pool, pod, waited_ms) |
A session got a browser |
| gateway | pod refused the session |
The browser pod failed to start the session |
| gateway | device allocated, device session finished |
Device sessions |
| gateway | the device's agent lost the session |
An agent restarted during a session |
| gateway | pod registered |
A browser pod offered itself through /internal/node/register |
| gateway | failed an abandoned queued session |
A request waited 20 minutes with no gateway serving it |
| operator | added pods, removed idle pods |
Scaling decisions |
| operator | replacing an out-of-date idle pod |
An upgrade is rolling through a pool |
| operator | removing a pod that never became ready |
A pod did not register in time (10 minutes; 90 s for an out-of-date one) |
| operator | invalid pool: ... |
A BrowserPool is misconfigured and skipped |
| browser pod | ready for a session, session started, session finished |
One pod's life |
| browser pod | artifact upload failed |
The video could not be stored through the gateway; check the gateway's storage settings |
| browser pod | heartbeat failed |
The pod cannot reach the gateway, or its token is unknown |
Browser pods are deleted after their session, so their logs go with them. Ship pod logs to your log store if you need them later.
Upgrades¶
-
Apply the new CRDs (Helm never upgrades them):
-
Upgrade the chart:
What happens:
- Gateway: a rolling update. With more than one replica, a PodDisruptionBudget keeps at least
one gateway up during node drains. A stopping gateway first waits 10 s so the Service stops sending
it new connections, then stops accepting and keeps proxying open sessions for up to
gateway.drainSeconds(one hour by default). Lower it if you prefer faster rollouts over letting long sessions finish. - Operator: replaced (one replica). Pools keep running meanwhile; nothing scales for a few seconds.
- Browser pods: idle pods from the old template are replaced at once; busy pods finish their session first. See Pools and scaling.
Keys, agent tokens, the Redis password and the bundled store's credentials are kept across upgrades.
What state matters¶
| State | Where | If you lose it |
|---|---|---|
| Pools, teams | BrowserPool, DevicePool, Team |
Back them up with your other manifests, or keep them in values |
| API keys, agent tokens | Secrets <release>-key-*, <release>-agent-* |
Clients and agents stop working until you issue new ones. Back them up like any secret |
| Recordings, apps | The S3 bucket | Gone. Use a bucket with the durability you need |
| Sessions, queue, pod and device registrations, pod token hashes, UI sign-ins | Redis | Running sessions fail, the session list empties and people must sign in to the UI again. Pools, teams, keys and agent tokens are published again by the operator within seconds, and agents report their devices again on their next heartbeat |
The bundled Valkey runs without persistence on purpose: everything in it is live state or a 7-day session list. There is nothing to back up in Redis.
After Redis restarts, existing browser pods have lost their registration, and the hashes of their pod tokens are gone with it, so they cannot register again. The operator removes a pod that is not registered once it is 10 minutes old and creates a fresh one, so the farm recovers by itself within about 10 minutes. To recover at once, delete the browser pods:
The bundled SeaweedFS keeps data on its PersistentVolumeClaim (<release>-s3). Back up that
volume, or better, use your own bucket for anything you need to keep.
Uninstall¶
- Key and agent-token Secrets stay (
helm.sh/resource-policy: keep), so a reinstall keeps the same keys. - Helm leaves the CRDs (and so any pools and teams you created outside the chart).
- Helm deletes the bundled store and its volume claim, and with it every recording and app in it. Copy what you need first.
To remove the rest by hand (deleting the CRDs also deletes every pool and team):