Skip to content

feat(monitoring): four-dashboard observability suite over metrics, logs and traces - #2046

Merged
thiras merged 2 commits into
mainfrom
feat/observability-dashboard-suite
Sep 18, 2026
Merged

thiras merged 2 commits into
mainfrom
feat/observability-dashboard-suite

Conversation

@thiras

@thiras thiras commented Sep 18, 2026

Copy link
Copy Markdown
Contributor

What

Replaces the single reference dashboard with a four-dashboard suite covering
metrics, logs and traces, fixes four query bugs found by actually running the
queries, and extends the name gate so the new files are covered from day one.

file uid scope
monitoring/grafana-dashboard.json decdn-poc-overview fleet overview — rebuilt, uid and filename unchanged so existing links resolve
monitoring/dashboard-delivery.json decdn-delivery serve leg, paying pull leg, cache, origin, warming
monitoring/dashboard-chain.json decdn-chain five chain-event watchers, registries, seller and buyer payments
monitoring/dashboard-node.json decdn-node single node: host, iroh transport, DHT and probe, logs, traces

Coverage goes from 25 named series to 207.

Why now

All three signals are already live and only one was on a dashboard. The fleet
exports ~200 decdn_* series, ships ~1 GB/day of logs to Loki and traces to
Tempo; the dashboard showed 25 metrics, no logs, no traces and no region view.

Four bugs this found

Three of these made a panel or a rule lie, and none were visible before something
actually evaluated them:

  1. DecdnWatcherTaskPanicked could never evaluate. rate() drops
    __name__, so the five per-watcher series on a node collapse to identical
    label sets and Prometheus refuses the vector outright. sum by (instance)
    does not help — the duplicate exists before the aggregation runs. Rewritten
    with label_replace on the raw selector plus an offset subtraction.
  2. DecdnCacheInflightMutexPoisoned could never resolve — a bare > 0 on a
    monotonic, process-local counter whose own annotation says not to restart.
  3. DecdnNodeRestarted fired for five minutes after every deploy, and a
    crash-looping node re-entered it continuously instead of escalating.
  4. The cache hit ratio clamped a per-second rate denominator to 1.0,
    understating every node doing under one lookup/sec — which is all three.

The query shape to know

rate() and increase() drop __name__. A family panel written as
sum by (__name__) (rate({__name__=~"decdn_x_.+_total"}[5m])) does not evaluate
at all. So rate panels name each series explicitly — verbose, correct, and it
puts every one of those ~50 names under the gate, where a regex form would scan
as the wildcard token decdn_x_ and be skipped entirely. Instant panels over a
family use label_replace on the raw selector, before any operator strips the
name.

Gate change

monitoring_selectors_are_exported now sweeps every .yml and .json under
monitoring/ rather than two hard-coded filenames, with a floor of 5 files so a
directory rename cannot silently green it.

The exported set it compares against had to grow to match. decdn_iroh_* (35
series) is registered from a live Endpoint and is absent from
Metrics::new().encode(), so every iroh panel would have failed as an
unexported name. Rather than add a prefix waiver — the failure message says
explicitly not to — register_iroh_endpoint is split so the test registers an
EndpointMetrics::default() without standing up a socket. Those names are now
genuinely checked.

Verification

Against the live stack, not by inspection:

  • 266/266 Prometheus targets return data, 0 empty, 0 errored.
  • 14/14 Loki and Tempo targets resolve. Two Loki panels are empty over 1h
    (PoolExhausted, bao faults) because no deliveries have happened; the filters
    themselves match over 24h where the events exist.
  • The extended gate was mutation-tested: a typo'd decdn_iroh_sockt_* in a
    new file fails it, confirming both the directory sweep and the iroh coverage
    are real.
  • cargo nextest run -p decdn-node metrics — 29/29.
  • cargo clippy --workspace --all-targets and cargo fmt -- --check clean.
  • yamllint on the alerts file: 0 errors. (It caught a duplicate component
    key my first pass introduced.)

