Metric cardinality¶
Per-agent series¶
These series include an instance_uid label:
grex_agent_healthgrex_agent_last_seen_timestamp_seconds
Unbounded agent counts would create unbounded Prometheus series. grex applies
metrics.per_agent_series_limit (default 1000).
Cap behavior¶
When len(agents) > per_agent_series_limit:
- All per-agent series are omitted (not a random subset)
- Aggregate fleet gauges/counters still emit
grex_fleet_sizecontinues to show true registry sizegrex_agent_series_cappedis set to 1
When under the limit, grex_agent_series_capped is 0.
Operator response¶
- Alert on
grex_agent_series_capped == 1(see Alerts) - Raise
per_agent_series_limitonly if Prometheus can absorb the series - Or accept aggregates-only fleet metrics and rely on the grex UI/API for per-agent drill-down
- Confirm
sample_limiton the fleet scrape job still has headroom
Other cardinality sources¶
| Source | Risk | Mitigation |
|---|---|---|
grex_agent_missing_attributes_total{attribute} |
One series per required key | Small fixed set of keys |
grex_agent_reports_total{type} |
Fixed enum of report kinds | Low |
grex_api_*{route,method,code} |
Routes are fixed set | Low |
grex_agents_connected{transport,via} |
2×2 label set | Low |
Do not add high-cardinality labels (raw hostnames, full config hashes) to new metrics without an explicit SPEC decision.