diff --git a/docs/index.asciidoc b/docs/index.asciidoc index 9c95921..5fe1283 100644 --- a/docs/index.asciidoc +++ b/docs/index.asciidoc @@ -45,6 +45,7 @@ This plugin supports the following configuration options plus the <> |<>, one of `["list", "channel", "pattern_channel"]`|Yes | <> |<>|No | <> |<>|No +| <> |<>|No | <> |<>|Yes | <> |<>|No | <> |<>|No @@ -58,7 +59,7 @@ input plugins.   [id="plugins-{type}s-{plugin}-batch_count"] -===== `batch_count` +===== `batch_count` * Value type is <> * Default value is `125` @@ -66,7 +67,7 @@ input plugins. The number of events to return from Redis using EVAL. [id="plugins-{type}s-{plugin}-data_type"] -===== `data_type` +===== `data_type` * This is a required setting. * Value can be any of: `list`, `channel`, `pattern_channel` @@ -77,7 +78,7 @@ key. If `redis\_type` is `channel`, then we will SUBSCRIBE to the key. If `redis\_type` is `pattern_channel`, then we will PSUBSCRIBE to the key. [id="plugins-{type}s-{plugin}-db"] -===== `db` +===== `db` * Value type is <> * Default value is `0` @@ -85,15 +86,24 @@ If `redis\_type` is `pattern_channel`, then we will PSUBSCRIBE to the key. The Redis database number. [id="plugins-{type}s-{plugin}-host"] -===== `host` +===== `host` * Value type is <> * Default value is `"127.0.0.1"` The hostname of your Redis server. +id="plugins-{type}s-{plugin}-path"] +===== `path` + + * Value type is <> + * There is no default value for this setting. + * Path will override Host configuration if both specified. + +The unix socket path of your Redis server. + [id="plugins-{type}s-{plugin}-key"] -===== `key` +===== `key` * This is a required setting. * Value type is <> @@ -102,7 +112,7 @@ The hostname of your Redis server. The name of a Redis list or channel. [id="plugins-{type}s-{plugin}-password"] -===== `password` +===== `password` * Value type is <> * There is no default value for this setting. @@ -110,7 +120,7 @@ The name of a Redis list or channel. Password to authenticate with. There is no authentication by default. [id="plugins-{type}s-{plugin}-port"] -===== `port` +===== `port` * Value type is <> * Default value is `6379` @@ -118,7 +128,7 @@ Password to authenticate with. There is no authentication by default. The port to connect on. [id="plugins-{type}s-{plugin}-threads"] -===== `threads` +===== `threads` * Value type is <> * Default value is `1` @@ -126,7 +136,7 @@ The port to connect on. [id="plugins-{type}s-{plugin}-timeout"] -===== `timeout` +===== `timeout` * Value type is <> * Default value is `5` @@ -136,4 +146,4 @@ Initial connection timeout in seconds. [id="plugins-{type}s-{plugin}-common-options"] -include::{include_path}/{type}.asciidoc[] \ No newline at end of file +include::{include_path}/{type}.asciidoc[] diff --git a/lib/logstash/inputs/redis.rb b/lib/logstash/inputs/redis.rb index 203f854..fe4f3af 100644 --- a/lib/logstash/inputs/redis.rb +++ b/lib/logstash/inputs/redis.rb @@ -29,6 +29,10 @@ module LogStash module Inputs class Redis < LogStash::Inputs::Threadable # The port to connect on. config :port, :validate => :number, :default => 6379 + # The unix socket path to connect on. Will override host and port if defined. + # There is no unix socket path by default. + config :path, :validate => :string + # The Redis database number. config :db, :validate => :number, :default => 0 @@ -68,7 +72,7 @@ def new_redis_instance end def register - @redis_url = "redis://#{@password}@#{@host}:#{@port}/#{@db}" + @redis_url = @path.nil? ? "redis://#{@password}@#{@host}:#{@port}/#{@db}" : "#{@password}@#{@path}/#{@db}" @redis_builder ||= method(:internal_redis_builder) @@ -114,13 +118,25 @@ def is_list_type? # private def redis_params - { - :host => @host, - :port => @port, + if @path.nil? + connectionParams = { + :host => @host, + :port => @port + } + else + @logger.warn("Parameter 'path' is set, ignoring parameters: 'host' and 'port'") + connectionParams = { + :path => @path + } + end + + baseParams = { :timeout => @timeout, :db => @db, :password => @password.nil? ? nil : @password.value } + + return connectionParams.merge(baseParams) end # private