首页 文章

流利的apache格式[警告]:模式不匹配:

提问于
浏览
2

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

@type尾格式apache2路径/var/log/apache2/other_vhosts_access.log标记apache2.access

错误/警告:2016年2月11日○点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 \“”

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

2 回答

  • 0

    似乎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

  • 0

    我一直面对流利的 warn: pattern not match ,因此我的过滤部分无效 . 然后我认真对待这个警告并通过创建一个正则表达式来解决这个问题 . 所以,我的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中创建正则表达式,因为流利/ td-agent已用ruby编写 . 之后,您可以在目录 /var/log/td-agent/buffer/s3.xxx 中查看已收集日志的缓冲区

相关问题