• /
  • EnglishEspañolFrançais日本語한국어Português
  • ログイン今すぐ開始

この機械翻訳は、参考として提供されています。

英語版と翻訳版に矛盾がある場合は、英語版が優先されます。詳細については、このページを参照してください。

問題を作成する

サンプリングプロセッサ

サンプリング プロセッサは確率的サンプリングを実装し、信号を保持しながらデータ量を削減します。これを使用すると、すべてのエラーと遅いrequestsを維持しながら、日常的な成功ケースを積極的にサンプリングし、診断価値を失うことなくコストを削減できます。

サンプリングプロセッサを使用する場合

サンプリング プロセッサは、テレメトリー データのタイプに応じてさまざまな機能をサポートします。

ログとイベントについて

ログとイベントは、重大度、属性、その他の基準に基づいたカスタマイズ可能なルールによる条件付きサンプリングをサポートしています。

  • 成功例をサンプリングしながらエラーを100%維持: すべての診断データを保存し、通常のトラフィックをドロップします
  • 大量サービスをより積極的にサンプリングする:サービスまたは重要度に応じて異なるサンプリング率
  • 速いリクエストをサンプリングしながら遅いrequestsを保持する: 分析のためにパフォーマンスの予想値を保持する
  • 環境またはサービスごとに異なるサンプリング レートを適用します。本番環境では 10%、ステージング環境では 50%、テスト環境では 100% です。

トレース用

トレースは、グローバルなレートベースのサンプリングのみをサポートします。均一なサンプリングレートで、全体のトレース量を削減する。

メトリクス用

メトリクスのサンプリングは、現在サンプリングプロセッサではサポートされていません。代わりにフィルタ プロセッサを使用して、不要なメトリクスを削除します。

サンプリングの仕組み

サンプリング プロセッサは、条件付きルールを使用して確率的サンプリングを使用します。

  1. デフォルトのサンプリング割合: 条件付きルールに一致しないすべてのデータに適用されるデフォルトのレート。
  2. ルール: 特定の条件に一致した場合、デフォルトのレートをオーバーライドします。
  3. ランダム性のソース: 一貫性のあるフィールド(trace_idなど)により、関連するデータが一緒にサンプリングされます。

評価順序: ルールは定義された順序で評価されます。最初に一致したルールがサンプリングレートを決定します。どのルールにも一致しない場合、デフォルトのサンプリング割合が適用されます。

構成

パイプラインにサンプリング プロセッサを追加します。

probabilistic_sampler/Logs:
description: Probabilistic sampling for all logs
config:
default_sampling_percentage: 100
rules:
- name: sample the log records for ruby test service
description: sample the log records for ruby test service with 70%
sampling_percentage: 70
source_of_randomness: trace.id
conditions:
- resource.attributes["service.name"] == "ruby-test-service"

設定フィールド:

  • default_sampling_percentage: ルールに一致しないデータのデフォルトのサンプリングレート(0~100)。

  • rules: ルールの配列(順番に評価されます) — ログとイベントでのみサポートされています

    • name: ルール識別子。
    • description: 人間が読める形式の説明。
    • sampling_percentage: 一致したデータのサンプリングレート(0~100)。
    • source_of_randomness: サンプリング決定に使用するフィールド(通常はtrace_id)。
    • conditions: テレメトリーに一致するOTTL式のリスト。

サンプリング戦略

貴重なデータを維持し、日常的なトラフィックを削減

ログとイベントの最も一般的なパターン: すべての診断データ (エラー、遅いrequests) を保存し、ルーチンの成功ケースを積極的にサンプリングします。

probabilistic_sampler/Logs:
description: "Intelligent log sampling"
config:
default_sampling_percentage: 5 # Sample 5% of everything else
rules:
- name: "preserve-errors"
description: "Keep all errors and fatals"
sampling_percentage: 100
source_of_randomness: "trace.id"
conditions:
- 'severity_text == "ERROR" or severity_text == "FATAL"'
- name: "preserve-warnings"
description: "Keep most warnings"
sampling_percentage: 50
source_of_randomness: "trace.id"
conditions:
- 'severity_text == "WARN"'

結果: エラー 100% + 警告 50% + その他 5%

サービス別サンプル ティア

サービスの重要度に応じて異なるサンプリング レート:

