Smart Router

June 22, 2026 · View on GitHub

Every metric the Smart Router exposes over Prometheus, with its type, labels, and meaning. All metrics are defined under protocol/metrics/.

Exposition

Metrics are served in Prometheus text format from an HTTP server started by the metrics manager.

PathFormatDescription
/metricsPrometheusAll registered metrics (promhttp.Handler())
/metrics/overall-healthtext200 Health status OK if ≥1 endpoint is healthy, else 503 Unhealthy
/metrics/health-overalltextAlias of the above (backward-compat path)

Configuration

Flag / envDefaultEffect
--metrics-listen-addressdisabledAddress to expose Prometheus metrics on, e.g. :7779 or localhost:7779. The literal disabled turns the metrics server off entirely.
--optimizer-qos-sampling-interval1sHow often the optimizer-QoS sampler refreshes the rpc_optimizer_selection_score gauge and — when --usage-otel-enabled is set — emits optimizer_qos events to the OTel usage pipeline.
# enable, then scrape
smartrouter ... --metrics-listen-address ":7779"
curl http://localhost:7779/metrics

The flag is defined at rpcsmartrouter.go:1974; the flag name and the disabled sentinel live in flags.go.

Optimizer scores are always on. The optimizer-QoS client is created unconditionally, so rpc_optimizer_selection_score is populated on /metrics regardless of telemetry config. Remote shipping of these reports now flows through the OTel usage pipeline (--usage-otel-enabled), not a dedicated push address. (There is no separate GET /provider_optimizer_metrics endpoint; that handler was removed along with the dead consumer metrics manager.)

Conventions

  • Latency histograms all share the same buckets, in milliseconds (buckets.go:7): 1, 2, 5, 10, 25, 50, 100, 250, 500, 1000, 2500, 5000, 10000, 30000.
  • Attempt histograms (retry_attempts, hedge_attempts) use integer buckets 1…10.
  • Common labels:
    • spec — chain spec id (e.g. ETH1, LAV1).
    • apiInterfacejsonrpc, tendermintrpc, rest, grpc.
    • endpoint_id — the configured upstream RPC endpoint.
    • provider_address — provider the relay was routed to.
    • method — RPC method name.
    • function — relay function class; the function label lets one metric serve both the per-function breakdown and (via sum by (...)) the aggregate.
  • Boolean gauges encode 1 = true / healthy / present, 0 = false / unhealthy / absent.
  • Protocol version gauges encode major*1e6 + minor*1e3 + patch.
  • Metrics are registered with registerOrReuse, which returns the already-registered collector instead of panicking on a duplicate — so re-registration (e.g. across test runs sharing the default registry) is safe.

Smart Router metrics

These are the metrics specific to running as a Smart Router, defined in smartrouter_metrics_manager.go. They split into endpoint-scoped (rpc_endpoint_*) and router-scoped (smartrouter_*) families.

Endpoint-scoped — rpc_endpoint_*

MetricTypeLabelsDescription
rpc_endpoint_total_relays_servicedCounterspec, apiInterface, endpoint_id, functionRelays successfully served by this endpoint.
rpc_endpoint_total_erroredCounterspec, apiInterface, endpoint_id, functionErrored relays for this endpoint.
rpc_endpoint_requests_in_flightGaugespec, apiInterface, endpoint_id, functionRelays currently in flight to this endpoint.
rpc_endpoint_end_to_end_latency_millisecondsHistogramspec, apiInterface, endpoint_id, functionEnd-to-end latency per function for this endpoint.
rpc_endpoint_overall_healthGaugespec, apiInterface, endpoint_idEndpoint health (1 healthy / 0 unhealthy).
rpc_endpoint_overall_health_breakdownGaugespec, apiInterfaceAggregate health per chain/interface.
rpc_endpoint_selection_scoreGaugespec, apiInterface, endpoint_id, score_typeSelection scores by score_type (availability / latency / sync / stake / composite).
rpc_endpoint_latest_blockGaugespec, apiInterface, endpoint_idLatest block reported by the endpoint.
rpc_endpoint_fetch_latest_failsCounterspec, apiInterface, endpoint_idFailed latest-block fetches.
rpc_endpoint_fetch_block_failsCounterspec, apiInterface, endpoint_idFailed specific-block fetches.
rpc_endpoint_fetch_latest_successCounterspec, apiInterface, endpoint_idSuccessful latest-block fetches.
rpc_endpoint_fetch_block_successCounterspec, apiInterface, endpoint_idSuccessful specific-block fetches.

