System Observability: Logging, Metrics & Tracing (ELK + OpenTelemetry) · レッスン

メトリクスのカーディナリティとラベル付けのベストプラクティス

ラベルがカーディナリティを生む仕組み、高カーディナリティがメトリクスシステムを破綻させる理由、そして高速で低コストを保つラベル設計を学びます。

レッスン 4/413 ステップ

「メトリクスのカーディナリティとラベル付けのベストプラクティス」はCoddyKit上の無料System Observability: Logging, Metrics & Tracing (ELK + OpenTelemetry)レッスンです。 これはレッスン4/4です。 下記で完全なレッスンを無料で読むことができます。その後、ブラウザ内の組み込みコードエディタと24時間対応のAIチューターでハンズオン演習できます。 これはSystem Observability: Logging, Metrics & Tracing (ELK + OpenTelemetry)学習パスの一部であり、ウェブとCoddyKitアプリ全体で進捗が同期されます。 System Observability: Logging, Metrics & Tracing (ELK + OpenTelemetry)コースには全4レッスンが含まれています。

このレッスンの一部はまだ翻訳されておらず、英語で表示されています。

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.

無料で開始

AI チューターと学ぶ System Observability: Logging, Metrics & Tracing (ELK + OpenTelemetry) — 無料

ブラウザでリアルコードを書いて実行し、24/7 の AI チューターから瞬時にサポートを受け、ウェブまたはアプリで続きから学習できます。

コース
12
レッスン
48

よくある質問

「メトリクスのカーディナリティとラベル付けのベストプラクティス」レッスンは無料ですか?

はい。「メトリクスのカーディナリティとラベル付けのベストプラクティス」の完全なテキストはこのウェブで無料で読めます。インタラクティブに演習し(組み込みコードエディタと24時間対応のAIチューター)、System Observability: Logging, Metrics & Tracing (ELK + OpenTelemetry)コースの残りをアンロックするには、CoddyKit PROにアップグレードしてください。 System Observability: Logging, Metrics & Tracing (ELK + OpenTelemetry)コースには全4レッスンが含まれています。

「メトリクスのカーディナリティとラベル付けのベストプラクティス」で何を学びますか?

ラベルがカーディナリティを生む仕組み、高カーディナリティがメトリクスシステムを破綻させる理由、そして高速で低コストを保つラベル設計を学びます。 ブラウザで直接実行するハンズオンコードでSystem Observability: Logging, Metrics & Tracing (ELK + OpenTelemetry)を演習し、24時間対応のAIチューターがレッスンを進める中での質問に答えます。

System Observability: Logging, Metrics & Tracing (ELK + OpenTelemetry)を始めるのに経験は必要ですか?

事前経験は必要ありません。CoddyKitのSystem Observability: Logging, Metrics & Tracing (ELK + OpenTelemetry)は初級者から上級者向けに構成されているため、ここから始めるか最初から始めて、自分のペースで進むことができます。 これはレッスン4/4です。

「メトリクスのカーディナリティとラベル付けのベストプラクティス」レッスンにはどのくらい時間がかかりますか?

ほとんどのCoddyKitレッスンは約5~10分かかります。各レッスンはコンパクトでインタラクティブなので、着実に進歩し、ウェブとアプリ全体で正確に前回の場所から再開できます。

このSystem Observability: Logging, Metrics & Tracing (ELK + OpenTelemetry)レッスンでコードを書いて実行できますか?

はい。すべてのSystem Observability: Logging, Metrics & Tracing (ELK + OpenTelemetry)レッスンに組み込みコードエディタが含まれているため、ブラウザでリアルコードを書いて実行し、即座のAIフィードバックを取得できます。ローカル設定は不要です。

このコースのすべてのレッスン

  1. メトリクスの種類
  2. メトリクス収集の戦略
  3. メトリクスの可視化とアラート
  4. メトリクスのカーディナリティとラベル付けのベストプラクティス
← System Observability: Logging, Metrics & Tracing (ELK + OpenTelemetry)に戻る