Video in progress
In an organization with many teams, how do you manage metric cardinality so that one team's mistake doesn't take down everyone's monitoring?
Three layers: in code (tags banned at the library level and MeterFilter), in the pipeline (relabeling and tenant limits in the collector or remote write), and organizationally (a series budget per team, visible consumption on a dashboard, and an automatic warning when it is exceeded).
📖 Answer
Cardinality is a shared resource and a "tragedy of the commons" problem: one extra label looks cheap for each team, but together they take the platform down.
- Make the defaults safe, inside the internal starter library (which all services use):
@Bean
MeterFilter dropNoisyMeters() {
return MeterFilter.denyNameStartsWith("jvm.buffer."); // unneeded details
}
@Bean
MeterFilter limitUriTags() {
return MeterFilter.maximumAllowableTags("http.server.requests", "uri", 200, MeterFilter.deny());
}
// also: a filter that rejects tag keys like userId, email, orderId, sessionId
This has to be in the starter. Nobody reads a wiki page.
-
Limits in the pipeline: in Mimir or a similar system, per-tenant
max_global_series_per_userand ingestion rate limits. When a limit is exceeded, new series from that tenant are rejected and the others are not affected. In the collector or Prometheus relabeling, drop certain labels (pod_template_hash, rawpath). -
A visible budget: a dashboard per team that says something like "you have 400k series, the budget is 500k, last week +120k, caused by the
checkout_items_totalmetric". People fix their own consumption when they can see it. -
When you need high cardinality, use another tool: if a team really needs "latency per customer", the answer is not to ban it but to point it to the right place: trace attributes, wide events or an analytics database (ClickHouse). Metrics are for aggregates with low cardinality.
An important subtlety: a team that hits its limit has to know right away. Silently rejected series turn into "why is my graph empty" tickets. So the rejection events are also delivered to the team itself, as a metric and an alert.
Sign up to mark studied questions and save your progress.