logstash-output-elasticsearch 5.1.1-java → 5.1.2-java

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7460d82e37205595de8bb7fb7f4a7a9cfdeb6817
4
- data.tar.gz: 361096568a9c9c0a5fa58d9b495b761f19312b29
3
+ metadata.gz: d467502b3717a7e37fb897d6efc9fb690d03f045
4
+ data.tar.gz: 3f73d6fa34b9bc65bce91210bf45dd3fb2e935c1
5
5
  SHA512:
6
- metadata.gz: ab9ddc3ff94a908c473e79869a3fd2b41682c7facbab54183c40294119b5c23907156a16f677c3181b5f8519670843cc380cd08528b13366f4ce8db3e5837104
7
- data.tar.gz: 4eb8391a5fb0df0666a30afabb67ba27e913dfb996e03e0a24edb9e8c73cb8214bfd1e686373385bed0d636034d812207e8930f036d6ff57b001a7c18d3378d7
6
+ metadata.gz: 7daa79d6457e3fe835cad7603a84016ef1964b4d836fbe766139c3a6a2a0438af0c31c11ca8861150198fb7cec2d362028fe3b379e271d9db7ef3f5d7e2d6ab7
7
+ data.tar.gz: fae281ebd446f93f4cdbf9785143cfa0d3294d9b9b67d17098b60f8139f4903f0abeddb379e2e25e6406335e8e33291148d3d76e58b91da58581b91503f9a511
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 5.1.2
2
+ - Hide credentials in exceptions and log messages ([#482](https://github.com/logstash-plugins/logstash-output-elasticsearch/issues/482))
3
+ - [internal] Remove dependency on longshoreman project
4
+
1
5
  ## 5.1.1
2
6
  - Hide user and password from the URL logged during sniffing process.
3
7
 
@@ -208,7 +208,8 @@ module LogStash; module Outputs; class ElasticSearch;
208
208
  retry unless @stopping.true?
209
209
  rescue ::LogStash::Outputs::ElasticSearch::HttpClient::Pool::BadResponseCodeError => e
210
210
  if RETRYABLE_CODES.include?(e.response_code)
211
- log_hash = {:code => e.response_code, :url => e.url}
211
+ safe_url = ::LogStash::Outputs::ElasticSearch::SafeURL.without_credentials(e.url)
212
+ log_hash = {:code => e.response_code, :url => safe_url}
212
213
  log_hash[:body] = e.body if @logger.debug? # Generally this is too verbose
213
214
  @logger.error("Attempted to send a bulk request to elasticsearch but received a bad HTTP response code!", log_hash)
214
215
 
@@ -8,7 +8,7 @@
8
8
  "_all" : {"enabled" : true, "omit_norms" : true},
9
9
  "dynamic_templates" : [ {
10
10
  "message_field" : {
11
- "match" : "message",
11
+ "path_match" : "message",
12
12
  "match_mapping_type" : "string",
13
13
  "mapping" : {
14
14
  "type" : "string", "index" : "analyzed", "omit_norms" : true,
@@ -1,5 +1,6 @@
1
1
  {
2
2
  "template" : "logstash-*",
3
+ "version" : 50001,
3
4
  "settings" : {
4
5
  "index.refresh_interval" : "5s"
5
6
  },
@@ -8,11 +9,11 @@
8
9
  "_all" : {"enabled" : true, "norms" : false},
9
10
  "dynamic_templates" : [ {
10
11
  "message_field" : {
11
- "match" : "message",
12
+ "path_match" : "message",
12
13
  "match_mapping_type" : "string",
13
14
  "mapping" : {
14
- "type" : "string", "index" : "analyzed", "norms" : false,
15
- "fielddata" : { "format" : "disabled" }
15
+ "type" : "text",
16
+ "norms" : false
16
17
  }
17
18
  }
18
19
  }, {
@@ -184,7 +184,8 @@ module LogStash; module Outputs; class ElasticSearch;
184
184
  end
185
185
 
186
186
  if path && url.path && url.path != "/" && url.path != ''
187
- raise LogStash::ConfigurationError, "A path '#{url.path}' has been explicitly specified in the url '#{url}', but you also specified a path of '#{path}'. This is probably a mistake, please remove one setting."
187
+ safe_url = ::LogStash::Outputs::ElasticSearch::SafeURL.without_credentials(url)
188
+ raise LogStash::ConfigurationError, "A path '#{url.path}' has been explicitly specified in the url '#{safe_url}', but you also specified a path of '#{path}'. This is probably a mistake, please remove one setting."
188
189
  end
189
190
 
190
191
  if path
@@ -194,14 +194,16 @@ module LogStash; module Outputs; class ElasticSearch; class HttpClient;
194
194
  def resurrect_dead!
195
195
  # Try to keep locking granularity low such that we don't affect IO...
196
196
  @state_mutex.synchronize { @url_info.select {|url,meta| meta[:dead] } }.each do |url,meta|
197
+ safe_url = ::LogStash::Outputs::ElasticSearch::SafeURL.without_credentials(url)
197
198
  begin
198
- @logger.info("Checking url #{url} with path #{@healthcheck_path} to see if node resurrected")
199
+ logger.info("Running health check to see if an Elasticsearch connection is working",
200
+ url: safe_url, healthcheck_path: @healthcheck_path)
199
201
  perform_request_to_url(url, "HEAD", @healthcheck_path)
200
202
  # If no exception was raised it must have succeeded!
201
- logger.warn("Resurrected connection to dead ES instance at #{url}")
203
+ logger.warn("Restored connection to ES instance", :url => safe_url)
202
204
  @state_mutex.synchronize { meta[:dead] = false }
203
205
  rescue HostUnreachableError => e
204
- logger.debug("Attempted to resurrect connection to dead ES instance at #{url}, got an error [#{e.class}] #{e.message}")
206
+ logger.debug("Attempted to resurrect connection to dead ES instance, but got an error.", url: safe_url, error_type: e.class, error: e.message)
205
207
  end
206
208
  end
207
209
  end
@@ -325,8 +327,9 @@ module LogStash; module Outputs; class ElasticSearch; class HttpClient;
325
327
  # In case a sniff happened removing the metadata just before there's nothing to mark
326
328
  # This is an extreme edge case, but it can happen!
327
329
  return unless meta
328
- logger.warn("Marking url as dead. Last error: [#{error.class}] #{error.message}",
329
- :url => url, :error_message => error.message, :error_class => error.class.name)
330
+ safe_url = ::LogStash::Outputs::ElasticSearch::SafeURL.without_credentials(url)
331
+ logger.warn("Marking url as dead.", :reason => error.message, :url => safe_url,
332
+ :error_message => error.message, :error_class => error.class.name)
330
333
  meta[:dead] = true
331
334
  meta[:last_error] = error
332
335
  meta[:last_errored_at] = Time.now
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
 
3
3
  s.name = 'logstash-output-elasticsearch'
4
- s.version = '5.1.1'
4
+ s.version = '5.1.2'
5
5
  s.licenses = ['apache-2.0']
6
6
  s.summary = "Logstash Output to Elasticsearch"
7
7
  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"
@@ -31,7 +31,6 @@ Gem::Specification.new do |s|
31
31
  end
32
32
 
33
33
  s.add_development_dependency 'logstash-devutils'
34
- s.add_development_dependency 'longshoreman'
35
34
  s.add_development_dependency 'flores'
36
35
  # Still used in some specs, we should remove this ASAP
37
36
  s.add_development_dependency 'elasticsearch'
@@ -1,30 +1,10 @@
1
1
  require "logstash/devutils/rspec/spec_helper"
2
2
  require "ftw"
3
- require "logstash/plugin"
4
- require "logstash/json"
5
- require "stud/try"
6
- require "longshoreman"
7
- require "logstash/outputs/elasticsearch"
8
3
  require 'elasticsearch'
9
4
 
10
- CONTAINER_NAME = "logstash-output-elasticsearch-#{rand(999).to_s}"
11
- CONTAINER_IMAGE = "elasticsearch"
12
- CONTAINER_TAG = "2.0"
13
-
14
- DOCKER_INTEGRATION = ENV["DOCKER_INTEGRATION"]
15
-
16
5
  module ESHelper
17
6
  def get_host_port
18
- addr = DOCKER_INTEGRATION ? Longshoreman.new.get_host_ip : "127.0.0.1"
19
- "#{addr}:#{get_port}"
20
- end
21
-
22
- def get_port
23
- return 9200 unless DOCKER_INTEGRATION
24
-
25
- container = Longshoreman::Container.new
26
- container.get(CONTAINER_NAME)
27
- container.rport(9200)
7
+ "127.0.0.1:9200"
28
8
  end
29
9
 
30
10
  def get_client
@@ -32,47 +12,6 @@ module ESHelper
32
12
  end
33
13
  end
34
14
 
35
-
36
15
  RSpec.configure do |config|
37
16
  config.include ESHelper
38
-
39
- if DOCKER_INTEGRATION
40
- # this :all hook gets run before every describe block that is tagged with :integration => true.
41
- config.before(:all, :integration => true) do
42
-
43
-
44
- # check if container exists already before creating new one.
45
- begin
46
- ls = Longshoreman::new
47
- ls.container.get(CONTAINER_NAME)
48
- rescue Docker::Error::NotFoundError
49
- scriptDir = File.expand_path File.dirname(__FILE__) + '/fixtures/scripts'
50
- Longshoreman.new("#{CONTAINER_IMAGE}:#{CONTAINER_TAG}", CONTAINER_NAME, {
51
- 'Cmd' => [ "-Des.script.inline=on", "-Des.script.indexed=on" ],
52
- 'HostConfig' => {
53
- 'Binds' => ["#{scriptDir}:/usr/share/elasticsearch/config/scripts"],
54
- 'PublishAllPorts' => true
55
- }
56
- })
57
- # TODO(talevy): verify ES is running instead of static timeout
58
- sleep 10
59
- end
60
- end
61
-
62
- # we want to do a final cleanup after all :integration runs,
63
- # but we don't want to clean up before the last block.
64
- # This is a final blind check to see if the ES docker container is running and
65
- # needs to be cleaned up. If no container can be found and/or docker is not
66
- # running on the system, we do nothing.
67
- config.after(:suite) do
68
- # only cleanup docker container if system has docker and the container is running
69
- begin
70
- ls = Longshoreman::new
71
- ls.container.get(CONTAINER_NAME)
72
- ls.cleanup
73
- rescue Docker::Error::NotFoundError, Excon::Errors::SocketError
74
- # do nothing
75
- end
76
- end
77
- end
78
17
  end
@@ -27,6 +27,7 @@ describe "index template expected behavior for 5.x", :integration => true, :vers
27
27
 
28
28
  subject.multi_receive([
29
29
  LogStash::Event.new("message" => "sample message here"),
30
+ LogStash::Event.new("somemessage" => { "message" => "sample nested message here" }),
30
31
  LogStash::Event.new("somevalue" => 100),
31
32
  LogStash::Event.new("somevalue" => 10),
32
33
  LogStash::Event.new("somevalue" => 1),
@@ -40,7 +41,7 @@ describe "index template expected behavior for 5.x", :integration => true, :vers
40
41
  # Wait or fail until everything's indexed.
41
42
  Stud::try(20.times) do
42
43
  r = @es.search
43
- insist { r["hits"]["total"] } == 7
44
+ insist { r["hits"]["total"] } == 8
44
45
  end
45
46
  end
46
47
 
@@ -60,11 +61,16 @@ describe "index template expected behavior for 5.x", :integration => true, :vers
60
61
  reject { values }.include?(1)
61
62
  end
62
63
 
63
- it "does not create .keyword field for the message field" do
64
+ it "does not create .keyword field for top-level message field" do
64
65
  results = @es.search(:q => "message.keyword:\"sample message here\"")
65
66
  insist { results["hits"]["total"] } == 0
66
67
  end
67
68
 
69
+ it "creates .keyword field for nested message fields" do
70
+ results = @es.search(:q => "somemessage.message.keyword:\"sample nested message here\"")
71
+ insist { results["hits"]["total"] } == 1
72
+ end
73
+
68
74
  it "creates .keyword field from any string field which is not_analyzed" do
69
75
  results = @es.search(:q => "country.keyword:\"us\"")
70
76
  insist { results["hits"]["total"] } == 1
@@ -26,6 +26,7 @@ describe "index template expected behavior", :integration => true, :version_less
26
26
 
27
27
  subject.multi_receive([
28
28
  LogStash::Event.new("message" => "sample message here"),
29
+ LogStash::Event.new("somemessage" => { "message" => "sample nested message here" }),
29
30
  LogStash::Event.new("somevalue" => 100),
30
31
  LogStash::Event.new("somevalue" => 10),
31
32
  LogStash::Event.new("somevalue" => 1),
@@ -39,7 +40,7 @@ describe "index template expected behavior", :integration => true, :version_less
39
40
  # Wait or fail until everything's indexed.
40
41
  Stud::try(20.times) do
41
42
  r = @es.search
42
- insist { r["hits"]["total"] } == 7
43
+ insist { r["hits"]["total"] } == 8
43
44
  end
44
45
  end
45
46
 
@@ -64,6 +65,11 @@ describe "index template expected behavior", :integration => true, :version_less
64
65
  insist { results["hits"]["total"] } == 0
65
66
  end
66
67
 
68
+ it "creates .raw field for nested message fields" do
69
+ results = @es.search(:q => "somemessage.message.raw:\"sample nested message here\"")
70
+ insist { results["hits"]["total"] } == 1
71
+ end
72
+
67
73
  it "creates .raw field from any string field which is not_analyzed" do
68
74
  results = @es.search(:q => "country.raw:\"us\"")
69
75
  insist { results["hits"]["total"] } == 1
@@ -48,7 +48,7 @@ describe LogStash::Outputs::ElasticSearch::TemplateManager do
48
48
  end
49
49
  end
50
50
  context "elasticsearch 5.x" do
51
- it "chooses the 2x template" do
51
+ it "chooses the 5x template" do
52
52
  expect(described_class.default_template_path("5")).to match(/elasticsearch-template-es5x.json/)
53
53
  end
54
54
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-output-elasticsearch
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.1.1
4
+ version: 5.1.2
5
5
  platform: java
6
6
  authors:
7
7
  - Elastic
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-09-13 00:00:00.000000000 Z
11
+ date: 2016-10-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement
@@ -126,20 +126,6 @@ dependencies:
126
126
  - - ">="
127
127
  - !ruby/object:Gem::Version
128
128
  version: '0'
129
- - !ruby/object:Gem::Dependency
130
- requirement: !ruby/object:Gem::Requirement
131
- requirements:
132
- - - ">="
133
- - !ruby/object:Gem::Version
134
- version: '0'
135
- name: longshoreman
136
- prerelease: false
137
- type: :development
138
- version_requirements: !ruby/object:Gem::Requirement
139
- requirements:
140
- - - ">="
141
- - !ruby/object:Gem::Version
142
- version: '0'
143
129
  - !ruby/object:Gem::Dependency
144
130
  requirement: !ruby/object:Gem::Requirement
145
131
  requirements: