Skip to content

aether_requests_total resets to ~0 on every proxy hot restart — counter values are not carried parent→child (labels are, since #707) #708

Closed

Description

@bpalermo

Observation

aether_requests_total (and presumably every aether_stats counter) resets on every proxy roll instead of carrying its value across the cross-pod hot restart:

proxy roll sum(aether_requests_total) before → after
19:09Z (rev197: v1.39.0 parent → 1.40-dev child, regexes present) 1,063,305 → 17,073
19:40Z (rev198: 1.40-dev → 1.40-dev, regexes removed) 233,133 → 6,416

Series identity (labels) is unchanged across the roll — the same 25 series, fully labelled, keep being exported — only the values restart from ~0. This matches the standing soak note that Envoy counters "reset and vanish on pod replacement", so it is pre-existing and independent of #707/#695; recording it because the hot-restart StatMerger is supposed to transfer counter deltas parent→child, so continuity is what the design promises.

Why it might happen (unmeasured)

  1. The aether_stats counters are looked up by the child's filter through a name that mixes symbolic and dynamic segments (tag values interned via StatNameDynamicPool); if the parent's DynamicsMap spans are not shipped for these names, the child creates a second, fresh counter and the merged one is never written again — exactly the two-counter failure tag_extraction_test had to model in chore: retire the aether_stats stats_tags regex workaround (#695 step 4) #707. Production is believed to ship the spans, but this observation says the exported value comes from a counter that starts at zero.
  2. The OTel stats sink exports the child's counter from process start, and the merge lands on a different Counter instance.
  3. Cross-pod hot restart via the shared UDS may not run the stats transfer at all in aether's supervisor flow (proposal 001) — check hotrestart for whether the parent's exportStatsToChild ever executes across pods.

Why it matters

Every per-run "total" read of an aether_* counter across a roll is wrong by the pre-roll value; soak grading already works around it with max_over_time/per-series deltas, and the prober (not Envoy) is authoritative for the SLI — so this is an observability defect, not a data-path one. But it also means the aether_requests_total-based Grafana panels dip to zero on every rollout.

Ask

Determine which of the three it is (a debug log of StatMerger::mergeCounters hits for aether.requests_total on a child start would settle 1 vs 3), then either ship the spans / fix the lookup, or document that aether counters are per-generation by design and switch the dashboards to increase() over per-generation series.

Refs #695, #707, envoy#45674.

Activity

  1. bpalermo commented on Sep 5, 2026

    @bpalermo
    OwnerAuthor

    Plan (2026-09-05): not a bug — Envoy transfers counter DELTAS on hot restart; the OTel sink exports cumulative-per-process. Fix the consumers and the docs.

    Mechanism (Envoy at 13144fb, the deployed snapshot)

    1. The stats transfer DOES run: buildEnvoyCmd (agent/internal/proxy/hotrestart/supervisor.go) never passes --skip-hot-restart-parent-stats; envoy_server_hot_restart_epoch increments per node exactly at every reset boundary.
    2. HotRestartingParent::exportStatsToChild sends counter.latch() — the pending increment, not the value; StatMerger::mergeCounters does .add(). Gauges go absolute, counters go as deltas.
    3. The parent has been latching those increments away every 5s for its whole life: MetricSnapshotImpl calls counter.latch() on each flush (flushMetricsToSinks even carries a comment that hot restart depends on this). The chart sets no stats_flush_interval → 5s default. Latching only stops at shutdownAdmin(), which the child triggers right before terminating the parent. So the child inherits ≈ the last ≤5s of parent traffic.
    4. The OTel sink (open_telemetry_impl.cc) exports counter.value() with AGGREGATION_TEMPORALITY_CUMULATIVE and start_time_unix_nano = this process's sink-creation time. Envoy is being honest: a new cumulative series starting at the child's start. Raw sum(aether_requests_total) is what lies.

    Discriminators (already measured on talos, 19:08–19:13Z roll)

    • Plain Envoy counters reset in the same buckets: sum(envoy_cluster_upstream_cx_total) (all-symbolic, no programmatic tags, no dynamic spans) resets at the same 600s buckets as sum(aether_requests_total). Refutes the two-counter / dynamic-span hypotheses outright.
    • The transferred residual is ~one flush interval: per node 139047→683, 266735→1559, 131812→339, 259710→379, 266301→1147, then each resumes at its exact prior slope (~1000/min w01, ~1930/min w02). Every first post-restart sample is < 1 minute of that node's traffic — delta semantics exactly. If the merge were not running the floor would be 0 with no residual.
    • Series identity is stable: label set is exactly destination_pod, destination_service, node, reporter, response_code, response_flags, source_pod, source_service (no pod/instance/job); node comes from the collector's k8s.node.name backstop and survives pod replacement. Matches proxy: bump Envoy to v1.40.0 to pick up envoy#45674 (hot-restart stat tags) and retire the aether_stats stats_tags regex workaround; envoy#45975 already in v1.39.0, leave envoy#45976 unset #695's 25-of-25 finding. The clean monotone ramp (no sawtooth, no duplicate-timestamp rejections) rules out two live counters.
    • The sum() step-down (8.58M → 2.80M → 99k) is the DaemonSet walking the fleet: for one bucket the sum mixes generations.

    So hypotheses (1) two-counter, (2) transfer not running, (3) identity relabel are all refuted. Proposal 001's "counters carry over" exit criterion was over-stated: Envoy preserves delta continuity (for statsd/metrics_service sinks), never absolute continuity for a cumulative exporter.

    Fix (one PR)

    1. charts/aether/templates/agent-proxy-configmap.yaml: a "counter values are per-generation" note next to the tag-propagation note, with the rule never read a raw counter; rate()/increase() only (Chart.yaml bump: comment is inside the rendered envoy.yaml).
    2. docs/proposals/001_proxy-hot-restart.md: correct "stats carried over" (l.85), "counters carry over" (l.129), "stat continuity" (l.177) → listen FDs and gauges carry over; counters as deltas only; cite the measurement.
    3. docs/proposals/012_aether_stats_cpp_extension.md, 013_mesh-availability-prober.md: make the per-generation caveat explicit where aether_requests_total is described (013 already says the prober is authoritative for the SLI — right posture).
    4. Dashboards / soak grading: any raw sum(aether_requests_total) → sum(increase(...[$__range])) or sum by (node)(rate(...[5m])). The soak's per-series-delta rule becomes the documented pattern, not a workaround.
    5. Guarding test in proxy/source/extensions/filters/http/aether_stats/tag_extraction_test.cc (the HotRestartTagPropagationTest fixture already has a real parent store + StatMerger): latch the parent counter (simulating the periodic flush), merge, assert the child's value equals only the post-latch residual — pin "counters transfer as deltas" as an intentional invariant.

    Rejected: making values continuous

    • report_counters_as_deltas: true on the sink + deltatocumulative in the collector: sink-wide flag (flips every counter); Prometheus's OTLP receiver here has no delta ingestion; and the collector runs 2 replicas behind one Service (the same fact that forced out_of_order_time_window: 30m), so two stateful converters would each see half of a series' deltas → silently wrong. Hard blocker on this cluster.
    • Upstream change to send absolute counters: would double-count for every delta-consuming sink; a contract change upstream would rightly reject. Not opening a PR.
    • No change to aether_stats tag interning; chore: retire the aether_stats stats_tags regex workaround (#695 step 4) #707 proved the dynamic-span round-trip.

    Validation on talos (across one rollout restart ds/aether-proxy)

    Assert the right invariant — not monotonicity:

    1. sum by (node)(aether_requests_total) drops per node as its epoch increments; drop floor < 1 min of that node's traffic.
    2. sum(rate(aether_requests_total[5m])) shows no dip and no spike through the roll; sum(increase(...[1h])) spanning the roll ≈ the pre-roll hourly volume.
    3. sum(envoy_cluster_upstream_cx_total) resets in the same buckets (generic, not aether-specific).
    4. count(aether_requests_total{reporter!="",source_service!=""}) == count(aether_requests_total); zero series with tag keys in __name__ (chore: retire the aether_stats stats_tags regex workaround (#695 step 4) #707 invariant holds).
    5. envoy_server_hot_restart_epoch +1 on every node, restartCount 0, prober liveness 0.
  2. bpalermo commented on Sep 5, 2026

    @bpalermo
    OwnerAuthor

    Validated on talos-main after the #711 merge (helm rev199, chart 0.92.5, 21:01–21:06Z 2026-09-05; the ConfigMap comment forced a proxy hot restart on every node, epochs w01 38→40, w02 39→41, w03 38→40, w04 39→41, w05 38→39): sum(rate(aether_requests_total[2m])) min 127/s, max 128/s across the 5-minute roll window vs 128/s baseline — no dip, no spike; raw per-node counters restarted at 3,276–7,704 (the expected per-generation residual); label integrity 25/25 fully-labelled series (the #707 invariant); prober liveness 0/6,590; restarts 0. The invariant the plan asks for holds; the raw-counter reset is real and correct, as documented.

  3. bpalermo commented on Sep 6, 2026

    @bpalermo
    OwnerAuthor

    Soak 2026-09-06 grade — a caveat found while following the "use rate()/increase(), never raw sums" rule that #708 motivated.

    The rule is right for anything #708 made per-generation. But applied to the external prober counters it cost accuracy, because increase() extrapolates:

    method, same series (w05, authoritative path) count
    sum by(node,target)(increase(...[480m])) over the whole window 36 (exact)
    sum by(node,target)(increase(...[5m])) > 0.5 tiled at 300 s step 27 — 9 events lost at bucket edges
    raw per-minute delta x - (x offset 1m) > 0 36 (reconciles)

    At a 60 s scrape, increase(...[5m]) carries a ×1.25 extrapolation factor and misattributes steps that land near a bucket boundary. The full-window [480m] figure is fine (factor 1.0021); the short buckets are not.

    Practical split for future grades: the prober DaemonSet is not touched by churn (0 restarts in 7d13h here), so its counters are continuous and raw deltas are both safe and exact — use them for episode localisation. Reserve the rate()/increase()-only rule for the configmap-derived, per-generation counters #708 actually changed. Worth wording it that way in the runbook so the next grade doesn't lose a quarter of its episodes to extrapolation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions