sudo cscli collections install crowdsecurity/traefikInstalls 2 parsers and 47 scenarios.
View Traefik →sudo cscli parsers install crowdsecurity/traefik-logsThen reload CrowdSec: sudo systemctl reload crowdsec
Sign in to see which of your engines run it →Hover a line or a note to see what each field does.
# co-authored with gmelodie (https://github.com/gmelodie)name: crowdsecurity/traefik-logsdescription: "Parse Traefik access logs"filter: "evt.Parsed.program startsWith 'traefik'"#debug: trueonsuccess: next_stagepattern_syntax:TRAEFIK_ROUTER: '(%{USER}@%{URIHOST}|\-)'TRAEFIK_SERVER_URL: '(%{URI}|\-)'NUMBER_MINUS: '[0-9-]+'NGCUSTOMUSER: '[a-zA-Z0-9\.\@\-\+_%]+'## Traefik >= 3.6.18 and 3.7.2 write " as \" (not \), older ones write it raw. Lazy DATA with the anchored tail below parses bothNGINXACCESS2: '%{IPORHOST:remote_addr} - %{NGCUSTOMUSER:remote_user} \[%{HTTPDATE:time_local}\] "%{WORD:verb} %{DATA:request} HTTP/%{NUMBER:http_version}" %{NUMBER_MINUS:status} %{NUMBER_MINUS:body_bytes_sent} "%{DATA:http_referer}" "%{DATA:http_user_agent}"'nodes:## CLF parser - extract fields and store full router chain in traefik_router_name (backwards compatible)- grok:pattern: '%{NGINXACCESS2} %{NUMBER:number_of_requests_received_since_traefik_started} "%{NOTDQUOTE:traefik_router_name}" "%{TRAEFIK_SERVER_URL:traefik_server_url}" %{NUMBER:request_duration_in_ms}ms$'apply_on: messagestatics:## Undo the \" escaping so the values match the JSON format- parsed: http_refererexpression: replace(evt.Parsed.http_referer, `\"`, `"`)- parsed: http_user_agentexpression: replace(evt.Parsed.http_user_agent, `\"`, `"`)nodes:## Parse root, intermediate (if any), and leaf routers from full router chain- grok:pattern: '^%{TRAEFIK_ROUTER:traefik_router_name_root}(?: -> (?:%{DATA:traefik_router_intermediate} -> )?%{TRAEFIK_ROUTER:traefik_router_leaf})?$'expression: evt.Parsed.traefik_router_name## JSON parser - extract fields and store full router chain in traefik_router_name (backwards compatible)# We must use evt.Parsed.message to make sure we respect s00 stage- filter: TrimSpace(evt.Parsed.message) startsWith "{" && UnmarshalJSON(evt.Parsed.message, evt.Unmarshaled, "traefik") in ["", nil]nodes:## Parse root, intermediate (if any), and leaf routers from full router chain- grok:pattern: '^%{TRAEFIK_ROUTER:traefik_router_name_root}?(?: -> (?:%{DATA:traefik_router_intermediate} -> )?%{TRAEFIK_ROUTER:traefik_router_leaf})?$'expression: "evt.Unmarshaled.traefik.RouterName ?? ''"statics:- parsed: remote_addr## Split by comma and take last IP to handle proxied requests (e.g., ZScaler)
Sign in to see the Security Engines that run this log parser, the version they run and whether it was modified locally.
Co-authored with (https://github.com/gmelodie)
This traefik parser supports access logs in the Common Log Format (defined here for Traefik) and JSON formats.