0Pricing
System Observability: Logging, Metrics & Tracing (ELK + OpenTelemetry) · Lekcja

Kardynalność metryk i dobre praktyki etykietowania

Dowiedzą się Państwo, jak etykiety tworzą kardynalność, dlaczego wysoka kardynalność obciąża systemy metryk oraz jak projektować schematy etykiet, które pozostają szybkie i niedrogie.

Kardynalność metryk i dobre praktyki etykietowania to bezpłatna lekcja System Observability: Logging, Metrics & Tracing (ELK + OpenTelemetry) na CoddyKit. To lekcja 4 z 4. Możesz przeczytać całą lekcję poniżej za darmo — a potem ćwiczyć ją interaktywnie w przeglądarce z wbudowanym edytorem kodu i tutorem AI dostępnym 24/7. To część ścieżki edukacyjnej System Observability: Logging, Metrics & Tracing (ELK + OpenTelemetry), a Twój postęp synchronizuje się między webem a aplikacją CoddyKit. Kurs System Observability: Logging, Metrics & Tracing (ELK + OpenTelemetry) zawiera 4 lekcji w sumie.

Części tej lekcji nie zostały jeszcze przetłumaczone i są wyświetlane po angielsku.

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.

Często zadawane pytania

Czy lekcja „Kardynalność metryk i dobre praktyki etykietowania” jest bezpłatna?

Tak — pełny tekst „Kardynalność metryk i dobre praktyki etykietowania” jest dostępny za darmo tutaj w sieci. Aby ćwiczyć ją interaktywnie (wbudowany edytor kodu i tutor AI dostępny 24/7) i odblokować resztę kursu System Observability: Logging, Metrics & Tracing (ELK + OpenTelemetry), przejdź na CoddyKit PRO. Kurs System Observability: Logging, Metrics & Tracing (ELK + OpenTelemetry) zawiera 4 lekcji w sumie.

Co nauczysz się w „Kardynalność metryk i dobre praktyki etykietowania”?

Dowiedzą się Państwo, jak etykiety tworzą kardynalność, dlaczego wysoka kardynalność obciąża systemy metryk oraz jak projektować schematy etykiet, które pozostają szybkie i niedrogie. Ćwiczysz System Observability: Logging, Metrics & Tracing (ELK + OpenTelemetry) z praktycznym kodem, który uruchamiasz bezpośrednio w przeglądarce, a tutor AI dostępny 24/7 odpowiada na Twoje pytania podczas pracy nad lekcją.

Czy potrzebuję doświadczenia, aby zacząć System Observability: Logging, Metrics & Tracing (ELK + OpenTelemetry)?

Nie wymagamy żadnego doświadczenia. System Observability: Logging, Metrics & Tracing (ELK + OpenTelemetry) w CoddyKit jest strukturyzowany dla początkujących i zaawansowanych użytkowników, więc możesz zacząć tutaj lub od początku i uczyć się w swoim tempie. To lekcja 4 z 4.

Ile czasu zajmuje lekcja „Kardynalność metryk i dobre praktyki etykietowania”?

Większość lekcji CoddyKit trwa około 5–10 minut. Każda lekcja to mały, interaktywny krok, dzięki czemu robisz systematyczne postępy i zawsze wracasz dokładnie do tego samego miejsca — na webie i w aplikacji.

Czy mogę pisać i uruchamiać kod w tej lekcji System Observability: Logging, Metrics & Tracing (ELK + OpenTelemetry)?

Tak. Każda lekcja System Observability: Logging, Metrics & Tracing (ELK + OpenTelemetry) zawiera wbudowany edytor kodu, więc piszesz i uruchamiasz prawdziwy kod bezpośrednio w przeglądarce i od razu otrzymujesz sprzężenie zwrotne od AI — bez konfiguracji na komputerze.

Wszystkie lekcje w tym kursie

  1. Wyjaśnienie typów metryk
  2. Strategie zbierania metryk
  3. Wizualizacja metryk i alerty
  4. Kardynalność metryk i dobre praktyki etykietowania
← Powrót do System Observability: Logging, Metrics & Tracing (ELK + OpenTelemetry)