fluentd收集nginx日志并输出到kafka

警告
本文最后更新于 2020-07-24 10:19,文中内容可能已过时。

官方文档

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<source>
  @type tail
  path /var/log/nginx/access.log
  pos_file /tmp/nginx.log.pos
  tag nginx.access
  <parse **>
    @type nginx
    expression /^(?<remote>[^ ]*) (?<host>[^ ]*) (?<user>[^ ]*) \[(?<time>[^\]]*)\] "(?<method>\S+)(?: +(?<path>[^\"]*?)(?: +\S*)?)?" (?<code>[^ ]*) (?<size>[^ ]*)(?: "(?<referer>[^\"]*)" "(?<agent>[^\"]*)"(?:\s+(?<http_x_forwarded_for>[^ ]+))?)?$/
  </parse>
</source>

<filter nginx.**>
  @type record_transformer
  <record>
    name "soulchild"
  </record>
</filter>

<match nginx.**>
  @type kafka2
  brokers  10.0.0.190:9092,10.0.0.191:9092,10.0.0.192:9092
  topic_key nginx_tag
  default_topic  nginx.access
  <buffer>
    flush_interval  5s
  </buffer>
  <format>
    @type json
  </format>
</match>
请我喝杯水
SoulChild 微信号 微信号
SoulChild 微信打赏 微信打赏
0%