Skip to content

Commit 789ad33

Browse files
committed
prometheus: single scrape for per-track metrics
Rework of #533 made every query parameter optional, so one target covers all namespaces instead of a per-namespace list. Namespace splitting is only needed past the endpoint's limit ceiling; noted in the README along with the label encoding and the live-tracks-only lifetime.
1 parent 2233983 commit 789ad33

2 files changed

Lines changed: 28 additions & 44 deletions

File tree

docker/prometheus/README.md

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,31 @@
22

33
## Per-track metrics (`moqx-track`)
44

5-
`/metrics/track` requires a `namespace` parameter, so every namespace to be
6-
graphed is a scrape target that relabelling turns into the query parameter.
7-
Namespace values use the moq-transport encoded form — tuple elements joined by
8-
`-`, other bytes as `.<hex>`:
9-
10-
moq-test/interop -> moq.2dtest-interop
11-
conf.example.com / room 1 -> conf.2eexample.2ecom-room.201
5+
`/metrics/track` takes optional `service`, `namespace`, `track` and `limit`
6+
parameters; with none of them it reports every live track, so a single scrape
7+
covers the relay.
128

13-
`limit` is a guard rather than a selector: a namespace holding more tracks than
14-
the limit returns 400, so an over-wide scrape fails visibly instead of graphing
15-
a series set that reshuffles between scrapes. Ceiling is
16-
`admin.track_metrics_max_limit` (1000).
9+
`limit` is a guard rather than a selector: more live tracks than the limit
10+
returns 400, so an over-wide scrape fails visibly instead of graphing a series
11+
set that reshuffles between scrapes. Ceiling is
12+
`admin.track_metrics_endpoint_max_limit` (1000).
1713

18-
### Generating the target list
19-
20-
The static list needs maintaining by hand. `/state.namespace_tree` already
21-
enumerates live namespaces, so the intended replacement is a small generator
22-
that walks the tree, encodes each namespace, and writes a `file_sd` target
23-
file; Prometheus reloads target files without a restart.
14+
Past that ceiling the scrape splits by namespace prefix, one job per prefix,
15+
with `/state.namespace_tree` generating the target list into a `file_sd` file:
2416

2517
file_sd_configs:
2618
- files: ['/etc/prometheus/targets/namespaces.json']
2719
refresh_interval: 30s
2820

29-
Namespaces churn as events start and end, and a relay may hold more than the
30-
per-scrape ceiling, so this becomes necessary rather than convenient once the
31-
relay carries production traffic.
21+
Label values use the moq-transport encoded form — tuple elements joined by
22+
`-`, other bytes as `.<hex>`:
23+
24+
moq-test/interop -> moq.2dtest-interop
25+
conf.example.com / room 1 -> conf.2eexample.2ecom-room.201
26+
27+
Series exist only for live tracks: they disappear when a track ends and restart
28+
from zero if it returns, so counters need `increase()`/`rate()` rather than
29+
raw deltas across a track's lifetime.
30+
31+
Counting is installed only when `admin.track_metrics_enabled` is true (default);
32+
with it false the endpoint returns 503.

docker/prometheus/prometheus.yml

Lines changed: 7 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -73,33 +73,16 @@ scrape_configs:
7373
- target_label: __address__
7474
replacement: json-exporter:7979
7575

76-
# Per-track counters from the relay (openmoq/moqx#533). The namespace
77-
# parameter is required, so each namespace is a target relabelled into the
78-
# query. Values use the moq-transport encoded form: tuple elements joined
79-
# by "-", other bytes as ".<hex>" (moq-test/interop -> moq.2dtest-interop).
80-
#
81-
# limit is a guard, not a top-N: a namespace holding more tracks than the
82-
# limit is rejected with 400 rather than truncated, so the scrape fails
83-
# loudly instead of graphing a set that reshuffles between scrapes.
84-
#
85-
# The list is static for now. /state.namespace_tree already enumerates live
86-
# namespaces, so it should be generated into a file_sd target file and
87-
# picked up without a reload — see docker/prometheus/README.md.
76+
# Per-track counters from the relay (openmoq/moqx#533). Every parameter is
77+
# optional, so one scrape covers all namespaces. limit is a guard, not a
78+
# top-N: more live tracks than the limit returns 400 rather than a series
79+
# set that reshuffles between scrapes.
8880
- job_name: moqx-track
8981
metrics_path: /metrics/track
9082
scrape_interval: 15s
9183
params:
9284
limit: ['1000']
9385
static_configs:
94-
- targets:
95-
- moq.2dtest-interop
96-
- aiomoqt
97-
relabel_configs:
98-
- source_labels: [__address__]
99-
target_label: __param_namespace
100-
- source_labels: [__param_namespace]
101-
target_label: ns_scrape
102-
- target_label: __address__
103-
replacement: moqx:8000
104-
- target_label: instance
105-
replacement: moqx-relay
86+
- targets: ['moqx:8000']
87+
labels:
88+
instance: moqx-relay

0 commit comments

Comments
 (0)