Docs » Splunk Distribution of the OpenTelemetry Collector の利用開始 » Collector コンポーネント » Collectorコンポーネント: プロセッサー » フィルターープロセッサー

フィルターープロセッサー 🔗

フィルターープロセッサーは OpenTelemetry Collector コンポーネントで、コンフィギュレーションで定義した条件に基づいてスパン、メトリクス、またはログをフィルターーします。フィルターープロセッサーの典型的なユースケースは、データのノイズを減らすために、クリティカルでないログやスパンのような、観測されたシステムに関連しないテレメトリをドロップすることです。

フィルターリングは、正規表現とリソース属性に基づいてテレメトリを含めたり除外したりする許可リストと拒否リストを通して機能します。OpenTelemetry Transformation Language (OTTL) を使用して、フィルターリングしたいシグナルをより適切に記述することもできます。プロセッサーはすべてのパイプラインタイプをサポートします。詳細は パイプラインでデータを処理する を参照してください。

フィルターープロセッサーは、以下の基準に基づいてテレメトリを含むことも除外することもできます:

シグナル

基準とマッチタイプ

スパン

OTTL条件、スパン名( strict または regexp )、リソース属性( strict または regexp )。スパン・イベント・フィルターリングは、OTTL条件のみをサポートしています。

メトリクス

OTTL条件、メトリクス名( strict または regexp )、およびメトリクス属性( expr )。データポイント・フィルターリングはOTTL条件のみをサポートしています。

ログ

OTTL条件、リソース属性( strict または regexp )。

フィルターープロセッサーが使用する正規表現エンジンは re2 です。

注釈

スパン、ログ、またはメトリクスの属性を削除せずに再編集または変換するには、属性プロセッサーを使用します。属性プロセッサー を参照してください。

はじめに 🔗

デフォルトでは、OpenTelemetry Collector の Splunk ディストリビューションにはフィルターープロセッサーが含まれています。パイプラインのフィルターープロセッサーを有効にするには、設定の processors セクションに filter を追加します。例:

processors:
  filter/includemetrics:
    metrics:
        # Drop nonmatching metrics from the pipeline
        include:
          match_type: strict
          metric_names:
            - good_metric
            - great_metric
  filter/excludemetrics:
    metrics:
      # Drop matching metrics from the pipeline
      exclude:
        match_type: strict
        metric_names:
          - a_metric
          - another_metric
          - a_third_metric
  filter/mixedlogs:
    logs:
       # Include filters are applied before exclude filters
       include:
         match_type: strict
         record_attributes:
           - key: host.name
             value: "(host1|anotherhost2)"
       exclude:
         match_type: strict
         record_attributes:
           - key: host.name
             value: wrong_host_.*

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

:emphasize-lines: 6, 14, 15, 23

service:
  pipelines:
    traces:
      receivers: [jaeger, otlp, zipkin]
      processors:
      - filter/traces
      - memory_limiter
      - batch
      - resourcedetection
      exporters: [sapm, signalfx]
    metrics:
      receivers: [hostmetrics, otlp, signalfx]
      processors:
      - filter/includemetrics
      - filter/excludemetrics
      - memory_limiter
      - batch
      - resourcedetection
      exporters: [signalfx]
    logs:
      receivers: [fluentforward, otlp]
      processors:
      - filter/mixedlogs
      - memory_limiter
      - batch
      - resourcedetection
      exporters: [splunk_hec]

パラメータの完全なリストについては、設定 を参照してください。

サンプル構成 🔗

以下のサンプル構成は、さまざまな基準を使用してスパン、メトリクス、およびログをフィルターする方法を示しています。

注釈

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

スパンをフィルターーする 🔗

リソース属性またはOTTL条件を使用して、スパンをトレースから除外または含めることができます。例:

filter/spans:
  spans:
    include:
      match_type: strict
      services:
        - ponygame
        - ponytest
      attributes:
        - key: an_attribute
          value: "(valid_value|another_value)"
    exclude:
      match_type: regexp
      attributes:
        - key: bad_attributes
          value: "(invalid_value|another_value)"

filter/ottl:
  traces:
    span:
      - 'attributes["test"] == "value"'
      - 'attributes["test"] == "value2"'

注釈

インクルードフィルターーは、どのフィルターープロセッサーのインスタンスでも、常に除外フィルターーの前に適用されます。

フィルター・メトリクス 🔗

メトリクス名、式、または OTTL 条件を使用して、メトリクスを除外または含めることができます。例:

filter/mixed:
  metrics:
    # Include using metric names
    include:
      match_type: strict
      metric_names:
        - a_metric
        - another_metric
    # Exclude using regular expressions
    exclude:
      match_type: regexp
      metric_names:
        - prefix/.*
        - prefix_.*
        - .*/suffix
        - .*_suffix
        - .*/contains/.*
        - .*_contains_.*
        - full/name/match
        - full_name_match

filter/expr:
  metrics:
    include:
      match_type: expr
      expressions:
        - Label("label1") == "text"
        - HasLabel("label2")

filter/ottl:
  metrics:
    metric:
      - 'name == "a_name"'
   datapoint:
      - 'attributes["attributename"] == "value"'

フィルターーログ 🔗

リソース属性または OTTL 条件を使用して、ログを除外または含めることができます。例:

