Skip to content

Commit 86d8dd1

Browse files
committed
change redis sentinel config format
1 parent efa40ff commit 86d8dd1

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

lib/logstash/inputs/redis.rb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ module LogStash module Inputs class Redis < LogStash::Inputs::Threadable
2828
# The hostname of your Redis server.
2929
config :host, :validate => :string, :default => "127.0.0.1"
3030

31-
# The hostnames of your sentinel servers.
31+
# The hostnames and ports of your sentinel servers.
3232
config :sentinel_hosts, :validate => :array
3333

3434
# The connection URLs of your cluster servers.
@@ -37,16 +37,13 @@ module LogStash module Inputs class Redis < LogStash::Inputs::Threadable
3737
# The port to connect on.
3838
config :port, :validate => :number, :default => 6379
3939

40-
# The sentinel port to connect on.
41-
config :sentinel_port, :validate => :number, :default => 26379
42-
4340
# The name of the sentinel master to connect to.
4441
config :sentinel_master_name, :validate => :string, :default => "mymaster"
4542

4643
# SSL
4744
config :ssl, :validate => :boolean, :default => false
4845

49-
# The unix socket path to connect on. Will override host and port and sentinel_hosts and sentinel_port and cluster_hosts if defined.
46+
# The unix socket path to connect on. Will override host and port and sentinel_hosts and cluster_hosts if defined.
5047
# There is no unix socket path by default.
5148
config :path, :validate => :string
5249

@@ -81,7 +78,7 @@ def register
8178
elsif !@cluster_hosts.nil?
8279
@redis_url = "#{@password}@#{@cluster_hosts.map { |h| "#{h}" }.join(',')}/#{@db}"
8380
elsif !@sentinel_hosts.nil?
84-
@redis_url = "redis://#{@password}@#{@sentinel_master_name}:#{@port}/#{@db}"
81+
@redis_url = "redis://#{@password}@#{@sentinel_master_name}/#{@db}"
8582
else
8683
@redis_url = "redis://#{@password}@#{@host}:#{@port}/#{@db}"
8784
end
@@ -141,7 +138,10 @@ def redis_params
141138
:nodes => cluster_hosts,
142139
}
143140
elsif !@sentinel_hosts.nil?
144-
hosts = @sentinel_hosts.map { |sentinel_host| { host: sentinel_host, port: @sentinel_port } }
141+
hosts = @sentinel_hosts.map do |sentinel_host|
142+
host, port = sentinel_host.split(':', 2)
143+
{ host: host, port: port ? port.to_i : 26379 }
144+
end
145145
params = {
146146
:name => @sentinel_master_name,
147147
:sentinels => hosts,

0 commit comments

Comments
 (0)