パート2: CollectorとSplunk Enterpriseインスタンスを設定する

Docker Compose を使用してサービスを設定したら、OpenTelemetry Collector 設定の Splunk Distribution を作成してすべての Collector コンポーネントを組み立て、Splunk Enterprise インデックス設定を作成します。チュートリアルの概要については、「Tutorial: Use the Collector to send container logs to Splunk Enterprise」を参照してください。

Collector の設定

Collector はコンテナログを収集し、Splunk Enterprise サービスに送信します。Collector を設定するには、次の手順を実行します。

  1. ログ収集ディレクトリにotel-collector-config.ymlというファイルを作成します。

  2. otel-collector-config.ymlファイルで、2つのロギングサービスからログを収集するために使用されるレシーバーを定義します:

    receivers:
      # Each filelog receiver requires a unique name that follows the slash.
      filelog/output1:
        # The include field specifies the path from which the receiver collects the container logs.
        include: [ /output1/file.log ]
      filelog/output2:
        include: [ /output2/file.log ]
  3. otel-collector-config.ymlファイルのレシーバーの後に、収集したログデータをSplunk Enterpriseで使用するために変換するプロセッサーを定義します:

    # ...
    processors:
      # The batch processor helps regulate the data flow from the receivers.
      batch:
      # The transform processor is configured to set the `com.splunk.index` attribute to `index2`
      # for the logs with a `logging2` message, and `index1` for all other logs.
      transform:
        log_statements:
          - context: log
            statements:
              - set(attributes["com.splunk.index"], "index1")
              - set(attributes["com.splunk.index"], "index2") where ParseJSON(body)["message"] == "logging2"
      # The groupbyattrs processor groups the logs by their `com.splunk.index` attribute,
      # which is either `index1` or `index2`.
      groupbyattrs:
        keys:
          - com.splunk.index
  4. otel-collector-config.yml ファイルのプロセッサの後に、ログを Splunk サーバーの HTTP Event Collector(HEC)に送信するために使用するエクスポータを定義します。

    # ...
    exporters:
      splunk_hec/logs:
        # Splunk HTTP Event Collector token.
        token: "00000000-0000-0000-0000-0000000000000"
        # Splunk instance URL where the exporter sends the log data.
        endpoint: "https://splunk:8088/services/collector"
        tls:
          # Skips checking the certificate of the HEC endpoint when sending data over HTTPS.
          insecure_skip_verify: true
  5. otel-collector-config.ymlファイルでエクスポーターを定義した後、サービスを定義します。このサービスは、3つのコンポーネントタイプを通じてロギングデータのフローを編成する logs パイプラインで構成されます:

    # ...
    service:
      pipelines:
        logs:
          receivers: [ filelog/output1, filelog/output2 ]
          processors: [ transform, groupbyattrs, batch ]
          exporters: [ splunk_hec/logs ]

Splunk Enterpriseインデックスを設定する

Splunk Enterprise インデックスは、Collector が Splunk Enterprise サービスに送信するデータを格納します。インデックスを設定するには、以下の手順に従います。

  1. ログ収集ディレクトリにsplunk.ymlというファイルを作成します。

  2. splunk.ymlファイルで、index1index2 インデックスを定義します:

    splunk:
      conf:
        indexes:
          directory: /opt/splunk/etc/apps/search/local
          content:
            index1:
              coldPath: $SPLUNK_DB/index1/colddb
              datatype: event
              homePath: $SPLUNK_DB/index1/db
              maxTotalDataSizeMB: 512000
              thawedPath: $SPLUNK_DB/index1/thaweddb
            index2:
              coldPath: $SPLUNK_DB/index2/colddb
              datatype: event
              homePath: $SPLUNK_DB/index2/db
              maxTotalDataSizeMB: 512000
              thawedPath: $SPLUNK_DB/index2/thaweddb

次のステップ

これで、Collector を使用してコンテナログを収集、処理、エクスポートするコンポーネントを定義し、ログを保存する Splunk Enterprise インデックスを定義しました。次に、Docker Compose を使用してサービスをデプロイし、すべてが想定どおりに機能することを検証します。続行するには、「Part 3: Deploy and verify the environment」を参照してください。

さらに詳しく