【发布时间】:2019-09-06 06:43:37
【问题描述】:
我正在使用以下配置让 fluentd 读取 auth.logs 并将其发送到弹性搜索,但我遇到了一个错误,提示模式不匹配并且日志未推送到 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 [警告]:#0 模式不匹配:“Apr 16 08:00:50 hostname-1415 sshd[15134]:pam_unix(sshd:session): 会话打开对于用户 ubuntu (uid = 0)“ 2019-04-16 08:00:50 +0000 [警告]:#0 模式不匹配:“Apr 16 08:00:50 hostname-1415 systemd-logind [1138]:用户 ubuntu 的新会话 10。”
【问题讨论】:
-
这是一个正则表达式问题,不流畅。尝试使用fluentular.herokuapp.com 进行故障排除。请注意,您的错误示例中有 2 个错误。
-
我找到了一个匹配 auth.log 的正则表达式。感谢指导。
-
感谢回帖,很有用
标签: elasticsearch logging kubernetes fluentd efk