我使用下面的配置让fluentd读取auth.logs并将其发送到elastic search,但我遇到一个错误,说模式不匹配,日志不会被推送到ES。
我使用的是fluentd syslog解析器插件rfc3164-pattern中定义的模式
<source>
@type tail
path /var/log/auth.log
pos_file /var/log/auth.pos
format /^\<(?<pri>[0-9]+)\>(?<time>[^ ]* {1,2}[^ ]* [^ ]*) (?<host>[^ ]*) (?<ident>[a-zA-Z0-9_\/\.\-]*)(?:\[(?<pid>[0-9]+)\]) *(?<message>.*)$/
tag authlog
</source>
<match authlog.**>
@type elasticsearch
hosts "ESHOST:PORT"
logstash_format true
logstash_prefix "server-authlogs"
include_tag_key true
flush_interval 5s
logstash_dateformat %Y.%m.%d
time_precision 3
</match>
输出错误:
2019-04-16 08:00:50 +0000 warn:#0模式不匹配:"Apr 16 08:00:50 hostname-1415 sshd15134: pam_unix(sshd: session ):会话由(uid=0)为用户ubuntu打开“2019-04-16 08:00:50 +0000 warn:#0模式不匹配:"Apr 16 08:00:50 hostname-1415 systemd-logind1138:用户ubuntu的新会话10。”
发布于 2019-04-17 03:09:56
对于那些正在寻找类似的东西的人来说,这里的配置工作得很好。
<source>
type tail
path /var/log/foo/auth.log
pos_file /var/log/auth.pos
tag authlog
format /^(?<time>[^ ]* {1,2}[^ ]* [^ ]*) (?<host>[^ ]*) (?<ident>[a-zA-Z0-9_\/\.\-]*)(?:\[(?<pid>[0-9]+)\])?(?:[^\:]*\:)? *(?<message>.*)$/
</source>
<match authlog.**>
@type elasticsearch
hosts "ESHOST:PORT"
logstash_format true
logstash_prefix "server-authlogs"
include_tag_key true
flush_interval 5s
logstash_dateformat %Y.%m.%d
time_precision 3
</match>
对于auth.log模式:
Apr 16 18:02:02 host-1415 sshd[11111]: Accepted password for ubuntu from 111.11.111.11 port 11111 ssh2
发布于 2019-04-17 08:36:57
使用parser_syslog怎么样?如果/var/log/auth.log采用syslog格式(RFC3164)。
<source>
@type tail
path /var/log/auth.log
pos_file /var/log/auth.pos
tag authlog
<parse>
@type syslog
message_format rfc3164
with_priority false
</parse>
</source>
https://stackoverflow.com/questions/55703492
复制相似问题