Skip to main content

Module health

Module health 

Source
Expand description

HTTP health and readiness endpoints for zebrad.

Overview

  • This module exposes two small HTTP/1.1 endpoints for basic liveness/readiness checks, suitable for Kubernetes probes and load balancers.
  • Endpoints are opt-in, disabled by default. Enable by setting a listen_addr in the health config section.
  • Plain-text responses and small responses keep the checks fast and safe.

Endpoints

  • GET /healthy β€” returns 200 OK if the process is up and the node has at least min_connected_peers recently live peers (default: 1). Otherwise 503 Service Unavailable.
  • GET /ready β€” returns 200 OK if the node is near the chain tip, the estimated block lag is within ready_max_blocks_behind, and the latest committed block is recent. On regtest/testnet, readiness returns 200 unless enforce_on_test_networks is set.

Security

  • Endpoints are unauthenticated by design. Bind to internal network interfaces, and restrict exposure using network policy, firewall rules, and service configuration.
  • The server does not access or return private data. It only summarises coarse node state.

Configuration and examples

ModulesΒ§

config πŸ”’

StructsΒ§

ChainTipMetrics
Metrics tracking how long it’s been since
Config
Health server configuration.
HealthCtx πŸ”’

ConstantsΒ§

MAX_RECENT_REQUESTS πŸ”’
The maximum number of requests that will be handled in a given time interval before requests are dropped.
METHOD_NOT_ALLOWED_MSG πŸ”’
NOT_FOUND_MSG πŸ”’
PEER_METRICS_REFRESH_INTERVAL πŸ”’
RECENT_REQUEST_INTERVAL πŸ”’

FunctionsΒ§

handle_request πŸ”’
healthy πŸ”’
init
Starts the health server if listen_addr is configured.
num_live_peers πŸ”’
peer_metrics_refresh_task πŸ”’
ready πŸ”’
run_health_server πŸ”’
simple_response πŸ”’