Skip to content

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

Open
@rcuza

Description

@rcuza

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"}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions