logstash-filter-elasticsearch 3.16.1 → 3.17.0
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 +6 -0
- data/docs/index.asciidoc +11 -0
- data/lib/logstash/filters/elasticsearch/client.rb +5 -0
- data/lib/logstash/filters/elasticsearch.rb +5 -1
- data/logstash-filter-elasticsearch.gemspec +2 -2
- data/spec/filters/elasticsearch_spec.rb +30 -2
- metadata +12 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aaf8d73f069f6550d53c38b1a27f5444f77b774bbe62d66b7b7dd276be4125fc
|
4
|
+
data.tar.gz: 19b2d5030a25fd03c78baf5edb6b18a649cc0751fa02f38fdfd8a9959669b9bc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f3792d01a260e9dcada0ddc7df7aaebbfc1280025781f4c8f2640eaba3abd0d777982f31b794cd7e37b1ce9430bd1f2a60d73dc05ddb8fc0eedd778d9574f1c6
|
7
|
+
data.tar.gz: 0743bccc0a8da98dd91d697ab1b05e95fae2853fd24e8d6db6887ec7ad636de2ae970ff65e15d491388402c702d71adc2190b987a30e5ee2f30a39daf5014954
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
## 3.17.0
|
2
|
+
- Added support for custom headers [#190](https://github.com/logstash-plugins/logstash-filter-elasticsearch/pull/190)
|
3
|
+
|
4
|
+
## 3.16.2
|
5
|
+
- Add `x-elastic-product-origin` header to Elasticsearch requests [#185](https://github.com/logstash-plugins/logstash-filter-elasticsearch/pull/185)
|
6
|
+
|
1
7
|
## 3.16.1
|
2
8
|
- Version bump to pick up doc fix in [#172](https://github.com/logstash-plugins/logstash-filter-elasticsearch/pull/172)
|
3
9
|
|
data/docs/index.asciidoc
CHANGED
@@ -131,6 +131,7 @@ This plugin supports the following configuration options plus the <<plugins-{typ
|
|
131
131
|
| <<plugins-{type}s-{plugin}-ca_trusted_fingerprint>> |<<string,string>>|No
|
132
132
|
| <<plugins-{type}s-{plugin}-cloud_auth>> |<<password,password>>|No
|
133
133
|
| <<plugins-{type}s-{plugin}-cloud_id>> |<<string,string>>|No
|
134
|
+
| <<plugins-{type}s-{plugin}-custom_headers>> |<<hash,hash>>|No
|
134
135
|
| <<plugins-{type}s-{plugin}-docinfo_fields>> |<<hash,hash>>|No
|
135
136
|
| <<plugins-{type}s-{plugin}-enable_sort>> |<<boolean,boolean>>|No
|
136
137
|
| <<plugins-{type}s-{plugin}-fields>> |<<array,array>>|No
|
@@ -228,6 +229,16 @@ Cloud ID, from the Elastic Cloud web console. If set `hosts` should not be used.
|
|
228
229
|
For more info, check out the
|
229
230
|
{logstash-ref}/connecting-to-cloud.html[Logstash-to-Cloud documentation].
|
230
231
|
|
232
|
+
|
233
|
+
[id="plugins-{type}s-{plugin}-custom_headers"]
|
234
|
+
===== `custom_headers`
|
235
|
+
|
236
|
+
* Value type is <<hash,hash>>
|
237
|
+
* Default value is empty
|
238
|
+
|
239
|
+
Pass a set of key value pairs as the headers sent in each request to Elasticsearch.
|
240
|
+
These custom headers will override any headers previously set by the plugin such as the User Agent or Authorization headers.
|
241
|
+
|
231
242
|
[id="plugins-{type}s-{plugin}-docinfo_fields"]
|
232
243
|
===== `docinfo_fields`
|
233
244
|
|
@@ -12,6 +12,7 @@ module LogStash
|
|
12
12
|
|
13
13
|
BUILD_FLAVOR_SERVERLESS = 'serverless'.freeze
|
14
14
|
DEFAULT_EAV_HEADER = { "Elastic-Api-Version" => "2023-10-31" }.freeze
|
15
|
+
INTERNAL_ORIGIN_HEADER = { 'x-elastic-product-origin' => 'logstash-filter-elasticsearch'}.freeze
|
15
16
|
|
16
17
|
def initialize(logger, hosts, options = {})
|
17
18
|
user = options.fetch(:user, nil)
|
@@ -19,12 +20,16 @@ module LogStash
|
|
19
20
|
api_key = options.fetch(:api_key, nil)
|
20
21
|
proxy = options.fetch(:proxy, nil)
|
21
22
|
user_agent = options[:user_agent]
|
23
|
+
custom_headers = options[:custom_headers]
|
24
|
+
|
22
25
|
|
23
26
|
transport_options = { }
|
24
27
|
transport_options[:headers] = options.fetch(:serverless, false) ? DEFAULT_EAV_HEADER.dup : {}
|
25
28
|
transport_options[:headers].merge!(setup_basic_auth(user, password))
|
26
29
|
transport_options[:headers].merge!(setup_api_key(api_key))
|
27
30
|
transport_options[:headers].merge!({ 'user-agent' => "#{user_agent}" })
|
31
|
+
transport_options[:headers].merge!(INTERNAL_ORIGIN_HEADER)
|
32
|
+
transport_options[:headers].merge!(custom_headers) unless custom_headers.empty?
|
28
33
|
|
29
34
|
transport_options[:pool_max] = 1000
|
30
35
|
transport_options[:pool_max_per_route] = 100
|
@@ -33,6 +33,9 @@ class LogStash::Filters::Elasticsearch < LogStash::Filters::Base
|
|
33
33
|
# Array of fields to copy from old event (found via elasticsearch) into new event
|
34
34
|
config :fields, :validate => :array, :default => {}
|
35
35
|
|
36
|
+
# Custom headers for Elasticsearch requests
|
37
|
+
config :custom_headers, :validate => :hash, :default => {}
|
38
|
+
|
36
39
|
# Hash of docinfo fields to copy from old event (found via elasticsearch) into new event
|
37
40
|
config :docinfo_fields, :validate => :hash, :default => {}
|
38
41
|
|
@@ -269,7 +272,8 @@ class LogStash::Filters::Elasticsearch < LogStash::Filters::Base
|
|
269
272
|
:ssl => client_ssl_options,
|
270
273
|
:retry_on_failure => @retry_on_failure,
|
271
274
|
:retry_on_status => @retry_on_status,
|
272
|
-
:user_agent => prepare_user_agent
|
275
|
+
:user_agent => prepare_user_agent,
|
276
|
+
:custom_headers => @custom_headers
|
273
277
|
}
|
274
278
|
end
|
275
279
|
|
@@ -1,13 +1,13 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
|
3
3
|
s.name = 'logstash-filter-elasticsearch'
|
4
|
-
s.version = '3.
|
4
|
+
s.version = '3.17.0'
|
5
5
|
s.licenses = ['Apache License (2.0)']
|
6
6
|
s.summary = "Copies fields from previous log events in Elasticsearch to current events "
|
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"
|
8
8
|
s.authors = ["Elastic"]
|
9
9
|
s.email = 'info@elastic.co'
|
10
|
-
s.homepage = "
|
10
|
+
s.homepage = "https://elastic.co/logstash"
|
11
11
|
s.require_paths = ["lib"]
|
12
12
|
|
13
13
|
# Files
|
@@ -333,6 +333,30 @@ describe LogStash::Filters::Elasticsearch do
|
|
333
333
|
end
|
334
334
|
end
|
335
335
|
|
336
|
+
context "with custom headers" do
|
337
|
+
let(:config) do
|
338
|
+
{
|
339
|
+
"query" => "*",
|
340
|
+
"custom_headers" => { "Custom-Header-1" => "Custom Value 1", "Custom-Header-2" => "Custom Value 2" }
|
341
|
+
}
|
342
|
+
end
|
343
|
+
|
344
|
+
let(:plugin) { LogStash::Filters::Elasticsearch.new(config) }
|
345
|
+
let(:client_double) { double("client") }
|
346
|
+
let(:transport_double) { double("transport", options: { transport_options: { headers: config["custom_headers"] } }) }
|
347
|
+
|
348
|
+
before do
|
349
|
+
allow(plugin).to receive(:get_client).and_return(client_double)
|
350
|
+
allow(client_double).to receive(:client).and_return(transport_double)
|
351
|
+
end
|
352
|
+
|
353
|
+
it "sets custom headers" do
|
354
|
+
plugin.register
|
355
|
+
client = plugin.send(:get_client).client
|
356
|
+
expect(client.options[:transport_options][:headers]).to match(hash_including(config["custom_headers"]))
|
357
|
+
end
|
358
|
+
end
|
359
|
+
|
336
360
|
context "if query is on nested field" do
|
337
361
|
let(:config) do
|
338
362
|
{
|
@@ -644,7 +668,7 @@ describe LogStash::Filters::Elasticsearch do
|
|
644
668
|
end
|
645
669
|
end
|
646
670
|
|
647
|
-
describe "Elastic Api
|
671
|
+
describe "Elastic Api and Product Origin Headers" do
|
648
672
|
let(:config) { {"query" => "*"} }
|
649
673
|
let(:plugin) { described_class.new(config) }
|
650
674
|
let(:headers) {{'x-elastic-product' => 'Elasticsearch'}}
|
@@ -666,6 +690,8 @@ describe LogStash::Filters::Elasticsearch do
|
|
666
690
|
plugin.register
|
667
691
|
client = plugin.send(:get_client).client
|
668
692
|
expect( extract_transport(client).options[:transport_options][:headers] ).to match hash_including("Elastic-Api-Version" => "2023-10-31")
|
693
|
+
expect( extract_transport(client).options[:transport_options][:headers] )
|
694
|
+
.to match hash_including("x-elastic-product-origin" => "logstash-filter-elasticsearch")
|
669
695
|
end
|
670
696
|
end
|
671
697
|
|
@@ -676,10 +702,12 @@ describe LogStash::Filters::Elasticsearch do
|
|
676
702
|
expect_any_instance_of(Elasticsearch::Client).to receive(:perform_request).with(any_args).and_return(mock_resp)
|
677
703
|
end
|
678
704
|
|
679
|
-
it 'does not propagate header to es client' do
|
705
|
+
it 'does not propagate Elastic-Api-Version header to es client' do
|
680
706
|
plugin.register
|
681
707
|
client = plugin.send(:get_client).client
|
682
708
|
expect( extract_transport(client).options[:transport_options][:headers] ).to match hash_not_including("Elastic-Api-Version" => "2023-10-31")
|
709
|
+
expect( extract_transport(client).options[:transport_options][:headers] )
|
710
|
+
.to match hash_including("x-elastic-product-origin" => "logstash-filter-elasticsearch")
|
683
711
|
end
|
684
712
|
end
|
685
713
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logstash-filter-elasticsearch
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.17.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Elastic
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2025-01-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|
@@ -20,8 +20,8 @@ dependencies:
|
|
20
20
|
- !ruby/object:Gem::Version
|
21
21
|
version: '2.99'
|
22
22
|
name: logstash-core-plugin-api
|
23
|
-
prerelease: false
|
24
23
|
type: :runtime
|
24
|
+
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
26
26
|
requirements:
|
27
27
|
- - ">="
|
@@ -37,8 +37,8 @@ dependencies:
|
|
37
37
|
- !ruby/object:Gem::Version
|
38
38
|
version: 7.14.9
|
39
39
|
name: elasticsearch
|
40
|
-
prerelease: false
|
41
40
|
type: :runtime
|
41
|
+
prerelease: false
|
42
42
|
version_requirements: !ruby/object:Gem::Requirement
|
43
43
|
requirements:
|
44
44
|
- - ">="
|
@@ -51,8 +51,8 @@ dependencies:
|
|
51
51
|
- !ruby/object:Gem::Version
|
52
52
|
version: 0.7.1
|
53
53
|
name: manticore
|
54
|
-
prerelease: false
|
55
54
|
type: :runtime
|
55
|
+
prerelease: false
|
56
56
|
version_requirements: !ruby/object:Gem::Requirement
|
57
57
|
requirements:
|
58
58
|
- - ">="
|
@@ -65,8 +65,8 @@ dependencies:
|
|
65
65
|
- !ruby/object:Gem::Version
|
66
66
|
version: '1.0'
|
67
67
|
name: logstash-mixin-ca_trusted_fingerprint_support
|
68
|
-
prerelease: false
|
69
68
|
type: :runtime
|
69
|
+
prerelease: false
|
70
70
|
version_requirements: !ruby/object:Gem::Requirement
|
71
71
|
requirements:
|
72
72
|
- - "~>"
|
@@ -79,8 +79,8 @@ dependencies:
|
|
79
79
|
- !ruby/object:Gem::Version
|
80
80
|
version: '1.0'
|
81
81
|
name: logstash-mixin-normalize_config_support
|
82
|
-
prerelease: false
|
83
82
|
type: :runtime
|
83
|
+
prerelease: false
|
84
84
|
version_requirements: !ruby/object:Gem::Requirement
|
85
85
|
requirements:
|
86
86
|
- - "~>"
|
@@ -93,8 +93,8 @@ dependencies:
|
|
93
93
|
- !ruby/object:Gem::Version
|
94
94
|
version: '0.6'
|
95
95
|
name: cabin
|
96
|
-
prerelease: false
|
97
96
|
type: :development
|
97
|
+
prerelease: false
|
98
98
|
version_requirements: !ruby/object:Gem::Requirement
|
99
99
|
requirements:
|
100
100
|
- - "~>"
|
@@ -107,8 +107,8 @@ dependencies:
|
|
107
107
|
- !ruby/object:Gem::Version
|
108
108
|
version: '0'
|
109
109
|
name: webrick
|
110
|
-
prerelease: false
|
111
110
|
type: :development
|
111
|
+
prerelease: false
|
112
112
|
version_requirements: !ruby/object:Gem::Requirement
|
113
113
|
requirements:
|
114
114
|
- - ">="
|
@@ -121,8 +121,8 @@ dependencies:
|
|
121
121
|
- !ruby/object:Gem::Version
|
122
122
|
version: '0'
|
123
123
|
name: logstash-devutils
|
124
|
-
prerelease: false
|
125
124
|
type: :development
|
125
|
+
prerelease: false
|
126
126
|
version_requirements: !ruby/object:Gem::Requirement
|
127
127
|
requirements:
|
128
128
|
- - ">="
|
@@ -174,7 +174,7 @@ files:
|
|
174
174
|
- spec/filters/fixtures/test_certs/ls.der.sha256
|
175
175
|
- spec/filters/fixtures/test_certs/ls.key
|
176
176
|
- spec/filters/integration/elasticsearch_spec.rb
|
177
|
-
homepage:
|
177
|
+
homepage: https://elastic.co/logstash
|
178
178
|
licenses:
|
179
179
|
- Apache License (2.0)
|
180
180
|
metadata:
|
@@ -195,7 +195,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
195
195
|
- !ruby/object:Gem::Version
|
196
196
|
version: '0'
|
197
197
|
requirements: []
|
198
|
-
rubygems_version: 3.
|
198
|
+
rubygems_version: 3.3.26
|
199
199
|
signing_key:
|
200
200
|
specification_version: 4
|
201
201
|
summary: Copies fields from previous log events in Elasticsearch to current events
|