Optimizer

MetricTypeLabelsDescription
rpc_optimizer_selection_scoreGaugespec, endpoint_id, score_typePeriodic optimizer selection score per provider, by score_type.

Router-scoped — smartrouter_*

Core relay & health

MetricTypeLabelsDescription
smartrouter_total_relays_servicedCounterspec, apiInterface, functionRelays served by the router.
smartrouter_total_erroredCounterspec, apiInterface, functionErrored relays.
smartrouter_end_to_end_latency_millisecondsHistogramspec, apiInterface, functionRouter-level end-to-end latency.
smartrouter_overall_healthGaugeOverall router health (1 / 0).
smartrouter_overall_health_breakdownGaugespec, apiInterfacePer-chain/interface health.
smartrouter_latest_blockGaugespec, apiInterfaceLatest block known to the router.
smartrouter_protocol_versionGaugeversionEncoded protocol version.

WebSocket

MetricTypeLabelsDescription
smartrouter_ws_connections_activeGaugespec, apiInterfaceActive WebSocket connections.
smartrouter_ws_subscriptions_totalCounterspec, apiInterfaceTotal WebSocket subscription requests.
smartrouter_ws_subscription_errors_totalCounterspec, apiInterfaceFailed WebSocket subscription requests.

Request breakdown

requests_total = success + failed. read/write partition by statefulness; debug_trace and archive are orthogonal addon flags; batch is mutually exclusive with read/write.

MetricTypeLabelsDescription
smartrouter_requests_totalCounterspec, apiInterface, provider_address, methodAll requests.
smartrouter_requests_success_totalCounterspec, apiInterface, provider_address, methodSuccessful requests.
smartrouter_requests_failed_totalCounterspec, apiInterface, provider_address, methodFailed requests.
smartrouter_requests_read_totalCounterspec, apiInterface, provider_address, methodRead (stateless) requests.
smartrouter_requests_write_totalCounterspec, apiInterface, provider_address, methodWrite (stateful) requests.
smartrouter_requests_debug_trace_totalCounterspec, apiInterface, provider_address, methodDebug/trace addon requests.
smartrouter_requests_archive_totalCounterspec, apiInterface, provider_address, methodArchive requests.
smartrouter_requests_batch_totalCounterspec, apiInterface, provider_address, methodBatch requests.

Errors

MetricTypeLabelsDescription
smartrouter_node_errors_totalCounterspec, apiInterface, provider_address, methodNode errors returned by endpoints.
smartrouter_protocol_errors_totalCounterspec, apiInterface, provider_address, methodProtocol/transport errors (connection/session failures).

Retries

MetricTypeLabelsDescription
smartrouter_retries_totalCounterspec, apiInterface, methodRetry attempts triggered (beyond the first try).
smartrouter_retries_success_totalCounterspec, apiInterface, methodRetried requests that succeeded.
smartrouter_retries_failed_totalCounterspec, apiInterface, methodRetried requests that failed.
smartrouter_retry_attemptsHistogramspec, apiInterface, methodAttempts per retried request (buckets 1…10).

Consistency

MetricTypeLabelsDescription
smartrouter_consistency_totalCounterspec, apiInterface, methodRequests enforcing consistency (seenBlock).
smartrouter_consistency_success_totalCounterspec, apiInterface, methodConsistency-enforced requests that succeeded.
smartrouter_consistency_failed_totalCounterspec, apiInterface, methodConsistency-enforced requests that failed.

Hedging

