Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Be consistent with how logstash-output-redis handles host and port #24

Open
rcuza opened this issue Aug 21, 2015 · 1 comment
Open

Be consistent with how logstash-output-redis handles host and port #24

rcuza opened this issue Aug 21, 2015 · 1 comment
Labels

Comments

@rcuza
Copy link

rcuza commented Aug 21, 2015

As a logstash administrator, I want my configuration of logstash-input-redis to be consistent with logstash-output-redis as much as possible.

Problem

When I use the following output { } configuration for logstash-output-redis everything works:

  redis {
    port => "12345"
    host => "redis.example.com:12345"
    key => "logstash"
    data_type => "list"
  }

But the same configuration used on the inside { } configuration for logstash-input-redis does not work. The debug output shows the following:

Registering Redis {:identity=>"redis://@redis.example.com:12345:6379/0 list:logstash", :level=>:info, :file=>"logstash/inputs/redis.rb", :line=>"117", :method=>"register"}
Pipeline started {:level=>:info, :file=>"logstash/pipeline.rb", :line=>"87", :method=>"run"}
Logstash startup completed
A plugin had an unrecoverable error. Will restart this plugin.
  Plugin: <LogStash::Inputs::Redis host=>"redis.example.com:12345", key=>"logstash", data_type=>"list", debug=>false, codec=><LogStash::Codecs::JSON charset=>"UTF-8">, threads=>1, name=>"default", port=>6379, db=>0, timeout=>5, batch_count=>1>
  Error: initialize: name or service not known
  Exception: SocketError
  Stack: org/jruby/ext/socket/RubyTCPSocket.java:129:in `initialize'

Notice that it registers with redis://@redis.example.com:12345:6379/0, effectively treating the port as part of the host name.

The following code works in both places:

  redis {
    port => "12345"
    host => "redis.example.com"
    key => "logstash"
    data_type => "list"
  }

Solution

The output plugin has the following line: @current_host, @current_port = @host[@host_idx].split(':') Something similar can be done with the input plugin.

Both the output and the input plugins need to be tweaked because the error message and the debug messages do not consistently represent the port variable. For instance if I do not set the port variable, the output plugins says @port = 6379 even though it uses port 12345 to connect:

config LogStash::Outputs::Redis/@host = ["redis.example.com:123245"] {:level=>:debug, :file=>"logstash/config/mixin.rb", :line=>"112", :method=>"config_init"}
config LogStash::Outputs::Redis/@port = 6379 {:level=>:debug, :file=>"logstash/config/mixin.rb", :line=>"112", :method=>"config_init"}
@olgac
Copy link

olgac commented May 7, 2018

i got same error, because of cannot reach to redis.
be sure; logstash can reach to redis?
they should be in the same network!

Ahmet Vehbi Olgac

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants