首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >用于解析auth.log的fluentd配置

用于解析auth.log的fluentd配置
EN

Stack Overflow用户
提问于 2019-04-16 16:13:50
回答 2查看 1.9K关注 0票数 1

我使用下面的配置让fluentd读取auth.logs并将其发送到elastic search,但我遇到一个错误,说模式不匹配,日志不会被推送到ES。

我使用的是fluentd syslog解析器插件rfc3164-pattern中定义的模式

代码语言:javascript
复制
<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。”

EN

回答 2

Stack Overflow用户

发布于 2019-04-17 03:09:56

对于那些正在寻找类似的东西的人来说,这里的配置工作得很好。

代码语言:javascript
复制
<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模式:

代码语言:javascript
复制
Apr 16 18:02:02 host-1415 sshd[11111]: Accepted password for ubuntu from 111.11.111.11 port 11111 ssh2
票数 0
EN

Stack Overflow用户

发布于 2019-04-17 08:36:57

使用parser_syslog怎么样?如果/var/log/auth.log采用syslog格式(RFC3164)。

代码语言:javascript
复制
<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>
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/55703492

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档