Skip to main content
Cardinality (in metrics and observability) refers to the number of unique combinations of metric attributes, often called labels or dimensions. In practice, it describes how many distinct values those dimensions can produce — and directly affects the number of metric series your backend must store and query.
The image defines cardinality as the number of unique combinations of metric attributes (dimensions). It includes a quote design and has a copyright notice by KodeKloud.

Cardinality levels (quick summary)

Cardinality levelDescriptionCommon examplesWhen to use
LowFew distinct values, bounded setHTTP status (200, 404, 500), region (us-east, eu-west)Broad monitoring and alerting; low cost
MediumModerate number of distinct valuesservice name, instance type, modelSegment analysis and trend detection
HighMany unique values, often unboundeduser_id, request_id, registration_numberRoot-cause analysis, per-entity investigation (use sparingly)
The image explains cardinality, distinguishing between low cardinality (small set of known values, e.g., status codes) and high cardinality (many unique values, e.g., IDs).

Why cardinality matters

Cardinality affects cost, memory, query time, and dashboard responsiveness. Each unique combination of labels typically becomes a separate metric series:
  • Low-cardinality metrics are cheap to store and fast to query.
  • High-cardinality metrics can explode the number of series and increase ingestion and query costs.
  • High-cardinality data is invaluable for targeted troubleshooting and identifying outliers, but requires careful design so your observability backend is not overwhelmed.
The image explains the importance of cardinality, highlighting its impact on cost, memory, performance, and its role in diagnosing anomalies and outliers. Additionally, it includes a graphic of a dashboard with charts and graphs.
High-cardinality data is powerful for investigations — but must be used judiciously to balance operational cost and backend performance.

Example: vehicle telemetry (low → high)

The following JavaScript snippet shows vehicle records where attributes vary in cardinality. This illustrates how different groupings produce different analytical granularity.
  • Group by fuel_type (low cardinality) — good for broad, cost-effective insights.
  • Group by model (medium cardinality) — reveals more granular trends by model.
  • Group by registration (high cardinality) — inspects specific vehicles (one point per entity).
The image shows a table titled "Analyzing Car Data by Attributes," listing various cars with details such as registration number, make, model, color, fuel type, and kilometers run.
Using different groupings yields different business questions and costs. For example:
The image shows a bar graph comparing the average kilometers run by vehicles with different fuel types: Diesel, Electric, Hybrid, and Petrol. Petrol and Diesel vehicles have the highest average kilometers, while Hybrid vehicles have the lowest.
Grouping by model provides more detail than fuel type:
The image is a bar chart showing the average kilometers run by various car models, with the highest being the CR-V and X3 models exceeding 120,000 kilometers. The chart is titled "Medium Cardinality – Average Kilometers Run by Car Model."
Grouping by registration (per-vehicle) is high cardinality and useful when you must pinpoint an exact entity.

Real-world example: e-commerce

In e-commerce, datasets might include user_id, loyalty_tier, country, city, product_category, purchase_channel, and total_spend. Choose grouping keys based on the analysis you need:
The image displays an eCommerce dataset for cardinality analysis, featuring columns such as user ID, user type, loyalty level, location details, product category, purchase channel, and total purchase amount.
  • Group by loyalty_tier (low cardinality) to view overall trends quickly:
The image shows a bar chart titled "Low Cardinality – Total Purchases by Loyalty Status," comparing total purchases across Gold, Platinum, and Silver loyalty statuses, with Platinum having the highest purchases.
  • Group by city (medium cardinality) for regional insights.
  • Group by user_id (high cardinality) to surface top individual spenders or investigate an individual user issue.
High cardinality enables user-level troubleshooting and business analytics (e.g., identifying the top spender), but it increases the number of metric series.
The image presents a table describing attributes, types, cardinality, and example values, focusing on "userID" with high cardinality and "state" with low cardinality in a real-world context.
The image is a table showcasing high cardinality key aspects using userID and state attributes, with userID having high cardinality and state having low cardinality. It also includes use cases related to backend load and error spikes.
High-cardinality metrics provide detailed, actionable insight but increase the number of metric series. Design labels to balance operational needs with backend cost and performance.
Warning: storing and querying high-cardinality data increases backend load. Confirm your observability backend can handle the ingestion and query volume before adding many high-cardinality labels.

Practical guidance and patterns

  • Use low-cardinality attributes for broad monitoring and alerting: cheaper and faster.
  • Use medium cardinality for deeper trend analysis and segmentation.
  • Use high-cardinality attributes sparingly for root-cause analysis or specific investigations.
  • If you need per-entity visibility but want to limit metric cost:
    • Apply sampling for high-frequency entities.
    • Aggregate or bucket values (e.g., percentile or range buckets).
    • Store high-cardinality details in traces or logs and link them to aggregated metrics when necessary.
    • Use labeling strategies that avoid combinatorial explosion (e.g., avoid mixing many high-cardinality labels on a single metric).

Summary

Cardinality is a key design decision in observability. Thoughtful selection of labels and aggregation levels ensures useful insights while keeping costs and backend load manageable. Balance granularity with practicality: instrument enough detail to troubleshoot and analyze, but avoid unnecessary high-cardinality series.

Watch Video