4. 機密データの秘匿化

4.3 Redaction Processorのテスト

2 min

redaction プロセッサは、テレメトリーデータからどの属性と値を許可または削除するかを正確に制御できます。

この演習では、Agent がエクスポートする前に、Spanデータの user.visauser.mastercard の値を秘匿化します。

Exercise

Gatewayを起動するGateway terminal ウィンドウで Gateway を起動します。

bash
../otelcol --config=gateway.yaml

redaction/redact プロセッサを有効にするAgent terminal ウィンドウで、agent.yaml を編集して前の演習で追加した # を削除します。

yaml
    traces:
      receivers:
      - otlp
      processors:
      - memory_limiter
      - attributes/update              # Update, hash, and remove attributes
      - redaction/redact               # Redact sensitive fields using regex
      - resourcedetection
      - resource/add_mode
      - batch
      exporters:
      - debug
      - file
      - otlphttp

Agentを起動するAgent terminal ウィンドウで Agent を起動します。

bash
../otelcol --config=agent.yaml

Load Generatorを起動するLoadgen terminal ウィンドウで loadgen を起動します

bash
../loadgen -count 1

デバッグ出力を確認するAgentGateway の両方で、user.visauser.mastercard の値が更新されていることを確認します。user.amex 属性の値は、blocked_values に一致する正規表現パターンが追加されていないため、秘匿化されていないことに注意してください。

text
   -> user.name: Str(George Lucas)
   -> user.phone_number: Str(UNKNOWN NUMBER)
   -> user.email: Str(62d5e03d8fd5808e77aee5ebbd90cf7627a470ae0be9ffd10e8025a4ad0e1287)
   -> payment.amount: Double(69.71)
   -> user.visa: Str(****)
   -> user.amex: Str(3782 822463 10005)
   -> user.mastercard: Str(****)
   -> redaction.masked.keys: Str(user.mastercard,user.visa)
   -> redaction.masked.count: Int(2)

Note

redaction プロセッサに summary:debug を含めると、デバッグ出力に、どの一致するキー値が秘匿化されたか、およびマスクされた値の数に関するサマリー情報が含まれます。

text
     -> redaction.masked.keys: Str(user.mastercard,user.visa)
     -> redaction.masked.count: Int(2)

ファイル出力を確認するjq を使用して、gateway-traces.outuser.visauser.mastercard が更新されていることを検証します。

bash
jq '.resourceSpans[].scopeSpans[].spans[].attributes[] | select(.key == "user.visa" or .key == "user.mastercard" or .key == "user.amex") | {key: .key, value: .value.stringValue}' ./gateway-traces.out

これらは、attributesredaction プロセッサを設定して機密データを保護する方法のほんの一例です。

Info

AgentGateway プロセスを、それぞれのターミナルで Ctrl-C を押して停止してください。