Fluentd数据采集到Kafka

  • 安装fluent

    下载安装 fluentd (查看官方文档,不详细介绍)

  • 安装fluent-plugin-kafka

    a. 修改ruby 的gem源 

查看源:
$ gem source
  https://ruby.taobao.org/ (已经修改好了之后的) 
删除默认源:
$ gem source -r <url>
添加新指向:
$ gem source -a https://ruby.taobao.org/
done

    b. 安装fluent-plugin-kafka (github上有详细介绍)     

  • fluentd --setup /path/xxx

  • 配置/path/xxx下的fluent.conf 

<source>
  @type forward
  @id forward_input
</source>

<source>
  @type http
  @id http_input
  port 8888
</source>

<source>
  @type    tail  #### tail方式采集日志
  #format   none
  format   /^(?<all>.*)$/
  path     /tmp/app_log.txt
  pos_file /data/logs/td-agent/httpd-access.log.pos
  tag      app_log.tag
</source>

<match app_log.**>
  @type               kafka
  #brokers            localhost:9002,localhost:9003
  zookeeper           localhost:2181
  default_topic       app_log_raw  
  #刷新间隔
  flush_interval      30
  buffer_type         file
  ack_timeout_ms      2000
  output_data_type    attr:all
  compression_codec   none
</match>

<source>
  @type monitor_agent
  @id monitor_agent_input
  port 24220
</source>

<source>
  @type debug_agent
  @id debug_agent_input
  bind 127.0.0.1
  port 24230
</source>

<match debug.**>
  @type stdout
  @id stdout_output
</match>

<match system.**>
  @type forward
  @id forward_output

  <server>
    host 192.168.0.11
  </server>
  <secondary>
    <server>
      host 192.168.0.12
    </server>
  </secondary>
</match>
$ fluentd -c fluent.conf
  • 查看kafka中数据是否进入

$ bin/kafka-console-consumer.sh --zookeeper localhost:2181 --topic app_log_raw



转载于:https://my.oschina.net/u/239075/blog/474296

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值