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

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

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

問題を作成する

フィルタープロセッサ

フィルター プロセッサは、OTTL (OpenTelemetry Transformation Language) ブール式に基づいてテレメトリー レコードまたは特定のプロパティを削除します。 これを使用して、テスト データ、デバッグ ログ、ヘルス チェック、または低価値のテレメトリーをネットワークから離れる前に削除します。

フィルタープロセッサを使用する場合

次の場合にフィルター プロセッサを使用します。

  • 個人情報またはテスト環境データの削除: ネットワークから流出すべきでないデータを削除します
  • 本番環境からデバッグレベルのログを削除する: 重大度でフィルタリングしてノイズを減らす
  • ヘルスチェックrequestsをフィルタリングする: 反復的で価値の低い監視トラフィックをドロップする
  • 特定のプレフィックスまたはパターンを持つメトリクスを削除: 不要なメトリクス ストリームを削除します
  • プロパティに基づいて価値の低いテレメトリーを削除: サービス名、環境、またはカスタム タグでフィルターします。

フィルタープロセッサの仕組み

フィルタ プロセッサは、各テレメトリ レコードに対して OTTL ブール式を評価します。 条件がtrueと評価されると、レコードは削除されます。

これは、 WHERE status = 'ERROR' 「エラーを保持する」ことを意味する多くのクエリ言語とは逆です。フィルタ プロセッサでは、 status == 'ERROR' 「エラーをドロップする」ことを意味します。

構成

パイプラインにフィルター プロセッサを追加します。

filter/Logs:
description: Apply drop rules and data processing for 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"

設定フィールド:

  • rules: 順番に評価されるフィルタリングルールの配列。

    • name: ルール識別子。
    • context: 評価するデータのタイプ。サポートされる値:logspanspan_eventmetricdatapoint
    • conditions: OTTLブール式のリスト。

複数の条件: 配列に複数の式を指定すると、それらは OR ロジックで評価されます。いずれかの条件が真の場合、レコードは削除されます。

OTTLブール演算子

比較演算子

  • == - 等しい
  • != - 等しくない
  • < - 未満
  • <= - 以下
  • > - より大きい
  • >= - より大きいか等しい

論理演算子

  • and - 両方の条件が満たされている必要があります
  • or - いずれかの条件が満たされている必要があります
  • not - 条件を否定する

パターンマッチング

  • IsMatch - 正規表現パターンマッチング
rules:
- name: match-health-logs
conditions:
- 'IsMatch(body, ".*health.*") or IsMatch(attributes["http.url"], ".*\\/api\\/v1\\/health.*")'

完全な例

例1: 落下試験環境データ

テスト環境と開発環境からすべてのテレメトリを削除します。

config:
rules:
- name: drop-test-environment
description: Drop logs from test environment
conditions:
- 'resource.attributes["environment"] == "test"'
context: log
- name: drop-dev-environment
description: Drop logs from dev environment
conditions:
- 'resource.attributes["environment"] == "dev"'
context: log

例2: 本番環境でデバッグログを削除する

本番環境では意味のあるログレベルのみを保持します。

config:
rules:
- name: drop-debug-logs
description: Drop all DEBUG severity logs
conditions:
- 'severity_text == "DEBUG"'
context: log
- name: drop-low-severity-logs
description: Drop INFO and below severity logs
conditions:
- "severity_number < 9"
context: log

重大度番号参照:

  • トレース = 1-4
  • デバッグ = 5-8
  • 情報 = 9-12
  • 警告 = 13-16
  • エラー = 17-20
  • 致命的 = 21-24

例3: ヘルスチェックスパンを削除する

診断価値を追加しないヘルスチェック トラフィックを削除します。

config:
rules:
- name: drop-health-endpoint
description: Drop spans from /health endpoint
conditions:
- 'attributes["http.path"] == "/health"'
context: span
- name: drop-health-check-spans
description: Drop spans named health_check
conditions:
- 'name == "health_check"'
context: span

例4: サービス名でドロップする

特定のサービスまたはサービス パターンをフィルターします。

config:
rules:
- name: drop-legacy-api
description: Drop logs from legacy API v1 service
conditions:
- 'resource.attributes["service.name"] == "legacy-api-v1"'
context: log
- name: drop-canary-services
description: Drop logs from canary deployment services
conditions:
- 'IsMatch(resource.attributes["service.name"], ".*-canary")'
context: log

例 5: 特定のプレフィックスを持つメトリクスを削除する

不要なメトリクス ストリームを削除します。

config:
rules:
- name: drop-internal-metrics
description: Drop metrics with internal prefix
conditions:
- 'IsMatch(name, "^internal\\.")'
context: metric
- name: drop-debug-datapoints
description: Drop datapoints marked as debug type
conditions:
- 'attributes["metric.type"] == "debug"'
context: datapoint