MetricTypeLabelsDescription
smartrouter_hedge_totalCounterspec, apiInterface, methodHedge (batch-ticker) relays sent.
smartrouter_hedge_success_totalCounterspec, apiInterface, methodHedged requests that succeeded.
smartrouter_hedge_failed_totalCounterspec, apiInterface, methodHedged requests that failed.
smartrouter_hedge_attemptsHistogramspec, apiInterface, methodHedge relays per request (buckets 1…10).

Cross-validation

MetricTypeLabelsDescription
smartrouter_cross_validation_requests_totalCounterspec, apiInterface, methodCross-validated requests. Includes request-time structural fail-fasts (insufficient-capacity / insufficient-groups) that abort before fanning out to any provider, so this is not the same as the number of provider fan-outs.
smartrouter_cross_validation_success_totalCounterspec, apiInterface, methodRequests that reached consensus.
smartrouter_cross_validation_failed_totalCounterspec, apiInterface, methodRequests that did not return a consensus answer — quorum-time failures (no-agreement / diversity / per-group) and request-time structural fail-fasts that never tried (insufficient-capacity / insufficient-groups). requests_total == success_total + failed_total.
smartrouter_cross_validation_provider_agreements_totalCounterspec, apiInterface, method, provider_addressTimes a provider agreed with consensus.
smartrouter_cross_validation_provider_disagreements_totalCounterspec, apiInterface, method, provider_addressTimes a provider disagreed with consensus.
smartrouter_cross_validation_mismatch_totalCounterspec, apiInterface, method, group, finalityContent outliers by group: one increment per distinct outlier group per successful deterministic cross-validation request (a response whose SHA256(reply.data) diverged from the reached consensus) — not a per-provider counter. Only emitted when a quorum was reached; quorum failures and node/protocol errors are excluded (failures report a lava-cross-validation-failure-reason instead). finality is finalized / not_finalized / unknown; post-finality divergence is the high-signal alert. Bounded cardinality (keyed by operator-defined group, not provider address).
smartrouter_cross_validation_failures_totalCounterspec, apiInterface, method, reasonFailures by reason — the by-reason breakdown of cross_validation_failed_total (which stays unlabeled, so existing dashboards are unaffected). reason is the closed lava-cross-validation-failure-reason enum: quorum-time no-agreement / insufficient-responses / diversity-unmet / group-quorum-unmet, or request-time structural insufficient-capacity / insufficient-groups. Use it to separate a structural failure (client should fall back) from a quorum disagreement (a retry may help). Bounded cardinality (the reason set is a closed enum).

The _mismatch_total series is the group-level alerting surface for outliers. When enough providers still agree, a divergent provider is outvoted and recorded here; per-provider detail lives in the cross-validation outlier detected info log and the lava-cross-validation-disagreeing-providers header.

Cache

MetricTypeLabelsDescription
smartrouter_cache_requests_totalCounterspec, apiInterface, methodCache lookup attempts.
smartrouter_cache_success_totalCounterspec, apiInterface, methodCache hits.
smartrouter_cache_failed_totalCounterspec, apiInterface, methodCache misses.
smartrouter_cache_latency_millisecondsHistogramspec, apiInterface, methodCache lookup latency.

CSM state-store sizes (diagnostics)

Expose otherwise black-box Consumer-Session-Manager state so integration tests can assert /debug/reset-all emptied each store (see MAG-1762). All drop to 0 after a reset.

MetricTypeLabelsDescription
smartrouter_csm_blocked_providersGaugespec, apiInterfaceSize of the previous-epoch blocked-providers store.
smartrouter_csm_blocked_backup_providersGaugespec, apiInterfaceSize of the blocked-backup-providers store.
smartrouter_csm_sticky_sessionsGaugespec, apiInterfaceLive sticky-session affinities.
smartrouter_csm_reported_providersGaugespec, apiInterfaceSize of the reported-providers register.

Shared metrics

Classified errors — smartrouter_errors_*

Defined in error_metrics.go.

MetricTypeLabelsDescription
smartrouter_errors_totalCountererror_name, error_category, retryable, chain_idErrors classified by name, category, retryability, and chain.