probabilistic_sampler/Logs:
description: "Service tier sampling"
config:
default_sampling_percentage: 10
rules:
- name: "critical-services"
description: "Keep most traces from critical services"
sampling_percentage: 80
source_of_randomness: "trace.id"
conditions:
- 'resource.attributes["service.name"] == "checkout" or resource.attributes["service.name"] == "payment"'
- name: "standard-services"
description: "Medium sampling for standard services"
sampling_percentage: 30
source_of_randomness: "trace.id"
conditions:
- 'resource.attributes["service.tier"] == "standard"'

環境別サンプル

テスト環境ではサンプリングを多く、本番環境ではサンプリングを少なくする:

probabilistic_sampler/Logs:
description: "Environment-based sampling"
config:
default_sampling_percentage: 10 # Production default
rules:
- name: "test-environment"
description: "Keep all test data"
sampling_percentage: 100
source_of_randomness: "trace.id"
conditions:
- 'resource.attributes["environment"] == "test"'
- name: "staging-environment"
description: "Keep half of staging data"
sampling_percentage: 50
source_of_randomness: "trace.id"
conditions:
- 'resource.attributes["environment"] == "staging"'

遅いrequestsを保存する

分析のためにパフォーマンスの外れ値を保持します。

probabilistic_sampler/Logs:
description: "Preserve important logs"
config:
default_sampling_percentage: 1 # Sample 1% of routine logs
rules:
- name: "critical-logs"
description: "Keep all error and fatal logs"
sampling_percentage: 100
source_of_randomness: "trace.id"
conditions:
- 'severity_text == "ERROR" or severity_text == "FATAL"'
- name: "warning-logs"
description: "Keep half of warning logs"
sampling_percentage: 50
source_of_randomness: "trace.id"
conditions:
- 'severity_text == "WARN"'
- name: "traced-logs"
description: "Keep logs with trace context"
sampling_percentage: 50
source_of_randomness: "trace.id"
conditions:
- 'trace_id != nil and trace_id.string != "00000000000000000000000000000000"'

: 期間はナノ秒単位です (1 秒 = 1,000,000,000 ns)。

完全な例

例 1: ディストリビューティッド(分散)トレーシング用のインテリジェントトレースサンプリング

トレースについては、デフォルトのサンプリング割合のみを設定できます。この割合は、エラートレースやスロートレースを含め、すべてのトレースに均等に適用されます:

probabilistic_sampler/Traces:
description: Probabilistic sampling for traces
config:
default_sampling_percentage: 55

例2: ログボリュームの削減

診断データを保持しながらログの量を大幅に削減します。

probabilistic_sampler/Logs:
description: "Aggressive log sampling, preserve errors"
config:
default_sampling_percentage: 2 # Keep 2% of routine logs
rules:
- name: "keep-errors-fatals"
description: "Keep all errors and fatals"
sampling_percentage: 100
source_of_randomness: "trace.id"
conditions:
- 'severity_number >= 17' # ERROR and above
- name: "keep-some-warnings"
description: "Keep 25% of warnings"
sampling_percentage: 25
source_of_randomness: "trace.id"
conditions:
- 'severity_number >= 13 and severity_number < 17' # WARN

例3: HTTPステータスコードによるサンプル

すべての失敗 (100%) をサンプリングし、成功の一部 (5%) をサンプリングします。

probabilistic_sampler/Logs:
description: "Sample by HTTP response status"
config:
default_sampling_percentage: 5 # 5% of successes
rules:
- name: "keep-server-errors"
description: "Keep all 5xx errors"
sampling_percentage: 100
source_of_randomness: "trace.id"
conditions:
- 'attributes["http.status_code"] >= 500'
- name: "keep-client-errors"
description: "Keep all 4xx errors"
sampling_percentage: 100
source_of_randomness: "trace.id"
conditions:
- 'attributes["http.status_code"] >= 400 and attributes["http.status_code"] < 500'

例 4: マルチティア サービスのサンプリング

重要度レベルに応じて異なるレート:

probabilistic_sampler/Logs:
description: "Business criticality sampling"
config:
default_sampling_percentage: 1
rules:
# Critical business services: keep 80%
- name: "critical-services"
description: "High sampling for critical services"
sampling_percentage: 80
source_of_randomness: "trace.id"
conditions:
- 'attributes["business_criticality"] == "critical"'
# Important services: keep 40%
- name: "important-services"
description: "Medium sampling for important services"
sampling_percentage: 40
source_of_randomness: "trace.id"
conditions:
- 'attributes["business_criticality"] == "important"'
# Standard services: keep 10%
- name: "standard-services"
description: "Low sampling for standard services"
sampling_percentage: 10
source_of_randomness: "trace.id"
conditions:
- 'attributes["business_criticality"] == "standard"'

