属性プロセッサー

属性プロセッサを使用すると、スパン、メトリクス、またはログの属性を変換、編集(マスク)、更新、ハッシュ化、または削除することができます。コンポーネントの設定方法については、続きをお読みください。

属性プロセッサは、アクションを通じてスパン、メトリック、またはログの属性を変更する OpenTelemetry Collector コンポーネントです。単一のプロセッサインスタンスでアクションを組み合わせて、複雑な操作を実行できます。ユースケースには、機密情報の難読化、新しいキーへの値のコピー、属性のバックフィルなどがあります。

スパン、メトリクス、またはログの収集された属性に対して、次のいずれかのアクションを適用できます:

アクション

説明

insert

特定の key を欠くデータに新しい属性を挿入します。このデータには valuefrom_attributefrom_context のいずれかが定義されていなければなりません。

update

valuefrom_attributefrom_context のいずれかが定義されていなければならない、特定の key を持つデータの属性を更新します。

upsert

key がすでに存在するかどうかに応じて、データ内の属性を更新または追加します。 key には、valuefrom_attribute、または from_context のいずれかが定義されている必要があります。

delete

特定の key または pattern を持つ属性をデータから削除します。

hash

特定の key または pattern を持つ既存の属性の値を、SHA1 アルゴリズムを使ってハッシュします。

extract

正規表現ルールを使用して値を抽出します。pattern が必要です。

convert

intdoublestringのいずれかである converted_type パラメータで指定されるように、属性を別のタイプに変換します。

注: メトリクス変換プロセッサを活用することでメトリクスの名称変更、ラベルキーと値の追加 / 名称変更、あるいは削除が可能です。また、ラベルまたはラベル値全体のメトリクスのスケーリングと集約を実行することもできます。スパン全体、ログ、またはメトリクスを含めたり除外したりするには、フィルタプロセッサを使用します。詳しくは「Metrics transform processor」を参照してください。「フィルタープロセッサ」を参照してください。

はじめに

Splunk Distribution of OpenTelemetry Collector には、パイプラインにデフォルトで属性プロセッサが含まれています。パイプラインの属性プロセッサを有効にするには、設定の processors セクションに attributes を追加します。例:

processors:
  attributes/example:
    actions:
      - key: db.table
        action: delete
      - key: redacted_span
        value: "new_value"
        action: upsert
      - key: copy_key
        from_attribute: key_original
        action: update
      - key: account_id
        value: 33445
        action: insert
      - key: account_password
        action: delete
      - key: account_email
        action: hash
      - key: http.status_code
        action: convert
        converted_type: int

その後、互換性のあるパイプラインに属性プロセッサを追加することができます。例:

service:
  pipelines:
    traces:
      receivers: [jaeger, otlp, zipkin]
      processors:
      - attributes/traces
      - memory_limiter
      - batch
      - resourcedetection
      exporters: [otlphttp, signalfx]
    metrics:
      receivers: [hostmetrics, otlp, signalfx]
      processors:
      - attributes/metrics
      - memory_limiter
      - batch
      - resourcedetection
      exporters: [signalfx]
    logs:
      receivers: [fluentforward, otlp]
      processors:
      - attributes/logs
      - memory_limiter
      - batch
      - resourcedetection
      exporters: [splunk_hec]

属性を包含または除外するには、以下のプロパティのいずれかを使用します:

  • services

  • resources

  • libraries

  • span_names

  • log_bodies

  • log_severity_texts

  • metric_names

  • attributes

次の例は、特定のサービスに delete アクションを適用する方法を示します:

attributes/selectiveprocessing:
  include:
    match_type: strict
    services: ["service1", "service2"]
  actions:
    - key: sensitive_field
      action: delete

パラメータの完全なリストについては、「Settings」をご確認ください。

サンプル構成

以下のサンプル設定は、属性に対して異なるアクションを実行する方法を示しています。

注: 例の完全なリストは、https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/processor/attributesprocessor/testdata/config.yaml のコンフィギュレーションスニペットを参照してください。

ログから機密情報を削除または難読化する

次の例は、トークン属性を削除し、電子メールをハッシュ化し、ログ中のパスワードを再編集する方法を示しています:

attributes/log_body_regexp:
  include:
    match_type: regexp
      log_bodies: ["AUTH.*"]
  actions:
    - key: password
      action: update
      value: "Redacted"
    - key: apitoken
      action: delete
    - key: email
      action: hash

別の属性の値に基づいて新しい属性を作成する

次の例は、スパン内の別の属性の値に基づいて新しい属性を作成する方法を示しています:

attributes/createattributes:
  actions:
  # Creates four new attributes (defined in pattern) from the
  # value of the http.url attribute
    - key: "http.url"
      pattern: ^(?P<http_protocol>.*):\\/\\/(?P<http_domain>.*)\\/(?P<http_path>.*)(\\?|\\&)(?P<http_query_params>.*)
      action: extract

属性が欠けているスパンを埋め戻す

次の例は、属性が欠けているスパンを埋め戻す方法を示しています:

attributes/complex:
  actions:
    - key: operation
      value: default
      action: insert
    - key: svc.operation
      from_attribute: operation
      action: upsert
    - key: operation
      action: delete

その他の例とシナリオ

以下のシナリオも参照してください:

設定

次の表は、属性プロセッサーの設定オプションを示します:

https://raw.githubusercontent.com/splunk/collector-config-tools/main/cfg-metadata/processor/attributes.yaml

トラブルシューティング

__ ___ ___ _ ______ _____________ _____ ________ ___ ___ ___ ____ __ ___ ____ ____ __ ______ _____________ ______ ___ ___ ___ ____ __ ___ _________ _____

_________ __ ______ _____________ _____ _________

_________ __ ___________ _________ ___ ____ _____ _____

  • ___ _ ________ ___ ___ _______ _______ _________ _______ __ ______ ________

  • ____ ___ ______ ______________ ____ _____ _____ _______ __ ___________ ____ __________ _________ ___ ______ _________ __________ __ _____ ___ ____ _______