====== Сервис OpenTelemetry ====== ===== OpenTelemetry Collector ===== * [[https://grafana.com/docs/loki/latest/send-data/otel/otel-collector-getting-started/]] $ wget https://github.com/open-telemetry/opentelemetry-collector-releases/releases/download/v0.162.0/otelcol-contrib_0.162.0_linux_amd64.deb # dpkg -i otelcol-contrib_0.162.0_linux_amd64.deb # cat /etc/otelcol-contrib/config.yaml receivers: journald: convert_to_semantic_conventions: true resource: service.name: ИМЯ_СИСТЕМЫ-journald #Можно и просто journald , так как ниже добавляется и индексируется host_name # filelog/roundcube: # include: # - /var/log/roundcube/*.log # start_at: end # resource: # service.name: server-roundcube # operators: # - type: regex_parser # regex: '^\[(?P\d{2}-[A-Za-z]{3}-\d{4} \d{2}:\d{2}:\d{2} [+-]\d{4})\]:\s*(?P.*)$' # - type: time_parser # parse_from: attributes.log_time # layout: '%d-%b-%Y %H:%M:%S %z' # - type: move # from: attributes.message # to: body # - type: remove # field: attributes.log_time processors: batch: # filter/exclude_unimportant: # error_mode: ignore # logs: # log_record: # - 'IsMatch(body, "(?i)cron")' transform: error_mode: ignore log_statements: - context: log statements: - set(resource.attributes["syslog_identifier"], attributes["syslog.identifier"]) where attributes["syslog.identifier"] != nil - set(resource.attributes["host_name"], resource.attributes["host.name"]) where resource.attributes["host.name"] != nil - set(resource.attributes["loki.resource.labels"], "syslog_identifier, host_name") exporters: otlphttp/loki: endpoint: "http://server:3100/otlp" tls: insecure: true # debug: # verbosity: detailed service: pipelines: logs: receivers: [journald] # receivers: [journald, filelog/roundcube] processors: [transform, batch] # processors: [filter/exclude_unimportant, transform, batch] exporters: [otlphttp/loki] # exporters: [otlphttp/loki, debug] # otelcol-contrib validate --config /etc/otelcol-contrib/config.yaml # usermod -aG systemd-journal otelcol-contrib # #ls -l /var/log/roundcube/ # #usermod -aG adm otelcol-contrib # service otelcol-contrib restart