例6: ANDを使用した条件の組み合わせ

複数の条件が満たされる場合にのみドロップします。

config:
rules:
- name: drop-debug-logs-from-test
description: Drop DEBUG logs from background-worker service in test environment
conditions:
- 'severity_text == "DEBUG"'
- 'resource.attributes["service.name"] == "background-worker"'
- 'resource.attributes["environment"] == "test"'
context: log

例7: エラーを保持し、その他はすべて削除する

ロジックを反転して、貴重なデータのみを保持します。

config:
rules:
- name: drop-non-error-logs
description: Drop everything below ERROR severity level
conditions:
- "severity_number < 17"
context: log

または NOT ロジックを使用します。

filter/Logs:
description: "Drop non-errors"
config:
error_mode: ignore
rules:
- name: drop-non-error-logs
description: Drop logs that are not ERROR or FATAL
conditions:
- 'not (severity_text == "ERROR" or severity_text == "FATAL")'
context: log

例8: ログ本文のパターンマッチング

特定のパターンを含むログをドロップします。

config:
rules:
- name: drop-health-check-logs
description: Drop logs with health check in body
conditions:
- 'IsMatch(body, ".*health check.*")'
context: log

例9: 大量で価値の低いスパンを削除する

頻繁に発生するがあまり価値のないスパンを削除します。

config:
rules:
- name: drop-fast-cache-hits
description: Drop cache hit operations faster than 1ms
conditions:
- 'attributes["db.operation"] == "get"'
- 'end_time_unix_nano - start_time_unix_nano < 1000000'
- 'attributes["cache.hit"] == true'
context: span

例10: HTTPステータスに基づいてドロップする

成功したrequestsフィルタリングし、エラーを保持します:

config:
rules:
- name: drop-successful-requests
description: Drop HTTP requests with status code less than 400
conditions:
- 'attributes["http.status_code"] < 400'
context: span

例11: ORを使用した複数条件

いずれかの条件に一致する場合はドロップします:

config:
rules:
- name: drop-test-health-debug
description: Drop logs from test environment, health checks, or debug severity
conditions:
- 'resource.attributes["environment"] == "test"'
- 'IsMatch(body, ".*health.*")'
- 'severity_text == "DEBUG"'
context: log

データのドロップと属性のドロップ

フィルター プロセッサは、レコード全体を削除したり (上記を参照)、保持されているレコードから特定の属性を削除したりできます。

レコードを保持したまま属性を削除するには、フィルター プロセッサではなく、変換プロセッサのdelete_key()関数を使用する必要があります。フィルター プロセッサはレコード全体のみを削除します。

間違ったアプローチ(これは機能しません):

filter/Logs:
config:
rules:
- name: wrong-attribute-drop
description: Identify and drop logs containing specific sensitive attributes
conditions:
- 'delete attributes["sensitive_field"]' # Filter conditions must be boolean, not actions
context: log

正しいアプローチ(代わりに変換プロセッサを使用する):

transform/Logs:
description: "Remove sensitive attribute"
config:
rules:
- name: remove-sensitive-field
description: "Redacts the 'sensitive_field' attribute from log records to ensure privacy compliance."
statements:
- 'delete_key(attributes, "sensitive_field")'
output:
- nrexporter/newrelic

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

  • 順序が重要: フィルタープロセッサをパイプラインの早い段階に配置して、高価な処理の前に不要なデータを削除します。
  • 条件を組み合わせる: 複数のフィルター プロセッサを連結するのではなく、単一の式でand / orロジックを使用します。
  • 正規表現のパフォーマンス:IsMatchは完全一致チェックよりもコストがかかります。可能な場合は==を使用してください。

効率的な順序付けの例:

steps:
# ... receive steps ...
# ... probabilistic sampler steps ...
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/Metrics:
description: Apply drop rules and data processing for metrics
output:
- transform/Metrics
config:
error_mode: ignore
rules:
- name: drop-internal-metrics
description: drop internal metric
conditions:
- IsMatch(name, "^internal\\.")
context: metric
- name: drop-debug-datapoints
description: drop-debug-datapoints
conditions:
- attributes["metric.type"] == "debug"
context: datapoint
filter/Traces:
description: Apply drop rules and data processing for traces
output:
- transform/Traces
config:
error_mode: ignore
rules:
- name: drop-health-endpoint
description: drop-health-endpoint
conditions:
- attributes["http.path"] == "/health"
context: span
- name: drop-debug-events
description: drop-debug-events
conditions:
- name == 'debug_event'
context: span_event
# ... transformer steps...

OTTLブール式リファレンス

完全な OTTL 構文と追加の演算子については、以下を参照してください。

次のステップ

Copyright © 2026 New Relic株式会社。

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