victorialogs datasource passes the trailing newline of a message to the parsers (traefik-logs 1.6 fails on every line)

Abierto Apto para principiantes
#4,820 1 comentario 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 4 días

@IlayWolfson ya está trabajando en esto.

Desde el 17/11/2026.

  • #4831 de @IlayWolfson — abierto

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
70/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
docker, go
Área
data

Línea de trabajo

El error está en el datasource de victorialogs: ll.Raw = entry.Message en pkg/acquisition/modules/victorialogs/run.go:51 pasa un salto de línea final a los parsers. Compáralo con el datasource de syslog, que lo elimina con strings.TrimSuffix (syslog/run.go:210,243), y comprueba si loki (loki/run.go:61) necesita el mismo cambio. Está terminado cuando un mensaje que termina en \n o \r\n llega a los parsers sin el terminador, con un test que lo cubra.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

kind/bug needs/triage os/linux version/1.8.2
What happened?

Since the hub update of crowdsecurity/traefik-logs from 1.5 to 1.6 (crowdsecurity/hub#1978), not a single traefik access log
line read through the victorialogs datasource is parsed anymore (cscli metrics show parsers: 50.54k hits, 0 parsed).

The messages stored in VictoriaLogs end with \n (containers run by podman with the journald log driver keep the newline of each
stdout line in MESSAGE). The victorialogs datasource hands _msg to the parsers unchanged
(pkg/acquisition/modules/victorialogs/run.go:51, ll.Raw = entry.Message); the bytes.Trim(b, "\n") in
internal/vlclient/vl_client.go only applies to the JSON line of the response. traefik-logs 1.6 anchors its CLF pattern at the
end (... %{NUMBER:request_duration_in_ms}ms$), and Go's $ without the m flag does not match before a final newline, so every
line is rejected.

The other line based datasources remove the newline before the parsers see the line (v1.8.2):

datasource newline removed?
file yes, bufio.Scanner / tail lines (file/run.go)
journalctl yes, bufio.Scanner (journalctl/run.go:73)
docker yes, bufio.Scanner (docker/run.go)
syslog yes, strings.TrimSuffix(..., "\n") (syslog/run.go:210,243)
victorialogs no, ll.Raw = entry.Message (victorialogs/run.go:51)
loki no, ll.Raw = entry.Line (loki/run.go:61)

So whether a parser matches depends on the datasource the line came through. cscli explain --log and the hub tests read from a
file and never see the newline, so an anchored pattern passes there and fails for victorialogs users.

What did you expect to happen?

The victorialogs datasource delivers the message without a trailing line terminator, like file, journalctl, docker and syslog
do, so that parsers behave the same regardless of the datasource. traefik-logs 1.6 then parses these lines as 1.5 did.

How can we reproduce it (as minimally and precisely as possible)?
  1. Start VictoriaLogs and crowdsecurity/crowdsec:v1.8.2 so that crowdsec reaches VictoriaLogs on 127.0.0.1:9428 (e.g. both
    in one pod), with COLLECTIONS=crowdsecurity/traefik, then upgrade the hub to get traefik-logs 1.6
    (the image ships 1.5):

    $ cscli hub update && cscli hub upgrade
    $ cscli parsers list | grep traefik
     crowdsecurity/traefik-logs  ✔️  enabled  1.6  /etc/crowdsec/parsers/s01-parse/traefik-logs.yaml
    
  2. Ingest the same access log line twice, once with and once without a trailing newline:

    $ L='203.0.113.10 - - [12/Nov/2026:07:19:02 +0100] \"GET /status.php HTTP/1.1\" 200 170 \"-\" \"curl/8.0\" 22517 \"app@docker\" \"http://192.0.2.20:8080\" 42ms'
    $ curl -H 'Content-Type: application/stream+json' --data-binary "{\"app\":\"traefik-nl\",\"msg\":\"$L\n\"}" \
        'http://127.0.0.1:9428/insert/jsonline?_stream_fields=app&_msg_field=msg'
    $ curl -H 'Content-Type: application/stream+json' --data-binary "{\"app\":\"traefik-plain\",\"msg\":\"$L\"}" \
        'http://127.0.0.1:9428/insert/jsonline?_stream_fields=app&_msg_field=msg'
    
  3. Run both through the parsers via the victorialogs datasource:

    $ cscli explain --type traefik --dsn "victorialogs://127.0.0.1:9428/?query=app:traefik-nl&since=1h&limit=1"
    line: 203.0.113.10 - - [12/Nov/2026:07:19:02 +0100] "GET /status.php HTTP/1.1" 200 170 "-" "curl/8.0" 22517 "app@docker" "http://192.0.2.20:8080" 42ms
    
         ├ s00-raw
         |       ├ 🔴 crowdsecurity/cri-logs
         |       ├ 🔴 crowdsecurity/docker-logs
         |       ├ 🔴 crowdsecurity/syslog-logs
         |       └ 🟢 crowdsecurity/non-syslog (+5 ~7)
         ├ s01-parse
         |       ├ 🔴 crowdsecurity/sshd-logs
         |       ├ 🔴 crowdsecurity/sshd-success-logs
         |       └ 🔴 crowdsecurity/traefik-logs
         └-------- parser failure 🔴
    
    $ cscli explain --type traefik --dsn "victorialogs://127.0.0.1:9428/?query=app:traefik-plain&since=1h&limit=1"
    ...
         |       └ 🟢 crowdsecurity/traefik-logs (+27 ~2)
    

    Note the empty line after line: in the first case: that is the newline reaching the parser.

Results of the same test:

traefik-logs message result
1.6 with \n failure
1.6 without \n success
1.6 with \n + pipe success
1.5 with \n success

("pipe" = the workaround below.)

Anything else we need to know?

Suggested fix: strip a trailing \n / \r\n from the message in the victorialogs datasource, as the syslog datasource does.
The loki datasource takes the same path (entry.Line unchanged) and is probably affected as well; I have only tested victorialogs.

traefik-logs is just the first widely used parser to hit this: 15 of the 110 hub parsers with grok patterns end in $, among them
crowdsecurity/syslog-logs and crowdsecurity/http-logs.

Workaround: remove the newline in the acquisition query (works with the tail endpoint used in normal operation as well):

query: '<your query> | replace_regexp ("\n$", "") at _msg'

Analysis, reproduction and write-up done with AI assistance (Claude Code); I reviewed the report before posting.

Crowdsec version
$ cscli version
version: v1.8.2-3d369d64
Codename: alphaga
BuildDate: 2026-10-26_14:19:03
GoVersion: 1.27.1
Platform: linux
libre2: C++
User-Agent: crowdsec/v1.8.2-3d369d64-linux
Constraint_parser: >= 1.0, <= 3.0
Constraint_scenario: >= 1.0, <= 3.0
Constraint_api: v1
Constraint_acquis: >= 1.0, < 2.0
Built-in optional components: cscli_setup, datasource_appsec, datasource_cloudwatch, datasource_docker, datasource_file, datasource_http, datasource_journalctl, datasource_k8s-audit, datasource_kafka, datasource_kinesis, datasource_kubernetes, datasource_loki, datasource_s3, datasource_syslog, datasource_victorialogs, datasource_wineventlog, db_mysql, db_postgres, db_sqlite

The reproduction above used the official image crowdsecurity/crowdsec:v1.8.2.

OS version
$ cat /etc/os-release   # inside the container
NAME="Alpine Linux"
ID=alpine
VERSION_ID=3.24.3
PRETTY_NAME="Alpine Linux v3.24"
HOME_URL="https://alpinelinux.org/"
BUG_REPORT_URL="https://gitlab.alpinelinux.org/alpine/aports/-/issues"
$ uname -srmo           # host
Linux 6.18.60-1-lts x86_64 GNU/Linux
Enabled collections and parsers
$ cscli hub list -o raw   # relevant items
name,status,version,description,type
crowdsecurity/geoip-enrich,enabled,0.5,"Populate event with geoloc info : as, country, coords, source range.",parsers
crowdsecurity/http-logs,enabled,1.4,"Parse more Specifically HTTP logs, such as HTTP Code, HTTP path, HTTP args and if its a static ressource",parsers
crowdsecurity/syslog-logs,enabled,1.1,,parsers
crowdsecurity/traefik-logs,enabled,1.6,Parse Traefik access logs,parsers
crowdsecurity/whitelists,enabled,0.3,Whitelist events from private ipv4 addresses,parsers
crowdsecurity/base-http-scenarios,enabled,1.4,http common : scanners detection,collections
crowdsecurity/traefik,enabled,0.2,traefik support: parser and generic http scenarios,collections
Acquisition config
$ cat /etc/crowdsec/acquis.d/traefik.yaml
source: victorialogs
url: https://victorialogs.example.org
query: '_SYSTEMD_UNIT:traefik.service SYSLOG_IDENTIFIER:traefik _msg:~"^[0-9a-fA-F.:]+ - "'
labels:
  type: traefik
Config show

Not relevant here (the line fails in s01-parse, independent of the configuration); can be provided on request.

Prometheus metrics
$ cscli metrics show acquisition parsers   # relevant rows
+-----------------------------------------------+------------+--------------+----------------+
| Source                                        | Lines read | Lines parsed | Lines unparsed |
+-----------------------------------------------+------------+--------------+----------------+
| victorialogs:https://victorialogs.example.org | 62.97k     | 7.07k        | 55.90k         |
+-----------------------------------------------+------------+--------------+----------------+
+----------------------------------------+---------+--------+----------+
| Parsers                                | Hits    | Parsed | Unparsed |
+----------------------------------------+---------+--------+----------+
| child-child-crowdsecurity/traefik-logs | 50.54k  | -      | 50.54k   |
| child-crowdsecurity/traefik-logs       | 50.54k  | -      | 50.54k   |
| crowdsecurity/non-syslog               | 63.44k  | 63.44k | -        |
| crowdsecurity/traefik-logs             | 50.54k  | -      | 50.54k   |
+----------------------------------------+---------+--------+----------+

The 7.07k parsed lines of this source are sshd lines from a second victorialogs acquisition.

Related custom configs versions (if applicable) : notification plugins, custom scenarios, parsers etc.

One local whitelist parser in s02-enrich; not involved, the lines fail in s01-parse.

Lenguaje dominante
Go
Estrellas
15.1k
Forks
726
Merge medio
4 d 23 h
PR fusionados (30 d)
27

Preparar el entorno

Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de crowdsecurity/crowdsec

Todos los issues de crowdsecurity/crowdsec

Issues similares

Más issues de Go

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.