Skip to content

Commit

Permalink
adds sniffing option for transport protocol
Browse files Browse the repository at this point in the history
  • Loading branch information
jsvd authored and jordansissel committed Dec 22, 2014
1 parent e5b41ca commit 6860bd6
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/logstash/outputs/elasticsearch.rb
Expand Up @@ -200,6 +200,10 @@ class LogStash::Outputs::ElasticSearch < LogStash::Outputs::Base
# Set the truststore password
config :truststore_password, :validate => :password

# Enable cluster sniffing (transport only)
# Asks host for the list of all cluster nodes and adds them to the hosts list
config :sniffing, :validate => :boolean, :default => false

# helper function to replace placeholders
# in index names to wildcards
# example:
Expand All @@ -223,6 +227,7 @@ def register
client_settings["cluster.name"] = @cluster if @cluster
client_settings["network.host"] = @bind_host if @bind_host
client_settings["transport.tcp.port"] = @bind_port if @bind_port
client_settings["client.transport.sniff"] = @sniffing

if @node_name
client_settings["node.name"] = @node_name
Expand Down
28 changes: 28 additions & 0 deletions spec/outputs/elasticsearch_spec.rb
Expand Up @@ -521,3 +521,31 @@ def settings_with_index(index)
end
end
end

describe "outputs/elasticsearch" do
require 'elasticsearch'

it "set sniffing in transport mode" do

config = %q[
output {
elasticsearch {
host => "node01"
protocol => "transport"
sniffing => true
}
}
]


settings_class = org.elasticsearch.common.settings.ImmutableSettings
settings = settings_class.settingsBuilder

expect(settings_class).to receive(:settingsBuilder).and_return(settings)

pipeline = LogStash::Pipeline.new(config)
pipeline.run

expect(settings.build.getAsMap["client.transport.sniff"]).to eq("true")
end
end

0 comments on commit 6860bd6

Please sign in to comment.