Raccolta dei log di sistema di Linux con OpenTelemetry
È possibile raccogliere i log dai sistemi operativi basati su Linux e inviarli all'indirizzo Instana utilizzando il Collector OpenTelemetry (OTEL).
Instana può ricevere i log OTEL tramite diversi meccanismi. Per ulteriori informazioni, consultare la sezione "Configurazione dell'acquisizione dei dati di un OpenTelemetry ".
Per ulteriori informazioni su come configurare la correlazione dei messaggi di log con i servizi, consultare la pagina OpenTelemetry service correlation.
Prerequisiti per l'acquisizione dei log tramite OpenTelemetry
Per importare i log in Instana tramite OpenTelemetry, potrebbe essere necessario un componente aggiuntivo o una configurazione supplementare. Per ulteriori informazioni, consultare i requisiti relativi alle licenze e ai diritti.
Raccolta dei log normali
Scarica il file otelcol-contrib binario eseguibile nella versione 0.110.0 o successive dalla pagina delle versioni all'indirizzo Linux, in base alla configurazione del tuo server Linux. Il OTEL Collector Contrib pacchetto include funzionalità open source sviluppate dalla comunità, necessarie per raccogliere e inviare i log a Instana. Configurare OTEL Collector per raccogliere i dati di log e inoltrarli all'agente Instana sull'endpoint OTLP. Per configurare il collettore OTEL, utilizzare l'esempio seguente come riferimento.
Se desideri comunicare utilizzando metodi crittografati con il protocollo TLS con l'agente Instana, segui la procedura per configurare la crittografi TLS e per l'endpoint dell'agente.
Configurazione del ricevitore filelog del collettore OTEL
Di seguito è riportato un esempio completo di configurazione di un collettore OTEL. Salvare questa configurazione in un file " otel-config.yaml ed eseguirla con il seguente comando:
./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]
| ## Per ulteriori informazioni, consulta la pagina sulle migliori pratiche per la registrazione di Instana OpenTelemetry. |
| lotto: {} |
Raccolta syslog dei registri
Instana collega i log ricevuti alle informazioni del computer ospitante, quindi utilizza il filelog ricevitore per raccogliere localmente i /var/log/syslog contenuti.
Raccolta journald dei registri
filelog ricevitore è in grado di leggere, journald i log sono memorizzati in formato binario. Il Journald Receiver è in grado di importare questi log binari. Per ulteriori informazioni sui journald log, consultare la guida «Come utilizzare journalctl per visualizzare e gestire i log di Systemd ».Configurazione del ricevitore journald del collettore OTEL
Per aggiungere il ricevitore 'journald, fornire la posizione dei registri 'journald nella configurazione. Utilizzare il seguente esempio di configurazione. Copiare il seguente esempio di configurazione nel file 'otel-config.yaml ed eseguirlo con il seguente comando:
./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]