例5: 時間ベースのサンプリング(オフピーク削減)

営業時間中のサンプリング頻度の増加(外部属性のタグ付けが必要):

probabilistic_sampler/Logs:
description: "Time-based sampling (requires time attribute)"
config:
default_sampling_percentage: 5 # Off-peak default
rules:
- name: "business-hours"
description: "Higher sampling during business hours"
sampling_percentage: 50
source_of_randomness: "trace.id"
conditions:
- 'attributes["is_business_hours"] == true'

例6: エンドポイントパターンによるサンプル

すべての管理エンドポイントを維持し、パブリック API を積極的にサンプリングします。

probabilistic_sampler/Logs:
description: "Endpoint-based sampling"
config:
default_sampling_percentage: 10
rules:
- name: "admin-endpoints"
description: "Keep all admin traffic"
sampling_percentage: 100
source_of_randomness: "trace.id"
conditions:
- 'IsMatch(attributes["http.path"], "^/admin/.*")'
- name: "api-endpoints"
description: "Sample public API"
sampling_percentage: 5
source_of_randomness: "trace.id"
conditions:
- 'IsMatch(attributes["http.path"], "^/api/.*")'

ランダム性の源

source_of_randomnessフィールドは、一貫したサンプリングの決定を行うために使用する属性を決定します。

共通の値:

  • trace_id: ディストリビューティッド(分散)トレースの場合(トレース内のすべてのスパンが一緒にサンプリングされるようにします)
  • span_id:個別スパンサンプリング用(ディストリビューティッド(分散)トレーシングには非推奨)
  • カスタムアトリビュート: ランダム性を提供する任意のプロパティ

重要性: trace_id使用すると、トレースをサンプリングするときに、ランダムな個々のスパンだけではなく、そのトレースのすべてのスパンが取得されるようになります。これは分散トランザクションを理解する上で重要です。

パフォーマンスに関する考慮事項

  • 頻度順にルールを並べる: 最も頻繁に一致する条件を先頭にして評価時間を短縮します
  • ランダム性パフォーマンスのソース: trace_idはすでに利用可能であるため、使用するのは非常に効率的です
  • サンプリングは他のプロセッサの後に行われます。サンプリングをパイプラインの最後近くに配置して、破棄されるデータにCPUを浪費しないようにします。

効率的なパイプライン順序付け:

steps:
# ... receive steps...
probabilistic_sampler/Logs:
description: Probabilistic sampling for all logs
output:
- filter/Logs
config:
rules:
- name: sample the log records for ruby test service
description: sample the log records for ruby test service with 70%
sampling_percentage: 70
source_of_randomness: trace.id
conditions:
- resource.attributes["service.name"] == "ruby-test-service"
default_sampling_percentage: 100
probabilistic_sampler/Traces:
description: Probabilistic sampling for traces
output:
- filter/Traces
config:
default_sampling_percentage: 100
filter/Logs:
description: Apply drop rules and data processing for logs
output:
- transform/Logs
config:
error_mode: ignore
rules:
- name: drop the log records
description: drop all records which has severity text INFO
conditions:
- log.severity_text == "INFO"
context: log
# ... filter steps ...
# ... transdormer steps ...

コスト影響の例

例: 1TB/日 → 100GB/日

サンプリング前

  • 1日あたり1TBのログ
  • 90%はINFOレベルの日常業務です
  • 8%は警告
  • 2%はエラー/致命的

インテリジェントサンプリング機能

probabilistic_sampler/Logs:
description: "Sample logs by severity level"
config:
default_sampling_percentage: 2 # Sample 2% of INFO and below
rules:
- name: "errors"
description: "Keep all error logs"
sampling_percentage: 100 # Keep 100% of errors
source_of_randomness: "trace.id"
conditions:
- 'severity_number >= 17'
- name: "warnings"
description: "Keep quarter of warning logs"
sampling_percentage: 25 # Keep 25% of warnings
source_of_randomness: "trace.id"
conditions:
- 'severity_number >= 13 and severity_number < 17'

サンプリング後

  • 情報: 900GB × 2% = 18GB
  • 警告: 80GB × 25% = 20GB
  • エラー/致命的: 20GB × 100% = 20GB
  • 合計: 約58GB/日 (94%削減)
  • トラブルシューティングのためにすべてのエラーが保存されます

OpenTelemetryリソース

次のステップ

Copyright © 2026 New Relic株式会社。

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.