In my/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;哇64; rv:43.0) 壁虎/20100101火狐/43.0\"
为什么这个父亲不匹配?最好。
面临警告:流利的模式不匹配,因此我的过滤器部分不起作用。然后我认真对待这个警告,并通过创建一个正则表达式来解决这个问题。所以,我的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/[wW]*
</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 中进行了不同的配置。您可以使用卢布
用于在 Ruby 中创建正则表达式,因为 Fluentd/TD-agent 是用 Ruby 编写的。之后,您可以查看在目录/var/log/td-agent/buffer/s3.xxx 中收集日志的缓冲区
巴插件不支持 apache 日志格式"vhost_combined"而是"组合"的格式。
如何更改 apache 配置文件,如下所示:
etc/apache2/conf-available/other-vhosts-access-log.conf
之前:CustomLog ${APACHE_LOG_DIR}/other_vhosts_access.log vhost_combined
(将vhost_combined更改为合并)
之后:CustomLog ${APACHE_LOG_DIR}/other_vhosts_access.log combined