This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
|
сервис_opentelemetry [2026/11/03 10:29] val |
сервис_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 |
| - | # operators: | + | #Можно и просто journald , так как ниже добавляется и индексируется host_name |
| - | # - type: regex_parser | + | |
| - | # regex: '^(?P<log_time>\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d+[-+]\d{2}:\d{2})\s*(?P<message>.*)$' | + | |
| - | # - type: time_parser | + | |
| - | # parse_from: attributes.log_time | + | |
| - | # layout: '%Y-%m-%dT%H:%M:%S.%L%z' | + | |
| - | # - type: move | + | |
| - | # from: attributes.message | + | |
| - | # to: body | + | |
| - | # - type: remove | + | |
| - | # field: attributes.log_time | + | |
| # filelog/roundcube: | # filelog/roundcube: | ||
| Line 42: | Line 23: | ||
| # start_at: end | # start_at: end | ||
| # resource: | # resource: | ||
| - | # service.name: roundcube-mail | + | # service.name: server-roundcube |
| # operators: | # operators: | ||
| # - type: regex_parser | # - type: regex_parser | ||
| Line 57: | Line 38: | ||
| 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: | ||
| Line 75: | Line 64: | ||
| pipelines: | pipelines: | ||
| logs: | logs: | ||
| - | receivers: [filelog/system] | + | receivers: [journald] |
| - | # receivers: [filelog/system, filelog/roundcube] | + | # receivers: [journald, filelog/roundcube] |
| - | processors: [filter/exclude_unimportant, batch] | + | processors: [transform, batch] |
| + | # processors: [filter/exclude_unimportant, transform, batch] | ||
| exporters: [otlphttp/loki] | exporters: [otlphttp/loki] | ||
| # exporters: [otlphttp/loki, debug] | # exporters: [otlphttp/loki, debug] | ||
| Line 83: | Line 73: | ||
| # otelcol-contrib validate --config /etc/otelcol-contrib/config.yaml | # otelcol-contrib validate --config /etc/otelcol-contrib/config.yaml | ||
| - | # service otelcol-contrib restart | + | # usermod -aG systemd-journal otelcol-contrib |
| - | # ###journalctl -f | + | # #ls -l /var/log/roundcube/ |
| + | # #usermod -aG adm otelcol-contrib | ||
| + | |||
| + | # service otelcol-contrib restart | ||
| </code> | </code> | ||