【问题标题】:Fluentd apache format [warn]: pattern not match:Fluentd apache 格式 [警告]:模式不匹配:
【发布时间】:2016-05-21 14:03:11
【问题描述】:

在我的 /etc/fluent/fluent.conf 中

<source>
  @type tail
  format apache2
  path /var/log/apache2/other_vhosts_access.log
  tag apache2.access
</source>

错误/警告:2016-02-11 00:59:10 +0100 [警告]:模式不匹配: “mybebsite.dz:443 105.101.114.234 - - [11/Feb/2016:00:59:10 +0100] \"POST /__es/_all/_search HTTP/1.1\" 200 794 \"https://mywebsite.net/\" \"Mozilla/5.0 (Windows NT 6.1; WOW64; rv:43.0) Gecko/20100101 Firefox/43.0\""

为什么这个模式不匹配? 最好的。

【问题讨论】:

    标签: apache fluentd


    【解决方案1】:

    tail插件似乎不支持apache日志格式“vhost_combined”但“combined”的格式。
    修改apache配置文件怎么样:

    /etc/apache2/conf-available/other-vhosts-access-log.conf
    之前:CustomLog ${APACHE_LOG_DIR}/other_vhosts_access.log vhost_combined
    (将 vhost_combined 更改为 combined)
    后:CustomLog ${APACHE_LOG_DIR}/other_vhosts_access.log combined

    【讨论】:

      【解决方案2】:

      我在 fluentd 中一直面临 警告:模式不匹配,因此我的过滤器部分无法正常工作。然后我认真对待这个警告并通过创建一个正则表达式来解决这个问题。所以,我的 td-agent.conf 如下:

       <source>
          @type tail
          format **/^([^ ]*) (?<host>[^ ]*) [^ ]* "(?<method>\S+) (?<path>[^ ]* +\S*)? (?<code>[^ ]*) (?<size>[^ ]*) (?: "(?<referer>[^\"]*)" "(?<agent>[^\"]*)")?/**
          path /var/log/apache2/access.log
          pos_file /var/log/td-agent/httpd.access.pos
          tag s3.apache.access
        </source>
        <filter **>
          @type grep
          <regexp>
            key path
            pattern \/aws\/project_launch\/view\/[\w\W]*
          </regexp>
        </filter>
        <match **>
          @type s3
          aws_key_id xxxxxx
          aws_sec_key xxxxxx
          s3_bucket bucketalifluentd
          s3_region eu-west-1
          path logs_viewshare/
          buffer_path /var/log/td-agent/buffer/s3
          time_slice_format %Y-%m-%d/%H
          time_slice_wait 2m
        </match>
      

      请注意,您的 apache2 日志可能会有所不同,因为您在 apache2.conf 中进行了不同的配置。你可以使用rubular

      用于在 ruby​​ 中创建正则表达式,因为 fluentd/td-agent 是用 ruby​​ 编写的。 之后,您可以在目录 /var/log/td-agent/buffer/s3.xxx

      中查看已收集日志的缓冲区

      【讨论】:

      • 我使用了 rubular 并将结果(工作)表达式)粘贴到 td-agent.conf 中。但是,在 Windows 上运行 fluentd 并读取 Linux Docker 转发的标准输出仍然无法解析。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-10-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-03-23
      相关资源
      最近更新 更多