System Observability: Logging, Metrics & Tracing (ELK + OpenTelemetry) · Lektion

Metrikkardinalität und Best Practices für Labels

Lernen Sie, wie Labels Kardinalität erzeugen, warum hohe Kardinalität Metriksysteme überlastet und wie Sie schnelle und kostengünstige Label-Schemata entwerfen.

Lektion 4 von 413 Schritte

Metrikkardinalität und Best Practices für Labels ist eine kostenlose System Observability: Logging, Metrics & Tracing (ELK + OpenTelemetry)-Lektion auf CoddyKit. Dies ist Lektion 4 von 4. Du kannst die komplette Lektion unten kostenlos lesen – dann übst du sie direkt im Browser mit einem integrierten Code-Editor und einem KI-Tutor rund um die Uhr. Sie ist Teil des System Observability: Logging, Metrics & Tracing (ELK + OpenTelemetry)-Lernpfads, und dein Fortschritt wird über Web und CoddyKit-App synchronisiert. Der System Observability: Logging, Metrics & Tracing (ELK + OpenTelemetry)-Kurs umfasst insgesamt 4 Lektionen.

Teile dieser Lektion wurden noch nicht übersetzt und werden auf Englisch angezeigt.

What Is Cardinality?

Cardinality is the number of unique time series produced by a metric. Each distinct combination of a metric name and its label values is a separate series.

  • http_requests_total{method="GET"} is one series
  • Adding status="200" multiplies the count

Labels Multiply

Cardinality grows by the product of the number of values per label. Three methods times five status codes times ten endpoints equals 150 series for one metric.

method: 3 values
status: 5 values
endpoint: 10 values
=> 3 * 5 * 10 = 150 series

Why High Cardinality Hurts

Each series consumes memory, disk, and index space. Unbounded labels can explode a single metric into millions of series, slowing queries and crashing collectors.

  • Memory pressure on the TSDB
  • Slow dashboards and alerts
  • Higher storage cost

The Classic Anti-Pattern

Putting unbounded values like user IDs, request IDs, or full URLs into labels is the most common mistake. These create one series per unique value.

http_requests_total{user_id="48213"}
http_requests_total{request_id="a9f...c1"}

Bounded vs Unbounded Labels

Good labels have a small, finite set of values.

  • Bounded: method, status_class, region
  • Unbounded: user_id, session_id, email

Keep unbounded data in logs or traces, not metric labels.

Normalize Before Labeling

Reduce cardinality by bucketing values. Replace exact status codes with classes and template dynamic path segments.

status=503  ->  status_class="5xx"
/users/48213 -> route="/users/:id"

Estimating Series Count

Before adding a label, estimate its impact. Multiply the existing series count by the number of new label values.

existing = 200 series
new label region: 4 values
=> 200 * 4 = 800 series

Aggregation Removes Detail

When you query, aggregations like sum by (status_class) collapse series. Design labels so the dimensions you aggregate by are exactly the ones you need.

sum by (status_class) (rate(http_requests_total[5m]))

Limits and Guardrails

Most TSDBs let you cap cardinality.

  • Prometheus: sample_limit per scrape
  • OpenTelemetry: cardinality limit on aggregations
  • Alert when series counts spike

Dropping Bad Labels

If a noisy label slips in, drop or relabel it at ingestion rather than storing it.

metric_relabel_configs:
  - source_labels: [user_id]
    action: labeldrop

A Healthy Label Set

Aim for a handful of bounded labels per metric. This example stays well under a few hundred series.

orders_total{region="eu", status_class="2xx", channel="web"}

Quick Check

Identify the riskiest label choice.

Recap

You learned that cardinality is the count of unique series, that labels multiply it, and that unbounded values like IDs must stay out of labels. Bucket and template values, estimate impact before adding labels, and enforce guardrails to keep metrics fast and cheap.

Kostenlos starten

Lerne System Observability: Logging, Metrics & Tracing (ELK + OpenTelemetry) mit einem KI-Tutor — kostenlos

Schreibe und führe echten Code in deinem Browser aus, bekomme sofortige Hilfe von einem 24/7 KI-Tutor und setze dein Lernen im Web oder in der App fort.

Kurse
12
Lektionen
48

Häufig gestellte Fragen

Ist die Lektion „Metrikkardinalität und Best Practices für Labels“ kostenlos?

Ja — der vollständige Text von „Metrikkardinalität und Best Practices für Labels“ ist hier im Web kostenlos zu lesen. Um sie interaktiv zu üben (integrierter Code-Editor und 24/7 KI-Tutor) und den Rest des System Observability: Logging, Metrics & Tracing (ELK + OpenTelemetry)-Kurses freizuschalten, upgrade auf CoddyKit PRO. Der System Observability: Logging, Metrics & Tracing (ELK + OpenTelemetry)-Kurs umfasst insgesamt 4 Lektionen.

Was lerne ich in „Metrikkardinalität und Best Practices für Labels“?

Lernen Sie, wie Labels Kardinalität erzeugen, warum hohe Kardinalität Metriksysteme überlastet und wie Sie schnelle und kostengünstige Label-Schemata entwerfen. Du übst System Observability: Logging, Metrics & Tracing (ELK + OpenTelemetry) mit praktischem Code, den du direkt im Browser ausführst, und ein 24/7 KI-Tutor beantwortet deine Fragen während du die Lektion bearbeitest.

Brauche ich Erfahrung, um System Observability: Logging, Metrics & Tracing (ELK + OpenTelemetry) zu starten?

Keine Vorkenntnisse erforderlich. System Observability: Logging, Metrics & Tracing (ELK + OpenTelemetry) auf CoddyKit ist für Anfänger bis fortgeschrittene Lernende strukturiert, sodass du hier starten oder von Anfang an beginnen und in deinem eigenen Tempo voranschreiten kannst. Dies ist Lektion 4 von 4.

Wie lange dauert die Lektion „Metrikkardinalität und Best Practices für Labels“?

Die meisten CoddyKit-Lektionen dauern etwa 5–10 Minuten. Jede ist kompakt und interaktiv, sodass du stetig Fortschritte machst und genau dort weitermachst, wo du aufgehört hast – im Web und in der App.

Kann ich in dieser System Observability: Logging, Metrics & Tracing (ELK + OpenTelemetry)-Lektion Code schreiben und ausführen?

Ja. Jede System Observability: Logging, Metrics & Tracing (ELK + OpenTelemetry)-Lektion enthält einen integrierten Code-Editor, sodass du echten Code direkt in deinem Browser schreibst und ausführst und sofort KI-Feedback erhältst — ohne lokale Einrichtung erforderlich.

Alle Lektionen in diesem Kurs

  1. Metriktypen erklärt
  2. Strategien zur Metrikerfassung
  3. Metrikvisualisierung und Alerting
  4. Metrikkardinalität und Best Practices für Labels
← Zurück zu System Observability: Logging, Metrics & Tracing (ELK + OpenTelemetry)