【问题标题】:Strange "pattern not match" error on fluentdfluentd上奇怪的“模式不匹配”​​错误
【发布时间】:2015-10-23 05:15:31
【问题描述】:

谁能判断 fluentd 在 td-agent.log 文件中引发此错误是否正常?

2015-07-31 13:15:19 +0000 [warn]: pattern not match: "- - - [31/Jul/2015:13:15:19 +0000] GET http://172.31.108.218/ HTTP/1.1 200 0 \"-\" \"ELB-HealthChecker/1.0\""

虽然这是一个格式良好的 apache2 日志:

- - - [31/Jul/2015:13:15:19 +0000] GET http://172.31.108.218/ HTTP/1.1 200 0 \"-\" \"ELB-HealthChecker/1.0\"

这里是源配置:

<source>
  type tail
  format apache2
  path /var/log/varnish/varnishncsa.log
  pos_file /var/log/td-agent/tmp/access.log.pos
  tag "apache2.varnish-access"
</source>

我不知道上面有什么问题。

【问题讨论】:

    标签: apache logging fluentd


    【解决方案1】:

    您可以为 Apache 访问日志设置自己的format,而不是寻找某种方法从 ELB-HealthChecker 中过滤掉日志,这在前几个字段方面更加灵活。从 collectd 获取 /server-status 检查时,我遇到了同样的错误(使用它来监视 SignalFx)。

    像这样设置源:

    <source>
      type tail
      format /^(?<host>[^ ]*(?:\s+[^ ]+)*) [^ ]* (?<user>[^ ]*) \[(?<time>[^\]]*)\] "(?<method>\S+)(?: +(?<path>[^ ]*) +\S*)?" (?<code>[^ ]*) (?<size>[^ ]*)(?: "(?<referer>[^\"]*)" "(?<agent>[^\"]*)")?$/
      time_format %d/%b/%Y:%H:%M:%S %z
      path /var/log/apache2/access.log
      pos_file /var/log/td-agent/apache2.pos
      tag apache2.log
    </source>
    

    允许两个日志行,例如:

    172.18.0.2:80 127.0.0.1 - - [08/Aug/2017:19:58:38 +0000] "GET /server-status?auto HTTP/1.1" 200 508 "-" "collectd/5.7.2.sfx0"
    

    还有:

    192.168.0.1 - - [28/Feb/2013:12:00:00 +0900] "GET / HTTP/1.1" 200 777 "-" "Opera/12.0"
    

    您可以使用Fluentular 测试format 正则表达式匹配。

    查看相关:Fluentd apache log format with multiple host ip

    【讨论】:

      【解决方案2】:

      问题是这些 ELB-HealthChecker 行日志有一个空的referer ip 字段。然后日志与 fluentd 的 apache2 日志格式不匹配。

      因此,解决此问题的方法是使用 ELB-HealthChecker 用户代理过滤日志。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2016-01-03
        • 2011-12-26
        • 2016-05-21
        • 1970-01-01
        • 1970-01-01
        • 2014-09-13
        相关资源
        最近更新 更多