パート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 を設定するには、次の手順を実行します。
-
ログ収集ディレクトリにotel-collector-config.ymlというファイルを作成します。
-
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 ] -
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 -
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 -
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 サービスに送信するデータを格納します。インデックスを設定するには、以下の手順に従います。
-
ログ収集ディレクトリにsplunk.ymlというファイルを作成します。
-
splunk.ymlファイルで、
index1とindex2インデックスを定義します: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」を参照してください。
さらに詳しく
-
Collector の詳細については、『Splunk Distribution of the OpenTelemetry Collector の利用開始』を参照してください。
-
このCollector設定で使用されているコンポーネントの詳細については、次のドキュメントを参照してください。
-
HEC エクスポータを使用する方法の詳細な例については、GitHub で https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/exporter/splunkhecexporter を参照してください。
-
Splunk Enterprise インデックスの設定については、Splunk Enterprise 管理者マニュアルの「indexes.conf」を参照してください。