httpd 虚拟主机的流利日志未转发到日志服务器

fluentd logs for httpd vhosts not being forwarded to logging server

我在设置 fluentd 以转发虚拟主机的 httpd 访问日志时遇到了一些困难。我有五个虚拟主机,我想分别记录每个虚拟主机的访问和错误,其次,流畅地跟踪这些文件并将日志转发到日志服务器。第一个没问题,第二个就不行了

使用这个 conf 文件,来自所有虚拟主机的所有 httpd 日志都被写入一个文件并正确转发到日志服务器。

<source>
  type tail
  format apache2
  tag apache.access
  path /var/log/apache/access_log
  pos_file /var/log/apache/access_log.pos
</source>

<match apache.access>
  type forward
  send_timeout 60s
  recover_wait 10s
  heartbeat_interval 1s
  phi_threshold 16
  hard_timeout 60s
  <server>
    name internal-1
    host 192.168.0.245
    port 24224
  </server>
</match>

但是,当我像这样更改 httpd-vhosts.conf 中日志文件的路径时:

CustomLog "/var/log/apache/internal-wiki/access_log" combined

并将 td-agent.conf 更改为:

<source>
  type tail
  format apache2
  tag internalwiki.access
  path /var/log/apache/internal-wiki/access_log
  pos_file /var/log/apache/internal-wiki/access_log.pos
</source>

<match internalwiki.access>
  type forward
  send_timeout 60s
  recover_wait 10s
  heartbeat_interval 1s
  phi_threshold 16
  hard_timeout 60s
  <server>
    name internal-1
    host 192.168.0.245
    port 24224
  </server>
</match>

日志已正确写入 CustomLog,但未转发至日志服务器。

td-agent.log的输出是

2015-11-09 12:23:44 +0900 [warn]: no patterns matched tag="internalwiki.access"

如果我在本地机器上将匹配类型更改为 stdout 和 tail td-agent.log,这没问题。

td-agent 在两台服务器上都是 运行 root 并且文件权限是 666 所以 td-agent 应该能够读取 access_log

日志服务器上的端口 24224 已打开,我已经用 nmap 检查过,我可以远程登录到端口 24224 并在日志服务器上查看 td-agent.log 中的条目,所以没有问题网络。

所以,我做错了什么?

这是一个基本错误... Web 服务器配置正确,但接收服务器配置不正确。

我没有在日志服务器上的 td-agent.conf 中包含源和匹配模式。

添加这个解决了我的问题。

<source>
  type forward
</source>
<match *.access>
  type stdout
</match>

所以我将其标记为已解决。