Commit 58c123e
feat(BA-5878): emit stats.rate window queries for io_read/io_write/net_rx/net_tx
Legacy live_stat consumers — most importantly the
legacy_compute_session.net_rx_bytes / net_tx_bytes / io_read_bytes /
io_write_bytes GraphQL resolvers — read the "stats.rate" key from the
per-metric live_stat dict. The new PromQL pipeline previously emitted
nothing under that label, leaving those four legacy fields uncovered:
- io_read / io_write: legacy agent's stats_filter={"rate"}, which the
new pipeline did not produce.
- net_rx / net_tx: legacy agent's stats_filter is empty, so the agent
publishes no stats.rate at all even though the legacy resolver
expects it — making the resolver always return 0. The new pipeline
now produces a value where legacy never did.
Two metric shapes flow through the new bucket:
- Gauge-shape (net_rx, net_tx): the metric's `current` value is
already a per-second rate (set by agent's
current_hook = lambda m: m.stats.rate), so PromQL only needs to
sum across replicas and label_replace to "stats.rate".
- Counter-shape (io_read, io_write): the value is a cumulative byte
counter, so PromQL applies rate(...[window]) before label_replace.
Live verified against Prometheus on a running kernel:
{net_rx, stats.rate} = 27530
{net_tx, stats.rate} = 30378
{io_read, stats.rate} = 0
{io_write, stats.rate} = 0
Re-introduces ValueType.RATE (and its to_legacy_live_stat_label /
from_live_stat_label round-trip) that was removed earlier in the
branch when no producer existed; the round-trip is now load-bearing
again.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>1 parent e781b81 commit 58c123e
4 files changed
Lines changed: 66 additions & 3 deletions
File tree
- src/ai/backend/common/clients/prometheus
- tests/unit/manager/services/utilization_metric
Lines changed: 28 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| 15 | + | |
| 16 | + | |
15 | 17 | | |
16 | 18 | | |
17 | 19 | | |
| |||
164 | 166 | | |
165 | 167 | | |
166 | 168 | | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
167 | 195 | | |
168 | 196 | | |
169 | 197 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
61 | 61 | | |
62 | 62 | | |
63 | 63 | | |
64 | | - | |
| 64 | + | |
65 | 65 | | |
66 | 66 | | |
67 | 67 | | |
68 | 68 | | |
69 | 69 | | |
70 | 70 | | |
| 71 | + | |
71 | 72 | | |
72 | 73 | | |
73 | | - | |
| 74 | + | |
74 | 75 | | |
75 | 76 | | |
76 | 77 | | |
| |||
91 | 92 | | |
92 | 93 | | |
93 | 94 | | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
94 | 105 | | |
95 | 106 | | |
96 | 107 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| 13 | + | |
13 | 14 | | |
14 | 15 | | |
15 | 16 | | |
| |||
21 | 22 | | |
22 | 23 | | |
23 | 24 | | |
24 | | - | |
| 25 | + | |
25 | 26 | | |
26 | 27 | | |
27 | 28 | | |
| |||
Lines changed: 23 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
847 | 847 | | |
848 | 848 | | |
849 | 849 | | |
| 850 | + | |
| 851 | + | |
| 852 | + | |
| 853 | + | |
| 854 | + | |
| 855 | + | |
| 856 | + | |
| 857 | + | |
| 858 | + | |
| 859 | + | |
| 860 | + | |
| 861 | + | |
| 862 | + | |
| 863 | + | |
| 864 | + | |
| 865 | + | |
| 866 | + | |
| 867 | + | |
| 868 | + | |
| 869 | + | |
| 870 | + | |
| 871 | + | |
| 872 | + | |
850 | 873 | | |
851 | 874 | | |
852 | 875 | | |
| |||
0 commit comments