使用TCP从一个logstash发送到另一个

时间:2016-01-15 22:49:40

标签: logstash

我正在尝试将事件从logstash服务器转发到另一个服务器。最后一个logstash服务器应该将收到的日志写入文件

在源logthash中我添加了:

output {
    tcp {
        host => "host"
        port => port
    }
}

并且目标logstash具有:

input {
  tcp {
    port => port
  }
}

output {
  file {
    path => "/var/log/project/log"
  }
}

这是启动日志:

{:timestamp=>"2016-01-15T23:12:30.884000+0100", :message=>"Reading config file", :file=>"logstash/agent.rb", :level=>:debug, :line=>"309", :method=>"local_config"}
{:timestamp=>"2016-01-15T23:12:31.011000+0100", :message=>"Compiled pipeline code:\n        @inputs = []\n        @filters = []\n        @outputs = []\n        @periodic_flushers = []\n        @shutdown_flushers = []\n\n          @input_tcp_1 = plugin(\"input\", \"tcp\", LogStash::Util.hash_merge_many({ \"port\" => port }))\n\n          @inputs << @input_tcp_1\n\n          @output_file_2 = plugin(\"output\", \"file\", LogStash::Util.hash_merge_many({ \"path\" => (\"/var/log/project/log\") }))\n\n          @outputs << @output_file_2\n\n  def filter_func(event)\n    events = [event]\n    @logger.debug? && @logger.debug(\"filter received\", :event => event.to_hash)\n    events\n  end\n  def output_func(event)\n    @logger.debug? && @logger.debug(\"output received\", :event => event.to_hash)\n    @output_file_2.handle(event)\n    \n  end", :level=>:debug, :file=>"logstash/pipeline.rb", :line=>"29", :method=>"initialize"}
{:timestamp=>"2016-01-15T23:12:31.027000+0100", :message=>"Plugin not defined in namespace, checking for plugin file", :type=>"input", :name=>"tcp", :path=>"logstash/inputs/tcp", :level=>:debug, :file=>"logstash/plugin.rb", :line=>"133", :method=>"lookup"}
{:timestamp=>"2016-01-15T23:12:31.070000+0100", :message=>"Plugin not defined in namespace, checking for plugin file", :type=>"codec", :name=>"line", :path=>"logstash/codecs/line", :level=>:debug, :file=>"logstash/plugin.rb", :line=>"133", :method=>"lookup"}
{:timestamp=>"2016-01-15T23:12:31.101000+0100", :message=>"config LogStash::Codecs::Line/@charset = \"UTF-8\"", :level=>:debug, :file=>"logstash/config/mixin.rb", :line=>"111", :method=>"config_init"}
{:timestamp=>"2016-01-15T23:12:31.120000+0100", :message=>"config LogStash::Inputs::Tcp/@port = 35364", :level=>:debug, :file=>"logstash/config/mixin.rb", :line=>"111", :method=>"config_init"}
{:timestamp=>"2016-01-15T23:12:31.127000+0100", :message=>"config LogStash::Inputs::Tcp/@debug = false", :level=>:debug, :file=>"logstash/config/mixin.rb", :line=>"111", :method=>"config_init"}
{:timestamp=>"2016-01-15T23:12:31.135000+0100", :message=>"config LogStash::Inputs::Tcp/@codec = <LogStash::Codecs::Line charset=>\"UTF-8\">", :level=>:debug, :file=>"logstash/config/mixin.rb", :line=>"111", :method=>"config_init"}
{:timestamp=>"2016-01-15T23:12:31.138000+0100", :message=>"config LogStash::Inputs::Tcp/@add_field = {}", :level=>:debug, :file=>"logstash/config/mixin.rb", :line=>"111", :method=>"config_init"}
{:timestamp=>"2016-01-15T23:12:31.146000+0100", :message=>"config LogStash::Inputs::Tcp/@host = \"0.0.0.0\"", :level=>:debug, :file=>"logstash/config/mixin.rb", :line=>"111", :method=>"config_init"}
{:timestamp=>"2016-01-15T23:12:31.154000+0100", :message=>"config LogStash::Inputs::Tcp/@data_timeout = -1", :level=>:debug, :file=>"logstash/config/mixin.rb", :line=>"111", :method=>"config_init"}
{:timestamp=>"2016-01-15T23:12:31.162000+0100", :message=>"config LogStash::Inputs::Tcp/@mode = \"server\"", :level=>:debug, :file=>"logstash/config/mixin.rb", :line=>"111", :method=>"config_init"}
{:timestamp=>"2016-01-15T23:12:31.169000+0100", :message=>"config LogStash::Inputs::Tcp/@ssl_enable = false", :level=>:debug, :file=>"logstash/config/mixin.rb", :line=>"111", :method=>"config_init"}
{:timestamp=>"2016-01-15T23:12:31.172000+0100", :message=>"config LogStash::Inputs::Tcp/@ssl_verify = false", :level=>:debug, :file=>"logstash/config/mixin.rb", :line=>"111", :method=>"config_init"}
{:timestamp=>"2016-01-15T23:12:31.175000+0100", :message=>"config LogStash::Inputs::Tcp/@ssl_key_passphrase = <password>", :level=>:debug, :file=>"logstash/config/mixin.rb", :line=>"111", :method=>"config_init"}
{:timestamp=>"2016-01-15T23:12:31.179000+0100", :message=>"Plugin not defined in namespace, checking for plugin file", :type=>"output", :name=>"file", :path=>"logstash/outputs/file", :level=>:debug, :file=>"logstash/plugin.rb", :line=>"133", :method=>"lookup"}
{:timestamp=>"2016-01-15T23:12:31.219000+0100", :message=>"Plugin not defined in namespace, checking for plugin file", :type=>"codec", :name=>"plain", :path=>"logstash/codecs/plain", :level=>:debug, :file=>"logstash/plugin.rb", :line=>"133", :method=>"lookup"}
{:timestamp=>"2016-01-15T23:12:31.246000+0100", :message=>"config LogStash::Codecs::Plain/@charset = \"UTF-8\"", :level=>:debug, :file=>"logstash/config/mixin.rb", :line=>"111", :method=>"config_init"}
{:timestamp=>"2016-01-15T23:12:31.263000+0100", :message=>"config LogStash::Outputs::File/@path = \"/var/log/project/log\"", :level=>:debug, :file=>"logstash/config/mixin.rb", :line=>"111", :method=>"config_init"}
{:timestamp=>"2016-01-15T23:12:31.269000+0100", :message=>"config LogStash::Outputs::File/@type = \"\"", :level=>:debug, :file=>"logstash/config/mixin.rb", :line=>"111", :method=>"config_init"}
{:timestamp=>"2016-01-15T23:12:31.281000+0100", :message=>"config LogStash::Outputs::File/@tags = []", :level=>:debug, :file=>"logstash/config/mixin.rb", :line=>"111", :method=>"config_init"}
{:timestamp=>"2016-01-15T23:12:31.284000+0100", :message=>"config LogStash::Outputs::File/@exclude_tags = []", :level=>:debug, :file=>"logstash/config/mixin.rb", :line=>"111", :method=>"config_init"}
{:timestamp=>"2016-01-15T23:12:31.297000+0100", :message=>"config LogStash::Outputs::File/@codec = <LogStash::Codecs::Plain charset=>\"UTF-8\">", :level=>:debug, :file=>"logstash/config/mixin.rb", :line=>"111", :method=>"config_init"}
{:timestamp=>"2016-01-15T23:12:31.309000+0100", :message=>"config LogStash::Outputs::File/@workers = 1", :level=>:debug, :file=>"logstash/config/mixin.rb", :line=>"111", :method=>"config_init"}
{:timestamp=>"2016-01-15T23:12:31.312000+0100", :message=>"config LogStash::Outputs::File/@flush_interval = 2", :level=>:debug, :file=>"logstash/config/mixin.rb", :line=>"111", :method=>"config_init"}
{:timestamp=>"2016-01-15T23:12:31.331000+0100", :message=>"config LogStash::Outputs::File/@gzip = false", :level=>:debug, :file=>"logstash/config/mixin.rb", :line=>"111", :method=>"config_init"}
{:timestamp=>"2016-01-15T23:12:31.334000+0100", :message=>"config LogStash::Outputs::File/@filename_failure = \"_filepath_failures\"", :level=>:debug, :file=>"logstash/config/mixin.rb", :line=>"111", :method=>"config_init"}
{:timestamp=>"2016-01-15T23:12:31.364000+0100", :message=>"Starting tcp input listener", :address=>"0.0.0.0:35364", :level=>:info, :file=>"logstash/inputs/tcp.rb", :line=>"92", :method=>"register"}
{:timestamp=>"2016-01-15T23:12:31.425000+0100", :message=>"Pipeline started", :level=>:info, :file=>"logstash/pipeline.rb", :line=>"87", :method=>"run"}
{:timestamp=>"2016-01-15T23:13:53.014000+0100", :message=>"Accepted connection", :client=>"xx.xx.xx.xx:51272", :server=>"0.0.0.0:port", :level=>:debug, :file=>"logstash/inputs/tcp.rb", :line=>"146", :method=>"client_thread"}
{:timestamp=>"2016-01-15T23:13:53.025000+0100", :message=>"config LogStash::Codecs::Line/@charset = \"UTF-8\"", :level=>:debug, :file=>"logstash/config/mixin.rb", :line=>"111", :method=>"config_init"}

我可以使用netstat以及包含tcpdump事件的数据包查看客户端和服务器之间的连接。 /var/log/project归logstash用户所有。

但是,没有创建文件,没有写入文件,没有关于该文件的日志

2 个答案:

答案 0 :(得分:0)

我不确定问题是用TCP还是别的,但是从TCP切换到伐木工人的输入和输出工作得很好

答案 1 :(得分:0)

我知道这个问题已经很老了,但是我在回答或猜测的任何方式

问题可能是日志存储可能没有打开文件/ var / log / project / log的权限。

检查日志存储日志文件以获取日志存储应用程序。

之前我遇到过这个问题,那就是问题。