This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
|
сервис_opentelemetry [2026/10/09 16:42] val [OpenTelemetry Collector] |
сервис_opentelemetry [2026/11/05 15:10] (current) val [OpenTelemetry Collector] |
||
|---|---|---|---|
| Line 8: | Line 8: | ||
| # dpkg -i otelcol-contrib_0.162.0_linux_amd64.deb | # dpkg -i otelcol-contrib_0.162.0_linux_amd64.deb | ||
| - | </code> | + | </code><code> |
| - | + | ||
| - | * [[Регистрация событий в Linux#Сервис rsyslog]] | + | |
| - | * [[Поиск важных событий в syslog]] (Вариант 1) | + | |
| - | + | ||
| - | <code> | + | |
| - | # usermod -aG adm otelcol-contrib | + | |
| # cat /etc/otelcol-contrib/config.yaml | # cat /etc/otelcol-contrib/config.yaml | ||
| </code><code> | </code><code> | ||
| receivers: | receivers: | ||
| - | filelog/system: | + | journald: |
| - | include: | + | convert_to_semantic_conventions: true |
| - | - /var/log/*.log | + | |
| - | start_at: end | + | |
| resource: | resource: | ||
| - | service.name: system-logs | + | service.name: ИМЯ_СИСТЕМЫ-journald |
| + | #Можно и просто journald , так как ниже добавляется и индексируется host_name | ||
| - | filelog/roundcube: | + | # filelog/roundcube: |
| - | include: | + | # include: |
| - | - /var/log/roundcube/*.log | + | # - /var/log/roundcube/*.log |
| - | start_at: end | + | # start_at: end |
| - | resource: | + | # resource: |
| - | service.name: roundcube-mail | + | # service.name: server-roundcube |
| + | # operators: | ||
| + | # - type: regex_parser | ||
| + | # regex: '^\[(?P<log_time>\d{2}-[A-Za-z]{3}-\d{4} \d{2}:\d{2}:\d{2} [+-]\d{4})\]:\s*(?P<message>.*)$' | ||
| + | # - 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: | processors: | ||
| batch: | batch: | ||
| - | filter/exclude_unimportant: | + | # filter/exclude_unimportant: |
| + | # error_mode: ignore | ||
| + | # logs: | ||
| + | # log_record: | ||
| + | # - 'IsMatch(body, "(?i)cron")' | ||
| + | transform: | ||
| error_mode: ignore | error_mode: ignore | ||
| - | logs: | + | log_statements: |
| - | log_record: | + | - context: log |
| - | - 'IsMatch(body, "(?i)cron")' | + | 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: | exporters: | ||
| otlphttp/loki: | otlphttp/loki: | ||
| - | endpoint: "http://192.168.13.10:3100/otlp" | + | endpoint: "http://server:3100/otlp" |
| tls: | tls: | ||
| insecure: true | insecure: true | ||
| + | |||
| + | # debug: | ||
| + | # verbosity: detailed | ||
| service: | service: | ||
| pipelines: | pipelines: | ||
| logs: | logs: | ||
| - | receivers: [filelog/system, filelog/roundcube] | + | receivers: [journald] |
| - | processors: [filter/exclude_unimportant, batch] | + | # receivers: [journald, filelog/roundcube] |
| + | processors: [transform, batch] | ||
| + | # processors: [filter/exclude_unimportant, transform, batch] | ||
| exporters: [otlphttp/loki] | exporters: [otlphttp/loki] | ||
| + | # exporters: [otlphttp/loki, debug] | ||
| </code><code> | </code><code> | ||
| # otelcol-contrib validate --config /etc/otelcol-contrib/config.yaml | # 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 | ||
| </code> | </code> | ||