skip to Main Content

Nginx – How to match optional group in regular expression

I want a regular expression for using in fluentd for parsing nginx error logs. The sample row is: 2024/04/15 09:06:29 [error] 3443790#3443790: *176070165 limiting requests, excess: 2.957 by zone "RequestLimitForCommonApi", client: 77.81.151.129, server: test.com, request: "POST /capi/session/forgot HTTP/1.1", host: "test.com",…

VIEW QUESTION

Fluentd: – problem with regex while parsing log – Nginx

I have this fluentd configuration: <source> @type tail <parse> @type regexp expression /^(?<remote>[^ ]*) (?<host>[^ ]*) (?<user>[^ ]*) [(?<time>[^]]*)] "(?<method>w+) (?<path>[^ ]*) (?<http>[^ ]*)" (?<status_code>[^ ]*) (?<size>[^ ]*)(?:s"(?<referer>[^"]*)") "(?<agent>[^"]*)" (?<urt>[^"]*).*/ time_format %d/%b/%Y:%H:%M:%S %z keep_time_key true types size:integer,reqtime:float,uct:float,uht:float,urt:float </parse> path /var/log/nginx/access.log…

VIEW QUESTION
Back To Top
Search