Linux システムログを OpenTelemetry で収集する
OpenTelemetry (OTEL)コレクターを使用することで、 Linux ベースのオペレーティングシステムからログを収集し、 Instana に送信することができます。
Instana さまざまな仕組みを通じてOTELログを受信できます。 詳細については、 「 OpenTelemetry のデータ取り込みの設定」 を参照してください。
サービスへのログメッセージの相関設定方法の詳細については、 「 OpenTelemetry のサービス相関」 を参照してください。
OpenTelemetry 経由でログを取り込むための前提条件
OpenTelemetry, 経由でログを Instana に取り込むには、アドオンや追加の設定が必要になる場合があります。 詳細については、 「ライセンスおよび利用権の要件」 を参照してください。
通常のログの収集
お使いの Linux サーバーの構成に合わせて、 Linux のリリースページから、 0.110.0otelcol-contrib 以降のバージョンの実行可能バイナリファイルをダウンロードしてください。 この OTEL Collector Contrib パッケージには、ログを収集して Instana に送信するために必要な、コミュニティ主導のオープンソース機能が含まれています。 OTEL Collector を設定し、ログデータを収集して、 Instana エージェントの OTLP エンドポイントに転送するようにします。 OTEL コレクタを構成するには、以下の例を参照してください。
Instana エージェントと TLS で暗号化された通信を行う場合は、 エージェントのエンドポイントに対して TLS 暗号化を設定する手順を実行してください。
OTELコレクター filelog の受信機を設定する
以下は、OTEL コレクタの構成例です。 この設定を「otel-config.yamlファイルに保存し、以下のコマンドを使って実行する:
./otelcol-contrib --config=./otel-config.yaml
receivers:
## [REQUIRED] The filelog receiver will collect logs written to file by a process
filelog:
## [REQUIRED] Path (or regex) to the log files that must be read.
include: [ "/path/to/log/files/to/read" ]
## [OPTIONAL] Path (or regex) to the log files that must be ignored.
exclude: [ "/path/to/log/files/to/ignore" ]
## [REQUIRED] Whether to include the file path in the logs
include_file_path: true
## [OPTIONAL] Whether to include the file name in the logs
include_file_name: true
## [OPTIONAL] Preserve the leading white spaces so that the example 'recombine' operator works as expected.
preserve_leading_whitespaces: true
operators:
## [OPTIONAL] Example recombine operator config to handle multi-line log messages for stack-traces. Requires `include_file_path: true` above.
- type: recombine
combine_field: body
is_first_entry: body matches "^[^\\s]"
source_identifier: attributes["log.file.path"]
processors:
## [OPTIONAL] This is an example log severity parser that sets the **severity_text** field in the log payload, each runs in-order such that the highest matching severity is set.
## Note: If the OpenTelemetry Collector does not set log severity, then the severity is set by Instana when analyzing the log message.
transform/set_log_severity:
log_statements:
- context: log
statements:
- set(severity_text, "Info") where IsMatch(body.string, ".*INFO.*")
- set(severity_text, "Warn") where IsMatch(body.string, ".*WARN.*")
- set(severity_text, "Error") where IsMatch(body.string, ".*ERROR.*")
- set(severity_text, "Fatal") where IsMatch(body.string, ".*FATAL.*")
## Logs must be sent in batches for performance reasons.
## Note: No additional `batch` processor configuration is provided since configuration depends on the user scenario.
batch: {}
## See the page on best practices for Instana OpenTelemetry logging for more information.
exporters:
## [REQUIRED] The Instana Agent supports GRPC payloads
otlp/instanaAgent:
## The GRPC port will be 4317 (unless port-forwarding is used to change this).
## Note: Be sure to set Instana Agent's OTLP endpoint HOST:PORT combination.
endpoint: "INSTANA_AGENT_HOST:INSTANA_AGENT_GRPC_PORT"
## TLS encryption is disabled in this example.
tls:
insecure: true
service:
pipelines:
## Sample logs pipeline using the above configurations.
logs:
receivers: [filelog]
processors: [transform/set_log_severity, batch]
exporters: [otlp/instanaAgent]
| ## 詳細については、 Instana のログ記録に関するベストプラクティスのページ( OpenTelemetry )をご覧ください。 |
| バッチ: {} |
ログの syslog 収集
Instana 受信したログをホストマシンの情報と関連付けるため、 filelog レシーバーを使用して内容を /var/log/syslog ローカルに収集してください。
ログの journald 収集
filelog 機が読み取れる通常のログファイルとは異なり、 journald ログはバイナリ形式で保存されます。 Journald レシーバー は、これらのバイナリログを取り込むことができます。 ログ journald に関する詳細については、 「journalctl を使用して Systemd ログを表示および操作する方法」 を参照してください。OTELコレクター journald の受信機を設定する
journaldレシーバーを追加するには、「journaldログの場所をコンフィギュレーションで指定する。 以下の設定例を使用してください。 以下の設定例を「otel-config.yamlファイルにコピーし、以下のコマンドで実行する:
./otelcol-contrib --config=./otel-config.yaml
receivers:
# [REQUIRED] The journald logs can be located in other locations, depending on the setup (that is, `/run/log/journal` or `/run/journal`).
journald:
directory: /var/log/journal
exporters:
## [REQUIRED] The Instana Agent supports GRPC payloads
otlp/instanaAgent:
## Be sure to set the appropriate HOST:PORT combination.
## Note: The GRPC port will be 4317 (unless port-forwarding is used to change this).
endpoint: "INSTANA_AGENT_HOST:INSTANA_AGENT_GRPC_PORT"
## TLS encryption is disabled in this example.
tls:
insecure: true
processors:
## [OPTIONAL] This is an example log severity parser that sets the **severity_text** field in the log payload, each runs in-order such that the highest matching severity is set.
## Note: If the OpenTelemetry Collector does not set log severity, then the severity is set by Instana when analyzing the log message.
transform/set_log_severity:
log_statements:
- context: log
statements:
- set(severity_text, "Info") where IsMatch(body.string, ".*INFO.*")
- set(severity_text, "Warn") where IsMatch(body.string, ".*WARN.*")
- set(severity_text, "Error") where IsMatch(body.string, ".*ERROR.*")
- set(severity_text, "Fatal") where IsMatch(body.string, ".*FATAL.*")
## [REQUIRED] Logs must be sent in batches for performance reasons.
## Note: No additional `batch` processor configuration is provided since configuration depends on the user scenario.
batch: {}
## See the page on best practices for Instana OpenTelemetry logging for more information.
service:
pipelines:
## [REQUIRED] Sample logs pipeline using the above configurations.
logs:
receivers: [journald]
processors: [transform/set_log_severity, batch]
exporters: [otlp/instanaAgent]