如何配置fluentd http输入插件以侦听运行中的Web服务器?

时间:2019-02-21 06:10:06

标签: fluentd

假设我有一个包含以下内容的环境:

  • 在端口9876上运行的NodeJS Web服务器
  • 已安装log-forwarder td-agent

我想将NodeJS Web服务器收到的HTTP POST消息发送到fluentd(日志聚合器),而无需修改Web服务器本身。

我尝试像这样设置日志转发器的td-agent配置文件(/etc/td-agent/td-agent.conf):

<source>
  @type http
  tag app.httplogs
  port 9876
  bind 0.0.0.0
  body_size_limit 50m
  keepalive_timeout 10s
</source>

<match *.*>
  @type forward
  @id forward_http
  heartbeat_type tcp
  <server>
    host (ip address of fluentd log-aggregator)
  </server>
</match>

然后,我运行以下命令:

sudo /etc/init.d/td-agent start

这将导致 EADDRINUSE:地址已在使用中错误

2019-02-21 14:35:14 +0900 [error]: unexpected error error_class=Errno::EADDRINUSE error=#<Errno::EADDRINUSE: Address already in use - bind(2) for "0.0.0.0" port 9876>
  2019-02-21 14:35:14 +0900 [error]: /opt/td-agent/embedded/lib/ruby/gems/2.5.0/gems/fluentd-0.12.43/lib/fluent/plugin/in_http.rb:104:in `initialize'
  2019-02-21 14:35:14 +0900 [error]: /opt/td-agent/embedded/lib/ruby/gems/2.5.0/gems/fluentd-0.12.43/lib/fluent/plugin/in_http.rb:104:in `new'
  2019-02-21 14:35:14 +0900 [error]: /opt/td-agent/embedded/lib/ruby/gems/2.5.0/gems/fluentd-0.12.43/lib/fluent/plugin/in_http.rb:104:in `start'
  2019-02-21 14:35:14 +0900 [error]: /opt/td-agent/embedded/lib/ruby/gems/2.5.0/gems/fluentd-0.12.43/lib/fluent/root_agent.rb:115:in `block in start'
  2019-02-21 14:35:14 +0900 [error]: /opt/td-agent/embedded/lib/ruby/gems/2.5.0/gems/fluentd-0.12.43/lib/fluent/root_agent.rb:114:in `each'
  2019-02-21 14:35:14 +0900 [error]: /opt/td-agent/embedded/lib/ruby/gems/2.5.0/gems/fluentd-0.12.43/lib/fluent/root_agent.rb:114:in `start'
  2019-02-21 14:35:14 +0900 [error]: /opt/td-agent/embedded/lib/ruby/gems/2.5.0/gems/fluentd-0.12.43/lib/fluent/engine.rb:237:in `start'
  2019-02-21 14:35:14 +0900 [error]: /opt/td-agent/embedded/lib/ruby/gems/2.5.0/gems/fluentd-0.12.43/lib/fluent/engine.rb:187:in `run'
  2019-02-21 14:35:14 +0900 [error]: /opt/td-agent/embedded/lib/ruby/gems/2.5.0/gems/fluentd-0.12.43/lib/fluent/supervisor.rb:570:in `run_engine'
  2019-02-21 14:35:14 +0900 [error]: /opt/td-agent/embedded/lib/ruby/gems/2.5.0/gems/fluentd-0.12.43/lib/fluent/supervisor.rb:162:in `block in start'
  2019-02-21 14:35:14 +0900 [error]: /opt/td-agent/embedded/lib/ruby/gems/2.5.0/gems/fluentd-0.12.43/lib/fluent/supervisor.rb:366:in `main_process'
  2019-02-21 14:35:14 +0900 [error]: /opt/td-agent/embedded/lib/ruby/gems/2.5.0/gems/fluentd-0.12.43/lib/fluent/supervisor.rb:339:in `block in supervise'
  2019-02-21 14:35:14 +0900 [error]: /opt/td-agent/embedded/lib/ruby/gems/2.5.0/gems/fluentd-0.12.43/lib/fluent/supervisor.rb:338:in `fork'
  2019-02-21 14:35:14 +0900 [error]: /opt/td-agent/embedded/lib/ruby/gems/2.5.0/gems/fluentd-0.12.43/lib/fluent/supervisor.rb:338:in `supervise'
  2019-02-21 14:35:14 +0900 [error]: /opt/td-agent/embedded/lib/ruby/gems/2.5.0/gems/fluentd-0.12.43/lib/fluent/supervisor.rb:156:in `start'
  2019-02-21 14:35:14 +0900 [error]: /opt/td-agent/embedded/lib/ruby/gems/2.5.0/gems/fluentd-0.12.43/lib/fluent/command/fluentd.rb:173:in `<top (required)>'
  2019-02-21 14:35:14 +0900 [error]: /opt/td-agent/embedded/lib/ruby/site_ruby/2.5.0/rubygems/core_ext/kernel_require.rb:55:in `require'
  2019-02-21 14:35:14 +0900 [error]: /opt/td-agent/embedded/lib/ruby/site_ruby/2.5.0/rubygems/core_ext/kernel_require.rb:55:in `require'
  2019-02-21 14:35:14 +0900 [error]: /opt/td-agent/embedded/lib/ruby/gems/2.5.0/gems/fluentd-0.12.43/bin/fluentd:8:in `<top (required)>'
  2019-02-21 14:35:14 +0900 [error]: /opt/td-agent/embedded/bin/fluentd:23:in `load'
  2019-02-21 14:35:14 +0900 [error]: /opt/td-agent/embedded/bin/fluentd:23:in `<top (required)>'
  2019-02-21 14:35:14 +0900 [error]: /usr/sbin/td-agent:7:in `load'
  2019-02-21 14:35:14 +0900 [error]: /usr/sbin/td-agent:7:in `<main>'
2019-02-21 14:35:14 +0900 [info]: shutting down fluentd
2019-02-21 14:35:14 +0900 [info]: shutting down output type="forward" plugin_id="forward_http"
2019-02-21 14:35:15 +0900 [info]: process finished code=0

是否可以在Web服务器上同时使用fluentd的http输入插件 (即在同一环境中)?

0 个答案:

没有答案