配置一个有多Agent的流

要配置一个多层级的流,你需要在第一层Agent的末尾使用Avro/Thrift Sink,并且指向下一层Agent的Avro/Thrift Source。这样就能将第一层Agent的Event发送到下一层的Agent了。例如,你使用avro客户端定期地发送文件(每个Event一个文件)到本地的Event上,然后本地的Agent可以把Event发送到另一个配置了存储功能的Agent上。

提示

语言描述似乎不太容易理解,大概是这样的结构[source1]->[channel]->[Avro Sink]->[Avro Source]->[channel2]->[Sink2]

一个收集web日志的Agent配置:

  1. # 列出这个Agent的source、sink和channel
  2. agent_foo.sources = avro-AppSrv-source
  3. agent_foo.sinks = avro-forward-sink
  4. agent_foo.channels = file-channel
  5.  
  6. # 把source、channel、sink连接起来,组成一个流
  7. agent_foo.sources.avro-AppSrv-source.channels = file-channel
  8. agent_foo.sinks.avro-forward-sink.channel = file-channel
  9.  
  10. # avro-forward-sink 的属性配置
  11. agent_foo.sinks.avro-forward-sink.type = avro
  12. agent_foo.sinks.avro-forward-sink.hostname = 10.1.1.100
  13. agent_foo.sinks.avro-forward-sink.port = 10000
  14.  
  15. # 其他部分配置(略)
  16. #...

存储到HDFS的Agent配置:

  1. # 列出这个Agent的source、sink和channel
  2. agent_foo.sources = avro-collection-source # 只有一个source叫做:avro-collection-source
  3. agent_foo.sinks = hdfs-sink # 只有一个sink叫做:hdfs-sink
  4. agent_foo.channels = mem-channel # 只有一个channel叫做:mem-channel
  5.  
  6. # 把source、channel、sink连接起来,组成一个流
  7. agent_foo.sources.avro-collection-source.channels = mem-channel
  8. agent_foo.sinks.hdfs-sink.channel = mem-channel
  9.  
  10. # Avro Source的属性配置
  11. agent_foo.sources.avro-collection-source.type = avro
  12. agent_foo.sources.avro-collection-source.bind = 10.1.1.100
  13. agent_foo.sources.avro-collection-source.port = 10000
  14.  
  15. # 其他部分配置(略)
  16. #...

上面两个Agent就这样连接到了一起,最终Event会从外部应用服务器进入,经过第一个Agent流入第二个Agent,最终通过hdfs-sink存储到了HDFS。

提示

什么,不知道两个Agent怎么连接到一起的? 第一个Agent的Avro Sink将Event发送到了10.1.1.100的10000端口上,而第二个Agent的Avro Source从10.1.1.100的10000端口上接收Event,就这样形成了两个Agent首尾相接的多Agent流。