filter/mixed:
  logs:
    include:
      match_type: strict
      resource_attributes:
        - key: should_include
          value: "true"
    exclude:
      match_type: regexp
      resource_attributes:
        - key: host.name
          value: banned_host_.*

filter/severity:
  logs:
    exclude:
      match_type: strict
      severity_texts:
        - "DEBUG"
        - "DEBUG2"
        - "DEBUG3"
        - "DEBUG4"
    include:
      match_type: regexp
      severity_texts:
        - "INFO[2-4]?"

filter/recordattributes:
  logs:
    exclude:
      match_type: strict
      record_attributes:
        - key: should_exclude
          value: "true"

filter/includeexclude:
  logs:
    include:
      severity_number:
        min: "INFO"
        match_undefined: true
   exclude:
      severity_number:
        min: "ERROR"

filter/ottl:
  logs:
    log_record:
      - 'attributes["test"] == "pass"'

Kubernetesエレメントのフィルターリング 🔗

コンテナ、ポッド、ノード、名前空間、クラスターなどのKubernetes要素を除外または含めるには、次のように設定します:

agent:
  config:
    processors:
      # Exclude specific metrics from containers named 'containerXName' or 'containerYName'
      filter/exclude_metrics_from_container:
        metrics:
          exclude:
            match_type: regexp
            resource_attributes:
              - key: k8s.container.name
                value: '^(containerXName|containerYName)$'

      # Exclude logs from pods named 'podNameX'
      filter/exclude_logs_from_pod:
        logs:
          exclude:
            match_type: regexp
            resource_attributes:
              - key: k8s.pod.name
                value: '^(podNameX)$'

      # Exclude logs from nodes named 'nodeNameX'
      filter/exclude_logs_from_node:
        logs:
          exclude:
            match_type: regexp
            resource_attributes:
              - key: k8s.node.name
                value: '^(nodeNameX)$'

      # Exclude spans from traces for services housed in containers named 'containerXName' or 'containerYName'
      filter/exclude_spans_from_traces_from_container:
        spans:
          exclude:
            match_type: regexp
            attributes:
              - key: k8s.container.name
                value: '^(containerXName|containerYName)$'

      # Exclude all telemetry data (metrics, logs, traces) from a namespace named 'namespaceX'
      filter/exclude_all_telemetry_data_from_namespace:
        logs:
          exclude:
            match_type: regexp
            resource_attributes:
              - key: k8s.namespace.name
                value: '^(namespaceX)$'
        metrics:
          exclude:
            match_type: regexp
            resource_attributes:
              - key: k8s.namespace.name
                value: '^(namespaceX)$'
        traces:
          span:
            - 'attributes["k8s.namespace.name"] != "namespaceX"'

      # Exclude metrics from a cluster named 'clusterX'
      filter/exclude_metrics_from_cluster:
        metrics:
          exclude:
            match_type: regexp
            resource_attributes:
              - key: k8s.cluster.name
                value: '^(clusterX)$'

プロセッサーを設定したら、パイプラインを設定します:

# Define the data processing pipelines for logs, metrics, and traces
service:
  pipelines:
    logs:
      processors:
        - memory_limiter
        - k8sattributes
        - filter/logs
        - batch
        - resourcedetection
        - resource
        - resource/logs
        - filter/exclude_logs_from_pod
        - filter/exclude_logs_from_node

OTTL条件を使用してテレメトリをドロップする 🔗

OpenTelemetry Transformation Language (OTTL) を使って、より詳細なフィルターリング条件を定義することができます。一致するテレメトリはドロップ(除外)されます。

OTTL では、各テレメトリタイプまたはコンテキストに独自のフィールドがあります。次の例は、使用可能なすべての OTTL コンテキストを示しています:

processors:
  filter:
     traces:
       span:
         - 'attributes["attribute.label"] == "attribute_value"'
         - 'resource.attributes["host.name"] == "localhost"'
       # Checked only if `span` is not dropped
       spanevent:
         - 'attributes["label"] == true'
         - 'IsMatch(name, ".*http.*") == false'
        # If all span events are dropped, the span is dropped
       metrics:
         metric:
           - 'name == "metric.name" and attributes["label"] == "value"'
           - 'type == METRIC_DATA_TYPE_HISTOGRAM'
         # Checked only if `metric` is not dropped
         datapoint:
           - 'metric.type == METRIC_DATA_TYPE_SUMMARY'
           - 'resource.attributes["service.name"] == "my_service_name"'
          # If all datapoints are dropped, the metric is dropped
       logs:
         log_record:
           - 'IsMatch(body, ".*token.*") == true'
           - 'severity_number < SEVERITY_NUMBER_WARN'

OTTLの関数と構文の詳細については、こちらを参照してください:

設定 🔗

次の表は、フィルターープロセッサーのコンフィギュレーション・オプションを示しています:

トラブルシューティング 🔗

Splunk Observability Cloudをご利用のお客様で、Splunk Observability Cloudでデータを確認できない場合は、以下の方法でサポートを受けることができます。

Splunk Observability Cloudをご利用のお客様

見込み客および無料トライアルユーザー様

  • Splunk Answers のコミュニティサポートで質問し、回答を得る

  • Splunk #observability ユーザーグループの Slack チャンネルに参加して、世界中の顧客、パートナー、Splunk 社員とのコミュニケーションを図る。参加するには、Get Started with Splunk Community マニュアルの チャットグループ を参照してください。

This page was last updated on 2024年05月29日.