Skip to content

Commit 4352d7e

Browse files
committed
prometheus: scrape per-track metrics from /metrics/track
Namespace is a required parameter and there is no enumeration endpoint, so namespaces are targets relabelled into the query. The static list should be generated from /state.namespace_tree into a file_sd file; noted in the README. Needs #533.
1 parent e4e07a1 commit 4352d7e

2 files changed

Lines changed: 62 additions & 0 deletions

File tree

docker/prometheus/README.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Prometheus scrape config
2+
3+
## Per-track metrics (`moqx-track`)
4+
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
12+
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).
17+
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.
24+
25+
file_sd_configs:
26+
- files: ['/etc/prometheus/targets/namespaces.json']
27+
refresh_interval: 30s
28+
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.

docker/prometheus/prometheus.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,3 +72,34 @@ scrape_configs:
7272
target_label: __param_target
7373
- target_label: __address__
7474
replacement: json-exporter:7979
75+
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.
88+
- job_name: moqx-track
89+
metrics_path: /metrics/track
90+
scrape_interval: 15s
91+
params:
92+
limit: ['1000']
93+
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

0 commit comments

Comments
 (0)