Home » High-Cardinality Metrics When the Series Count Looks Flat

High-Cardinality Metrics When the Series Count Looks Flat

A metric label fans into many distinct time series.

At 09:00 an API metric returned eight series. At 09:10 it returned eight again. An operator looking only at those two counts would miss that every request ID had changed. We loaded both snapshots into Prometheus and asked which label could come out while preserving the dashboard answer: how many of the sampled orders requests returned an error?

Count what Prometheus actually saw

The downloadable input contains two synthetic batches of eight requests, timestamped ten minutes apart. In each batch, four requests to the orders route returned 200, two returned 500, and two requests to the status route returned 200. Each request has a distinct ID and a gauge value of one. A second gauge records the count for each route and status in the same batch. These are snapshots of two batches. A running service would usually count completed requests with a counter.

Prometheus identifies a series by its metric name and complete label set. At either instant the detailed metric had two routes, two statuses and eight IDs. Multiplying those numbers gives 32 possible combinations. Only eight were present. For example, the status route had no 500 response. Prometheus data model.

Result from Prometheus 2.54.1 09:00 UTC 09:10 UTC
Detailed series at that instant 8 8
Distinct request IDs at that instant 8 8
Distinct route and status pairs 3 3
Detailed series seen in the preceding 11 minutes 8 16
Pre-aggregated series seen in the same window 3 3

The two instant queries below count different things. The first counts complete label sets. The inner aggregation in the second leaves one result per route and status. The third query looks back far enough from 09:10 to include both batches. Its inner function emits a sample count for each distinct series present in that window. The outer count counts those series. Aggregation operators · Range functions.

count(cf_request_trace_sample)
count(count by (route, status) (cf_request_trace_sample))
count(count_over_time(cf_request_trace_sample[11m]))

The sample times are farther apart than the default five-minute instant lookback. In this fixture the 09:10 instant query sees the second batch, while the range query sees both. Sixteen is a count of observed label sets across the window. Measuring backend memory, head series or a production series-creation rate requires additional evidence. PromQL selection and lookback.

Keep the two failed orders visible

For a migration check, compare sum by (route, status) (cf_request_trace_sample) with cf_request_group at each timestamp. Match on route and status and compare values. Both designs returned four successful orders, two failed orders and two successful status requests. The dashboard could still answer two of six orders failed in each sample. Simply stripping the ID from the original samples would leave several identical label sets at the same timestamp. The replacement needs an explicit counting rule.

Download the sample series, PromQL and results (ZIP)

Try the same check for a proposed route-only metric. It can report six orders, but it has discarded the status needed to count the failures. Keep bounded route and status dimensions for that question. Carry individual request IDs in logs or traces where an operator can follow a particular request. Metric and label naming · Choosing between logs, metrics and traces.

For a real migration, scope the comparison to one metric and service, run both instruments over the same representative window, and replay the existing alert expression before switching dashboards. For counters, take the per-series rate before summing so instance resets remain visible. The three-group result here establishes that the sample dashboard answer survived. Actual series savings depend on the labels and traffic your service emits.

You may also like