logstash-output-elasticsearch 10.2.1-java → 10.2.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 +4 -4
- data/CHANGELOG.md +3 -0
- data/docs/index.asciidoc +7 -2
- data/lib/logstash/outputs/elasticsearch/common.rb +5 -2
- data/logstash-output-elasticsearch.gemspec +1 -1
- data/spec/es_spec_helper.rb +12 -2
- data/spec/integration/outputs/compressed_indexing_spec.rb +2 -3
- data/spec/integration/outputs/index_spec.rb +2 -3
- data/spec/integration/outputs/retry_spec.rb +2 -2
- data/spec/unit/outputs/elasticsearch_spec.rb +38 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cee8d8a64a98ebc0e90746c1e84323fbe842ae0afdbf072e530b50cbb4b27950
|
4
|
+
data.tar.gz: 2b24860b48ef18b5c28cfc9b62990ecc90bd202269b309b681181e0c18b9bae6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 07c5415be2991fdfed79ecbd27027272f9a59a72797b6a1efc0de021f9ae876e8949374a307da9663c3c36c6603ed8a8e4aedcf0009076354d0fe079572e2330
|
7
|
+
data.tar.gz: 47e5ca4b87727558c5c99a2e7134de3f7fec886b46f007f4af287e4ba91ee1e9fa71d578428da2149e42d2dce37ae0dd79f84684fb824f50004ed23b13345e1b
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
## 10.2.2
|
2
|
+
- Fixed 8.x type removal compatibility issue [#892](https://github.com/logstash-plugins/logstash-output-elasticsearch/pull/892)
|
3
|
+
|
1
4
|
## 10.2.1
|
2
5
|
- Fixed wording and corrected option in documentation [#881](https://github.com/logstash-plugins/logstash-output-elasticsearch/pull/881) [#883](https://github.com/logstash-plugins/logstash-output-elasticsearch/pull/883)
|
3
6
|
|
data/docs/index.asciidoc
CHANGED
@@ -298,13 +298,18 @@ Elasticsearch with the same ID.
|
|
298
298
|
* There is no default value for this setting.
|
299
299
|
* This option is deprecated
|
300
300
|
|
301
|
-
|
301
|
+
NOTE: This option is deprecated due to the https://www.elastic.co/guide/en/elasticsearch/reference/6.0/removal-of-types.html[removal of types in Elasticsearch 6.0].
|
302
302
|
It will be removed in the next major version of Logstash.
|
303
|
+
|
304
|
+
NOTE: This value is ignored and has no effect for Elasticsearch clusters `8.x`.
|
305
|
+
|
303
306
|
This sets the document type to write events to. Generally you should try to write only
|
304
307
|
similar events to the same 'type'. String expansion `%{foo}` works here.
|
305
308
|
If you don't set a value for this option:
|
306
309
|
|
307
|
-
- for elasticsearch clusters
|
310
|
+
- for elasticsearch clusters 8.x: no value will be used;
|
311
|
+
- for elasticsearch clusters 7.x: the value of '_doc' will be used;
|
312
|
+
- for elasticsearch clusters 6.x: the value of 'doc' will be used;
|
308
313
|
- for elasticsearch clusters 5.x and below: the event's 'type' field will be used, if the field is not present the value of 'doc' will be used.
|
309
314
|
|
310
315
|
[id="plugins-{type}s-{plugin}-failure_type_logging_whitelist"]
|
@@ -70,10 +70,11 @@ module LogStash; module Outputs; class ElasticSearch;
|
|
70
70
|
params = {
|
71
71
|
:_id => @document_id ? event.sprintf(@document_id) : nil,
|
72
72
|
:_index => event.sprintf(@index),
|
73
|
-
:_type => get_event_type(event),
|
74
73
|
routing_field_name => @routing ? event.sprintf(@routing) : nil
|
75
74
|
}
|
76
75
|
|
76
|
+
params[:_type] = get_event_type(event) if client.maximum_seen_major_version < 8
|
77
|
+
|
77
78
|
if @pipeline
|
78
79
|
params[:pipeline] = event.sprintf(@pipeline)
|
79
80
|
end
|
@@ -276,8 +277,10 @@ module LogStash; module Outputs; class ElasticSearch;
|
|
276
277
|
event.get("type") || DEFAULT_EVENT_TYPE_ES6
|
277
278
|
elsif client.maximum_seen_major_version == 6
|
278
279
|
DEFAULT_EVENT_TYPE_ES6
|
279
|
-
|
280
|
+
elsif client.maximum_seen_major_version == 7
|
280
281
|
DEFAULT_EVENT_TYPE_ES7
|
282
|
+
else
|
283
|
+
nil
|
281
284
|
end
|
282
285
|
end
|
283
286
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'logstash-output-elasticsearch'
|
3
|
-
s.version = '10.2.
|
3
|
+
s.version = '10.2.2'
|
4
4
|
s.licenses = ['apache-2.0']
|
5
5
|
s.summary = "Stores logs in Elasticsearch"
|
6
6
|
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"
|
data/spec/es_spec_helper.rb
CHANGED
@@ -27,13 +27,24 @@ module ESHelper
|
|
27
27
|
end
|
28
28
|
|
29
29
|
def doc_type
|
30
|
-
if ESHelper.es_version_satisfies?(">=
|
30
|
+
if ESHelper.es_version_satisfies?(">=8")
|
31
|
+
nil
|
32
|
+
elsif ESHelper.es_version_satisfies?(">=7")
|
31
33
|
"_doc"
|
32
34
|
else
|
33
35
|
"doc"
|
34
36
|
end
|
35
37
|
end
|
36
38
|
|
39
|
+
def self.action_for_version(action)
|
40
|
+
action_params = action[1]
|
41
|
+
if ESHelper.es_version_satisfies?(">=8")
|
42
|
+
action_params.delete(:_type)
|
43
|
+
end
|
44
|
+
action[1] = action_params
|
45
|
+
action
|
46
|
+
end
|
47
|
+
|
37
48
|
def todays_date
|
38
49
|
Time.now.strftime("%Y.%m.%d")
|
39
50
|
end
|
@@ -82,7 +93,6 @@ module ESHelper
|
|
82
93
|
end
|
83
94
|
end
|
84
95
|
|
85
|
-
|
86
96
|
def self.es_version_satisfies?(*requirement)
|
87
97
|
es_version = RSpec.configuration.filter[:es_version] || ENV['ES_VERSION'] || ENV['ELASTIC_STACK_VERSION']
|
88
98
|
if es_version.nil?
|
@@ -50,9 +50,8 @@ if ESHelper.es_version_satisfies?(">= 5")
|
|
50
50
|
response = http_client.get("#{index_url}/_search?q=*&size=1000")
|
51
51
|
result = LogStash::Json.load(response.body)
|
52
52
|
result["hits"]["hits"].each do |doc|
|
53
|
-
if ESHelper.es_version_satisfies?(">= 6")
|
54
|
-
|
55
|
-
end
|
53
|
+
expect(doc["_type"]).to eq(type) if ESHelper.es_version_satisfies?(">= 6", "< 8")
|
54
|
+
expect(doc).not_to include("_type") if ESHelper.es_version_satisfies?(">= 8")
|
56
55
|
expect(doc["_index"]).to eq(index)
|
57
56
|
end
|
58
57
|
end
|
@@ -80,9 +80,8 @@ describe "indexing" do
|
|
80
80
|
response = http_client.get("#{index_url}/_search?q=*&size=1000")
|
81
81
|
result = LogStash::Json.load(response.body)
|
82
82
|
result["hits"]["hits"].each do |doc|
|
83
|
-
if ESHelper.es_version_satisfies?(">= 6")
|
84
|
-
|
85
|
-
end
|
83
|
+
expect(doc["_type"]).to eq(type) if ESHelper.es_version_satisfies?(">= 6", "< 8")
|
84
|
+
expect(doc).not_to include("_type") if ESHelper.es_version_satisfies?(">= 8")
|
86
85
|
expect(doc["_index"]).to eq(index)
|
87
86
|
end
|
88
87
|
end
|
@@ -4,9 +4,9 @@ require_relative "../../../spec/es_spec_helper"
|
|
4
4
|
describe "failures in bulk class expected behavior", :integration => true do
|
5
5
|
let(:template) { '{"template" : "not important, will be updated by :index"}' }
|
6
6
|
let(:event1) { LogStash::Event.new("somevalue" => 100, "@timestamp" => "2014-11-17T20:37:17.223Z", "@metadata" => {"retry_count" => 0}) }
|
7
|
-
let(:action1) { ["index", {:_id=>nil, routing_field_name =>nil, :_index=>"logstash-2014.11.17", :_type=> doc_type }, event1] }
|
7
|
+
let(:action1) { ESHelper.action_for_version(["index", {:_id=>nil, routing_field_name =>nil, :_index=>"logstash-2014.11.17", :_type=> doc_type }, event1]) }
|
8
8
|
let(:event2) { LogStash::Event.new("geoip" => { "location" => [ 0.0, 0.0] }, "@timestamp" => "2014-11-17T20:37:17.223Z", "@metadata" => {"retry_count" => 0}) }
|
9
|
-
let(:action2) { ["index", {:_id=>nil, routing_field_name =>nil, :_index=>"logstash-2014.11.17", :_type=> doc_type }, event2] }
|
9
|
+
let(:action2) { ESHelper.action_for_version(["index", {:_id=>nil, routing_field_name =>nil, :_index=>"logstash-2014.11.17", :_type=> doc_type }, event2]) }
|
10
10
|
let(:invalid_event) { LogStash::Event.new("geoip" => { "location" => "notlatlon" }, "@timestamp" => "2014-11-17T20:37:17.223Z") }
|
11
11
|
|
12
12
|
def mock_actions_with_response(*resp)
|
@@ -76,6 +76,44 @@ describe LogStash::Outputs::ElasticSearch do
|
|
76
76
|
end
|
77
77
|
end
|
78
78
|
|
79
|
+
describe "building an event action tuple" do
|
80
|
+
context "for 7.x elasticsearch clusters" do
|
81
|
+
let(:maximum_seen_major_version) { 7 }
|
82
|
+
it "should include '_type'" do
|
83
|
+
action_tuple = subject.send(:event_action_tuple, LogStash::Event.new("type" => "foo"))
|
84
|
+
action_params = action_tuple[1]
|
85
|
+
expect(action_params).to include(:_type => "_doc")
|
86
|
+
end
|
87
|
+
|
88
|
+
context "with 'document type set'" do
|
89
|
+
let(:options) { super.merge("document_type" => "bar")}
|
90
|
+
it "should get the event type from the 'document_type' setting" do
|
91
|
+
action_tuple = subject.send(:event_action_tuple, LogStash::Event.new("type" => "foo"))
|
92
|
+
action_params = action_tuple[1]
|
93
|
+
expect(action_params).to include(:_type => "bar")
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
context "for 8.x elasticsearch clusters" do
|
99
|
+
let(:maximum_seen_major_version) { 8 }
|
100
|
+
it "should not include '_type'" do
|
101
|
+
action_tuple = subject.send(:event_action_tuple, LogStash::Event.new("type" => "foo"))
|
102
|
+
action_params = action_tuple[1]
|
103
|
+
expect(action_params).not_to include(:_type)
|
104
|
+
end
|
105
|
+
|
106
|
+
context "with 'document type set'" do
|
107
|
+
let(:options) { super.merge("document_type" => "bar")}
|
108
|
+
it "should not include '_type'" do
|
109
|
+
action_tuple = subject.send(:event_action_tuple, LogStash::Event.new("type" => "foo"))
|
110
|
+
action_params = action_tuple[1]
|
111
|
+
expect(action_params).not_to include(:_type)
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
79
117
|
describe "with auth" do
|
80
118
|
let(:user) { "myuser" }
|
81
119
|
let(:password) { ::LogStash::Util::Password.new("mypassword") }
|
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: 10.2.
|
4
|
+
version: 10.2.2
|
5
5
|
platform: java
|
6
6
|
authors:
|
7
7
|
- Elastic
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-11-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|