Skip to content

Domain-state Prometheus exporter#272

Draft
x3c41a wants to merge 2 commits into
devfrom
feat/chain-exporter
Draft

Domain-state Prometheus exporter#272
x3c41a wants to merge 2 commits into
devfrom
feat/chain-exporter

Conversation

@x3c41a

@x3c41a x3c41a commented Jul 7, 2026

Copy link
Copy Markdown

Third slice of #267: the piece that makes a stress run observable.

The chain nodes already expose standard Substrate Prometheus metrics (block time, weight, txpool, state size). What nothing covers is the pallet's own domain state: provider balances and stake, agreement counts, pending challenges, checkpoint accruals. This adds a small PAPI sidecar that polls that state per finalized block and exports it as Prometheus metrics, so a run of challenge-saturation.ts (or any activity) shows up on a dashboard. It is the first consumer of the telemetry work in #214 and the domain-specific scrape target the monitoring/ stack (next slice) will chart.

What it exports

examples/papi/chain-exporter.ts serves /metrics and /health (default port 9700).

Gauges, refreshed each finalized block:

  • per provider (bounded by MaxPrimaryProviders/MaxMembers): stake, committed bytes, free/reserved balance, pending challenges, lifetime challenges received/failed, deregistering flag
  • aggregate: providers, buckets, agreements total/active/expired, pending challenges, checkpoint rewards and pool totals, finalized block

Counters, accumulated from lifecycle events (pre-initialized to 0 so rate() has no startup gap):

  • challenge created / defended / slashed, provider-checkpoint submitted, checkpoint miss-penalized, provider registered, plus an exporter scrape-error counter

Design notes: aggregate counts are exported as totals, not per-entry, so a saturation run doesn't blow up label cardinality. Gauges track the finalized view (so they lag best block by the finalization gap, by design); event counters catch up over every block since the last scrape so a finalization jump doesn't drop events. Values are float64, so balances above 2^53 lose low-order precision. Hand-rolled exposition format, no new dependencies.

Tested

Live on local zombienet + provider node. Ran just demo against it and watched the metrics track: providers_total 0→1 on registration, buckets_total/agreements_total 0→1 (lagging best by the finalization gap, as expected for a finalized-view exporter), per-provider stake/committed-bytes/balances populated, and challenge_created_total / challenge_defended_total increment on the real events. No scrape errors. tsc --noEmit passes.

Follow-up

The monitoring/ stack (Prometheus + Grafana + docker-compose, with provisioned dashboards for chain health / economics / protocol activity) will scrape this exporter alongside the omni-node's built-in metrics. Provider-node /metrics gets added there once #214 lands.

Independent of #269 / #271; based directly on dev.

A PAPI sidecar that polls pallet domain state per finalized block and exports
it as Prometheus metrics: provider stake/committed-bytes/balances/pending
challenges (per-provider gauges), agreement counts (total/active/expired),
pending challenges, checkpoint rewards/pool totals, plus counters accumulated
from lifecycle events (challenge created/defended/slashed, checkpoint
submitted/miss-penalized, provider registered). Serves /metrics and /health;
hand-rolled exposition format, no new deps.

The chain nodes already expose standard Substrate metrics; this covers the
on-chain domain state nothing else does, so a stress run is observable. Feeds
the monitoring stack (follow-up) and is a first consumer of #214.

Part of #267.
@x3c41a
x3c41a marked this pull request as draft July 7, 2026 10:11
Add block_weight_ref_time / block_weight_proof_size gauges (labelled by
dispatch class) from System.BlockWeight of the latest finalized block.
Substrate's own Prometheus does not expose this; it is the signal that spikes
at a challenge-deadline block (the on_finalize slash sweep). Feeds the
chain-health dashboard.
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