diff --git a/.ci/logstash-run.sh b/.ci/logstash-run.sh index d0fb854..e7e81e1 100755 --- a/.ci/logstash-run.sh +++ b/.ci/logstash-run.sh @@ -21,7 +21,7 @@ wait_for_es() { } if [[ "$INTEGRATION" != "true" ]]; then - bundle exec rspec -fd spec/inputs -t ~integration -t ~secure_integration + jruby -rbundler/setup -S rspec -fd --tag ~integration --tag ~secure_integration spec/inputs else if [[ "$SECURE_INTEGRATION" == "true" ]]; then extra_tag_args="--tag secure_integration" @@ -29,5 +29,5 @@ else extra_tag_args="--tag ~secure_integration --tag integration" fi wait_for_es - bundle exec rspec -fd $extra_tag_args --tag es_version:$ELASTIC_STACK_VERSION spec/inputs/integration + jruby -rbundler/setup -S rspec -fd $extra_tag_args --tag es_version:$ELASTIC_STACK_VERSION spec/inputs/integration fi diff --git a/.travis.yml b/.travis.yml index a2283ac..998e838 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,10 +6,12 @@ before_install: env: - INTEGRATION=false ELASTIC_STACK_VERSION=7.x +- INTEGRATION=false ELASTIC_STACK_VERSION=8.x - INTEGRATION=false ELASTIC_STACK_VERSION=7.x SNAPSHOT=true - INTEGRATION=false ELASTIC_STACK_VERSION=8.x SNAPSHOT=true +- INTEGRATION=false ELASTIC_STACK_VERSION=7.16.3 MANTICORE_VERSION=0.7.1 ELASTICSEARCH_VERSION=7.15.0 - INTEGRATION=true ELASTIC_STACK_VERSION=7.x -- INTEGRATION=true ELASTIC_STACK_VERSION=7.x SNAPSHOT=true -- INTEGRATION=true ELASTIC_STACK_VERSION=8.x SNAPSHOT=true -- SECURE_INTEGRATION=true INTEGRATION=true ELASTIC_STACK_VERSION=7.x -- SECURE_INTEGRATION=true INTEGRATION=true ELASTIC_STACK_VERSION=7.15.0 +- INTEGRATION=true ELASTIC_STACK_VERSION=7.x SNAPSHOT=true LOG_LEVEL=info +- INTEGRATION=true ELASTIC_STACK_VERSION=8.x SNAPSHOT=true LOG_LEVEL=info +- SECURE_INTEGRATION=true INTEGRATION=true ELASTIC_STACK_VERSION=7.x LOG_LEVEL=info +- SECURE_INTEGRATION=true INTEGRATION=true ELASTIC_STACK_VERSION=7.15.0 MANTICORE_VERSION=0.7.1 ELASTICSEARCH_VERSION=7.14.1 LOG_LEVEL=info diff --git a/CHANGELOG.md b/CHANGELOG.md index 693ae49..2251e18 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +## 4.12.2 + - Fix: hosts => "es_host:port" regression [#168](https://github.com/logstash-plugins/logstash-input-elasticsearch/pull/168) + ## 4.12.1 - Fixed too_long_frame_exception by passing scroll_id in the body [#159](https://github.com/logstash-plugins/logstash-input-elasticsearch/pull/159) diff --git a/Gemfile b/Gemfile index 32cc6fb..85bf037 100644 --- a/Gemfile +++ b/Gemfile @@ -9,3 +9,6 @@ if Dir.exist?(logstash_path) && use_logstash_source gem 'logstash-core', :path => "#{logstash_path}/logstash-core" gem 'logstash-core-plugin-api', :path => "#{logstash_path}/logstash-core-plugin-api" end + +gem 'manticore', ENV['MANTICORE_VERSION'] if ENV['MANTICORE_VERSION'] +gem 'elasticsearch', ENV['ELASTICSEARCH_VERSION'] if ENV['ELASTICSEARCH_VERSION'] diff --git a/lib/logstash/inputs/elasticsearch.rb b/lib/logstash/inputs/elasticsearch.rb index 851ebd7..1319d7f 100644 --- a/lib/logstash/inputs/elasticsearch.rb +++ b/lib/logstash/inputs/elasticsearch.rb @@ -386,13 +386,13 @@ def setup_ssl def setup_hosts @hosts = Array(@hosts).map { |host| host.to_s } # potential SafeURI#to_s - if @ssl - @hosts.map do |h| - host, port = h.split(":") - { :host => host, :scheme => 'https', :port => port } + @hosts.map do |h| + if h.start_with?('http:', 'https:') + h + else + host, port = h.split(':') + { host: host, port: port, scheme: (@ssl ? 'https' : 'http') } end - else - @hosts end end diff --git a/logstash-input-elasticsearch.gemspec b/logstash-input-elasticsearch.gemspec index 5570314..2cd5bfc 100644 --- a/logstash-input-elasticsearch.gemspec +++ b/logstash-input-elasticsearch.gemspec @@ -1,7 +1,7 @@ Gem::Specification.new do |s| s.name = 'logstash-input-elasticsearch' - s.version = '4.12.1' + s.version = '4.12.2' s.licenses = ['Apache License (2.0)'] s.summary = "Reads query results from an Elasticsearch cluster" s.description = "This gem is a Logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/logstash-plugin install gemname. This gem is not a stand-alone program" diff --git a/spec/inputs/integration/elasticsearch_spec.rb b/spec/inputs/integration/elasticsearch_spec.rb index e7c1132..8edc5d8 100644 --- a/spec/inputs/integration/elasticsearch_spec.rb +++ b/spec/inputs/integration/elasticsearch_spec.rb @@ -6,13 +6,19 @@ describe LogStash::Inputs::Elasticsearch do - let(:config) { { 'hosts' => [ESHelper.get_host_port], + SECURE_INTEGRATION = ENV['SECURE_INTEGRATION'].eql? 'true' + + let(:config) { { 'hosts' => ["http#{SECURE_INTEGRATION ? 's' : nil}://#{ESHelper.get_host_port}"], 'index' => 'logs', 'query' => '{ "query": { "match": { "message": "Not found"} }}' } } let(:plugin) { described_class.new(config) } let(:event) { LogStash::Event.new({}) } let(:client_options) { Hash.new } + let(:user) { ENV['ELASTIC_USER'] || 'simpleuser' } + let(:password) { ENV['ELASTIC_PASSWORD'] || 'abc123' } + let(:ca_file) { "spec/fixtures/test_certs/ca.crt" } + before(:each) do @es = ESHelper.get_client(client_options) # Delete all templates first. @@ -45,7 +51,7 @@ end end - describe 'against an unsecured elasticsearch', :integration => true do + describe 'against an unsecured elasticsearch', integration: true do before(:each) do plugin.register end @@ -53,10 +59,7 @@ it_behaves_like 'an elasticsearch index plugin' end - describe 'against a secured elasticsearch', :secure_integration => true do - let(:user) { ENV['ELASTIC_USER'] || 'simpleuser' } - let(:password) { ENV['ELASTIC_PASSWORD'] || 'abc123' } - let(:ca_file) { "spec/fixtures/test_certs/ca.crt" } + describe 'against a secured elasticsearch', secure_integration: true do let(:client_options) { { :ca_file => ca_file, :user => user, :password => password } } @@ -78,4 +81,28 @@ end end + + context 'setting host:port', integration: true do + + let(:config) do + super().merge "hosts" => [ESHelper.get_host_port] + end + + it_behaves_like 'an elasticsearch index plugin' + + end + + context 'setting host:port (and ssl)', secure_integration: true do + + let(:client_options) { { :ca_file => ca_file, :user => user, :password => password } } + + let(:config) do + config = super().merge "hosts" => [ESHelper.get_host_port] + config.merge('user' => user, 'password' => password, 'ssl' => true, 'ca_file' => ca_file) + end + + it_behaves_like 'an elasticsearch index plugin' + + end + end