Nginx logs cannot get parsed
I have nginx logs written to docker logs as :
172.17.0.1 - - [23/Mar/2018:12:21:32 +0000] "GET / HTTP/1.1" 200 612 "-" "curl/7.47.0" "-"
172.17.0.1 - - [23/Mar/2018:12:21:33 +0000] "GET / HTTP/1.1" 200 612 "-" "curl/7.47.0" "-"
10.176.217.225 - - [23/Mar/2018:13:23:44 +0000] "GET / HTTP/1.1" 304 0 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.186 Safari/537.36" "-"
10.176.217.225 - - [23/Mar/2018:13:23:52 +0000] "GET / HTTP/1.1" 304 0 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.186 Safari/537.36" "-"
I've fluentd setup as:
<source>
type tail
pos_file fluentd-docker.pos
path /var/lib/docker/containers/faa18fdeca2eae392b1ab41f10109a1c8ba759cf29b5aa2607e3c497561aee4e/faa18fdeca2eae392b1ab41f10109a1c8ba759cf29b5aa2607e3c497561aee4e-json.log
tag nginx.hicham
format /^\\"(?<remote>[^ ]*) (?<host>[^ ]*) (?<user>[^ ]*) \[(?<time>[^\]]*)\] .*"(?<method>\S+)(?: +(?<path>[^\"]*) +\S*)?" (?<code>[^ ]*) (?<size>[^ ]*) .*"(?<referer>[^\"]*)\\\\\\" .*"(?<agent>[^\"]*)\\\\\\" .*"(?<xxx>[^\"]*)\\\\\\"/
time_format %d/%b/%Y:%H:%M:%S %z
</source>
<filter nginx.*>
@type geoip
geoip_lookup_keys host
<record>
city ${city["host"]}
</record>
</filter>
<match nginx.**>
@type copy
<store>
@type elasticsearch
host elasticsearch_IP
port 9200
index_name .hicam
logstash_dateformat %Y%m%d
include_tag_key true
type_name forever
time_key @timestamp
tag_key @landscape
resurrect_after 5
flush_interval 1s
</store>
<store>
@type stdout
</store>
</match>
but, nginx logs does not get parsed:
2018-03-23 13:39:05 +0000 [warn]: #0 pattern not match: "{\"log\":\"10.176.217.225 - - [23/Mar/2018:13:39:05 +0000] \\\"GET / HTTP/1.1\\\" 304 0 \\\"-\\\" \\\"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.186 Safari/537.36\\\" \\\"-\\\"\\n\",\"stream\":\"stdout\",\"attrs\":{\"cont_name\":\"nginx\",\"cont_service\":\"nginxService\"},\"time\":\"2018-03-23T13:39:05.874547167Z\"}"
even if I change the format to the official one in fluentd doc, I get the same result
in the other when i test it in fluentlar, it gets parsed.
is that a bug? or I did something wrong?
I answered it in ML.