promtool is not installed locally, so the alerts file was validated by YAML
parse and by the ruler accepting the rules, not by promtool check rules.

Deployed

Dashboards are live in a new deCDN folder on decdn.grafana.net, and the 18
rules are provisioned and reporting health=ok.

Note the rules are Grafana-managed, not Mimir: the Cloud ruler proxy rejects
writes through the stack service account (400 bad request data even for a
trivially valid group). The translation is not literal — each expr already
carries its own comparison, so the result set is empty when not firing but the
surviving values are not usable as a threshold (up == 0 fires at value 0). The
condition therefore counts datapoints rather than testing them, with
noDataState: OK carrying the not-firing case. That is written up in the
appendix.

Follow-ups not in this PR

  • No histograms exist anywhere, so Prometheus latency SLOs are impossible. The
    appendix already specifies decdn_probe_collection_latency_seconds as
    planned.
  • The workspace has zero #[instrument] attributes; every span in Tempo
    belongs to a dependency crate. The trace panels are built against the
    operations that will exist.
  • ~112 exported series remain undocumented in the appendix registry.
  • adr/appendix-observability.md:293-298 calls node_id mandatory on every log
    event; it is emitted on two startup lines only.

🤖 Generated with Claude Code

…gs and traces

The single reference dashboard was built when the exporter had a fraction of
today's surface. The fleet now exports ~200 decdn_* series, ships logs to Loki
and traces to Tempo, and runs three nodes in three regions, while the dashboard
covered 25 named series, no logs, no traces and no region view.

monitoring/ gains dashboard-delivery.json (decdn-delivery), dashboard-chain.json
(decdn-chain) and dashboard-node.json (decdn-node) beside a rebuilt
grafana-dashboard.json (decdn-poc-overview, retitled "fleet overview"; uid and
filename unchanged so the ADR, CHANGELOG and runbook links still resolve).
Coverage goes from 25 named series to 207: every serve-refusal reason, the whole
decdn_node_pull_* funnel, all five chain-event watchers, the decdn_iroh_*
transport sub-registry, and node_exporter host panels that join on the same
instance label.

Loki panels parse the daemon's tracing JSON. journald stamps every stdout line
priority info, so Loki's level stream label and detected_level both report info
whatever the event's real severity — `| json lvl="level"` is the only way to see
it. Tempo panels supply the only latency distribution available anywhere in the
stack: the exporter registers no histograms, so histogram_quantile has nothing
to read.

The name gate now sweeps every .yml and .json under monitoring/ instead of two
hard-coded filenames, so a new dashboard is gated the day it lands. Its exported
set had to grow to match: decdn_iroh_* is registered from a live Endpoint and is
absent from Metrics::new(), so every iroh panel would have read as an unexported
name. register_iroh_endpoint is split so the test can register an
EndpointMetrics::default() without standing up a socket — a real check rather
than a prefix waiver.

Four query bugs fixed while rebuilding, three of which made a panel or rule lie:

- DecdnWatcherTaskPanicked could never evaluate. rate() drops __name__, so the
  five per-watcher series on a node collapsed to identical label sets and
  Prometheus refused the vector; sum by (instance) does not help, because the
  duplicate exists before the aggregation runs. Rewritten with label_replace on
  the raw selector and an offset subtraction in place of rate().
- DecdnCacheInflightMutexPoisoned could never resolve: a bare `> 0` on a
  monotonic counter whose annotation says not to restart.
- DecdnNodeRestarted fired for five minutes after every deploy.
- The cache hit ratio clamped a per-second rate denominator to a floor of 1.0,
  understating every node doing under one lookup per second — all of them.

Also: USDC gauges are scaled out of raw 6-decimal base units and carry
currencyUSD; watcher tick-age thresholds move from 600/1800s to 120/180s so the
panel cannot read green while DecdnBlacklistWatcherStalled fires; panels that
aggregate by (instance) carry {{instance}} in the legend instead of emitting one
identically-labelled series per node; every rule gains a component label and,
where docs/runbook.md has a matching section, a runbook_url annotation.

