61 lines
1.5 KiB
Nginx Configuration File
61 lines
1.5 KiB
Nginx Configuration File
filter f_nginx { match("nginx" value("PROGRAM")); };
|
|
|
|
parser p_nginx_message {
|
|
csv-parser(
|
|
dialect(escape-double-char)
|
|
flags(strip-whitespace)
|
|
delimiters(" ")
|
|
quote-pairs('""[]')
|
|
columns("docker", "nginx.client.ip", "nginx.ident", "nginx.auth", "nginx.timestamp", "nginx.request", "nginx.response", "nginx.bytes", "nginx.referrer", "nginx.agent")
|
|
);
|
|
};
|
|
|
|
rewrite r_nginx_docker_header {
|
|
subst(":", " ", value("docker"));
|
|
subst("\/", " ", value("docker"));
|
|
subst('\[', " ", value("docker"));
|
|
subst('\]', " ", value("docker"));
|
|
};
|
|
|
|
parser p_nginx_docker_header {
|
|
csv-parser(
|
|
template("${docker}")
|
|
flags(strip-whitespace)
|
|
delimiters(" ")
|
|
columns("docker.image.name", "docker.container.name", "docker.container.pid")
|
|
);
|
|
};
|
|
|
|
parser p_nginx_client_ip_geoip2_city {
|
|
geoip2(
|
|
"${nginx.client.ip}",
|
|
prefix( "geoip2.source." )
|
|
database( "/config/GeoIP/GeoLite2-City.mmdb" )
|
|
);
|
|
};
|
|
|
|
destination d_nginx_logs {
|
|
elasticsearch-http(
|
|
index("nginx-logs")
|
|
type("")
|
|
user("elastic")
|
|
password("forty6and2")
|
|
url("http://pi501.in.thelinuxpro.net:9200/_bulk")
|
|
template("$(format-json --scope rfc5424 --scope dot-nv-pairs
|
|
--rekey .* --shift 1 --scope nv-pairs
|
|
--exclude DATE @timestamp=${ISODATE})")
|
|
persist-name("d_nginx_logs")
|
|
);
|
|
};
|
|
|
|
log {
|
|
source(s_network_udp);
|
|
filter(f_nginx);
|
|
parser(p_nginx_message);
|
|
rewrite(r_nginx_docker_header);
|
|
parser(p_nginx_docker_header);
|
|
parser(p_nginx_client_ip_geoip2_city);
|
|
destination(d_nginx_logs);
|
|
flags(final);
|
|
};
|