Verified against the live stack rather than by inspection: all 266 Prometheus
targets return data, all 14 Loki and Tempo targets resolve, and the extended gate
was mutation-tested — a typo'd decdn_iroh_sockt_* in a new file fails it.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Copilot AI lite review requested due to automatic review settings September 18, 2026 00:31

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The new monitoring/dashboard-node.json contains an annotation query that references undefined template variables, which will break the dashboard’s annotations until corrected.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

This PR upgrades deCDN’s operational observability from a single reference dashboard to a four-dashboard Grafana suite spanning metrics, logs (Loki), and traces (Tempo), while also correcting several alert/query behaviors and extending the “selectors are exported” gate so new monitoring files are validated immediately.

Changes:

  • Rebuilds the fleet overview dashboard and adds three new focused dashboards (delivery, chain/payments, single-node drilldown) with metrics/logs/traces panels.
  • Fixes multiple alert/query correctness issues (notably watcher panic detection, cache mutex poisoning resolution behavior, and restart detection).
  • Extends monitoring_selectors_are_exported to sweep all monitoring/*.json and monitoring/*.yml, and expands the exported series set to include decdn_iroh_* by registering EndpointMetrics in tests.
File summaries
File Description
monitoring/prometheus-alerts.yml Adds component + runbook_url metadata and fixes several alert expressions.
monitoring/grafana-dashboard.json Rebuilds the fleet overview dashboard; adds logs/traces panels and deep-linking.
monitoring/dashboard-delivery.json New dashboard for serve/pull/cache/origin/warming delivery surfaces.
monitoring/dashboard-chain.json New dashboard for chain watchers, registries, payments, and slash-safety signals.
monitoring/dashboard-node.json New single-node drilldown dashboard combining node_exporter + decdn metrics + logs/traces.
docs/runbook.md Updates runbook “Companion assets” to list the 4-dashboard suite and rule metadata conventions.
crates/node/src/metrics.rs Splits iroh metrics registration for testability; expands selector gating to scan monitoring/.
CHANGELOG.md Documents the observability suite addition and the query/alert fixes.
adr/appendix-observability.md Updates observability appendix to reflect the new dashboard suite and gating behavior.
.claude/skills/grafana-dashboards/SKILL.md Adds repo-specific guidance for maintaining the Grafana dashboards and gating rules.
Review details
  • Files reviewed: 9/10 changed files
  • Comments generated: 2
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread monitoring/dashboard-node.json Resolved
Comment thread monitoring/prometheus-alerts.yml Resolved
@github-actions

github-actions Bot commented Sep 18, 2026 •

Copy link
Copy Markdown

Coverage report

Total: 82.97% (was 82.96%, ▲ +0.01%) — 79907/96303 lines

File Coverage Lines Δ
crates/node/src/metrics.rs 95.40% 933/978 ▲ +0.64%
History
Commit Total Δ vs base
96fa683 82.97% ▲ +0.01%
358c50d (HEAD) 82.97% ▲ +0.01%

…the watcher label

Two review findings, both real.

The node drilldown's "Node restarts" annotation carried the fleet selector
(deployment_environment/region/instance) while that dashboard defines only a
single-select $node. Grafana renders an undefined variable literally, so the
query went out as instance=~"$instance" and matched nothing — the annotation
was silently dead. annotations() now takes the dashboard's own scope instead of
assuming the fleet one, and the node board passes {instance=~"$node"}. Audited
all four boards for undefined variables; this was the only one.

DecdnWatcherTaskPanicked extracted `watcher` with `decdn_(.+)_task_panicked_total`,
which captures `slash_watcher`, so the description read "The slash_watcher watcher
task unwound". The regex now ends `_watcher_task_panicked_total` and the label
reads `slash`. Verified against the live series: the five values are blacklist,
fee_shares, settlement, slash, staker_set.

The selector stays broad. Every panic counter today is a watcher's, but a future
one that is not would still fire this rule — with an empty `watcher` label rather
than silence. For a counter whose every non-zero value is a bug, firing with a
thin message beats not firing.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
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.

2 participants