logstash-input-elasticsearch 4.6.2 → 4.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/docs/index.asciidoc +22 -1
- data/lib/logstash/inputs/elasticsearch.rb +66 -31
- data/logstash-input-elasticsearch.gemspec +1 -1
- data/spec/inputs/elasticsearch_spec.rb +31 -1
- 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: a7719819282371ea4fbfc4ce20de33e30a47f60a3683eb865de44f46743b0df0
|
4
|
+
data.tar.gz: 0a73015d8f782597a939a326aebddc79bf260bdf1f02b543f00823f59bc74e27
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a2dea22533a17a4b47d72f5fe58ac5d1b819f58de71e6311d8dc2f6adac733be96bbf0748dcf4fdd5bca644dae15f755463c72313dff3e11ad805f1bebc350ad
|
7
|
+
data.tar.gz: bdebe2a507305e0fe0d788cce9e47acbc607de2992257a7d60f486c16126b7c2a4f7e47fd1a12be87eb2b57a1c9df9d5c9c19c9b2d919f5a0b23eda06b3a9f8c
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
## 4.7.0
|
2
|
+
- Added api_key support [#131](https://github.com/logstash-plugins/logstash-input-elasticsearch/pull/131)
|
3
|
+
|
1
4
|
## 4.6.2
|
2
5
|
- Added scroll clearing and better handling of scroll expiration [#128](https://github.com/logstash-plugins/logstash-input-elasticsearch/pull/128)
|
3
6
|
|
data/docs/index.asciidoc
CHANGED
@@ -68,6 +68,16 @@ Further documentation describing this syntax can be found
|
|
68
68
|
https://github.com/jmettraux/rufus-scheduler#parsing-cronlines-and-time-strings[here].
|
69
69
|
|
70
70
|
|
71
|
+
[id="plugins-{type}s-{plugin}-auth"]
|
72
|
+
==== Authentication
|
73
|
+
|
74
|
+
Authentication to a secure Elasticsearch cluster is possible using _one_ of the following options:
|
75
|
+
|
76
|
+
* <<plugins-{type}s-{plugin}-user>> AND <<plugins-{type}s-{plugin}-password>>
|
77
|
+
* <<plugins-{type}s-{plugin}-cloud_auth>>
|
78
|
+
* <<plugins-{type}s-{plugin}-api_key>>
|
79
|
+
|
80
|
+
|
71
81
|
[id="plugins-{type}s-{plugin}-options"]
|
72
82
|
==== Elasticsearch Input Configuration Options
|
73
83
|
|
@@ -76,6 +86,7 @@ This plugin supports the following configuration options plus the < |
|
76
86
|
[cols="<,<,<",options="header",]
|
77
87
|
|=======================================================================
|
78
88
|
|Setting |Input type|Required
|
89
|
+
| <<plugins-{type}s-{plugin}-api_key>> |<<password,password>>|No
|
79
90
|
| <<plugins-{type}s-{plugin}-ca_file>> |a valid filesystem path|No
|
80
91
|
| <<plugins-{type}s-{plugin}-cloud_auth>> |<<password,password>>|No
|
81
92
|
| <<plugins-{type}s-{plugin}-cloud_id>> |<<string,string>>|No
|
@@ -100,6 +111,16 @@ input plugins.
|
|
100
111
|
|
101
112
|
|
102
113
|
|
114
|
+
[id="plugins-{type}s-{plugin}-api_key"]
|
115
|
+
===== `api_key`
|
116
|
+
|
117
|
+
* Value type is <<password,password>>
|
118
|
+
* There is no default value for this setting.
|
119
|
+
|
120
|
+
Authenticate using Elasticsearch API key. Note that this option also requires enabling the `ssl` option.
|
121
|
+
|
122
|
+
Format is `id:api_key` where `id` and `api_key` are as returned by the Elasticsearch https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-create-api-key.html[Create API key API].
|
123
|
+
|
103
124
|
[id="plugins-{type}s-{plugin}-ca_file"]
|
104
125
|
===== `ca_file`
|
105
126
|
|
@@ -315,4 +336,4 @@ empty string authentication will be disabled.
|
|
315
336
|
[id="plugins-{type}s-{plugin}-common-options"]
|
316
337
|
include::{include_path}/{type}.asciidoc[]
|
317
338
|
|
318
|
-
:default_codec!:
|
339
|
+
:default_codec!:
|
@@ -70,11 +70,6 @@ class LogStash::Inputs::Elasticsearch < LogStash::Inputs::Base
|
|
70
70
|
# Port defaults to 9200
|
71
71
|
config :hosts, :validate => :array
|
72
72
|
|
73
|
-
# Cloud ID, from the Elastic Cloud web console. If set `hosts` should not be used.
|
74
|
-
#
|
75
|
-
# For more info, check out the https://www.elastic.co/guide/en/logstash/current/connecting-to-cloud.html#_cloud_id[Logstash-to-Cloud documentation]
|
76
|
-
config :cloud_id, :validate => :string
|
77
|
-
|
78
73
|
# The index or alias to search.
|
79
74
|
config :index, :validate => :string, :default => "logstash-*"
|
80
75
|
|
@@ -140,11 +135,20 @@ class LogStash::Inputs::Elasticsearch < LogStash::Inputs::Base
|
|
140
135
|
# Basic Auth - password
|
141
136
|
config :password, :validate => :password
|
142
137
|
|
138
|
+
# Cloud ID, from the Elastic Cloud web console. If set `hosts` should not be used.
|
139
|
+
#
|
140
|
+
# For more info, check out the https://www.elastic.co/guide/en/logstash/current/connecting-to-cloud.html#_cloud_id[Logstash-to-Cloud documentation]
|
141
|
+
config :cloud_id, :validate => :string
|
142
|
+
|
143
143
|
# Cloud authentication string ("<username>:<password>" format) is an alternative for the `user`/`password` configuration.
|
144
144
|
#
|
145
145
|
# For more info, check out the https://www.elastic.co/guide/en/logstash/current/connecting-to-cloud.html#_cloud_auth[Logstash-to-Cloud documentation]
|
146
146
|
config :cloud_auth, :validate => :password
|
147
147
|
|
148
|
+
# Authenticate using Elasticsearch API key.
|
149
|
+
# format is id:api_key (as returned by https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-create-api-key.html[Create API key])
|
150
|
+
config :api_key, :validate => :password
|
151
|
+
|
148
152
|
# Set the address of a forward HTTP proxy.
|
149
153
|
config :proxy, :validate => :uri_or_empty
|
150
154
|
|
@@ -177,28 +181,17 @@ class LogStash::Inputs::Elasticsearch < LogStash::Inputs::Base
|
|
177
181
|
@slices < 1 && fail(LogStash::ConfigurationError, "Elasticsearch Input Plugin's `slices` option must be greater than zero, got `#{@slices}`")
|
178
182
|
end
|
179
183
|
|
180
|
-
|
181
|
-
|
184
|
+
validate_authentication
|
182
185
|
fill_user_password_from_cloud_auth
|
186
|
+
fill_hosts_from_cloud_id
|
183
187
|
|
184
|
-
if @user && @password
|
185
|
-
token = Base64.strict_encode64("#{@user}:#{@password.value}")
|
186
|
-
transport_options[:headers] = { :Authorization => "Basic #{token}" }
|
187
|
-
end
|
188
188
|
|
189
|
-
|
190
|
-
|
189
|
+
transport_options = {:headers => {}}
|
190
|
+
transport_options[:headers].merge!(setup_basic_auth(user, password))
|
191
|
+
transport_options[:headers].merge!(setup_api_key(api_key))
|
191
192
|
|
192
|
-
hosts =
|
193
|
-
|
194
|
-
host, port = h.split(":")
|
195
|
-
{ :host => host, :scheme => 'https', :port => port }
|
196
|
-
end
|
197
|
-
else
|
198
|
-
@hosts
|
199
|
-
end
|
200
|
-
ssl_options = { :ssl => true, :ca_file => @ca_file } if @ssl && @ca_file
|
201
|
-
ssl_options ||= {}
|
193
|
+
hosts = setup_hosts
|
194
|
+
ssl_options = setup_ssl
|
202
195
|
|
203
196
|
@logger.warn "Supplied proxy setting (proxy => '') has no effect" if @proxy.eql?('')
|
204
197
|
|
@@ -351,25 +344,67 @@ class LogStash::Inputs::Elasticsearch < LogStash::Inputs::Base
|
|
351
344
|
hosts.nil? || ( hosts.is_a?(Array) && hosts.empty? )
|
352
345
|
end
|
353
346
|
|
354
|
-
def
|
355
|
-
|
347
|
+
def validate_authentication
|
348
|
+
authn_options = 0
|
349
|
+
authn_options += 1 if @cloud_auth
|
350
|
+
authn_options += 1 if (@api_key && @api_key.value)
|
351
|
+
authn_options += 1 if (@user || (@password && @password.value))
|
356
352
|
|
357
|
-
if
|
358
|
-
raise LogStash::ConfigurationError, '
|
353
|
+
if authn_options > 1
|
354
|
+
raise LogStash::ConfigurationError, 'Multiple authentication options are specified, please only use one of user/password, cloud_auth or api_key'
|
359
355
|
end
|
360
|
-
|
356
|
+
|
357
|
+
if @api_key && @api_key.value && @ssl != true
|
358
|
+
raise(LogStash::ConfigurationError, "Using api_key authentication requires SSL/TLS secured communication using the `ssl => true` option")
|
359
|
+
end
|
360
|
+
end
|
361
|
+
|
362
|
+
def setup_ssl
|
363
|
+
@ssl && @ca_file ? { :ssl => true, :ca_file => @ca_file } : {}
|
364
|
+
end
|
365
|
+
|
366
|
+
def setup_hosts
|
367
|
+
@hosts = Array(@hosts).map { |host| host.to_s } # potential SafeURI#to_s
|
368
|
+
if @ssl
|
369
|
+
@hosts.map do |h|
|
370
|
+
host, port = h.split(":")
|
371
|
+
{ :host => host, :scheme => 'https', :port => port }
|
372
|
+
end
|
373
|
+
else
|
374
|
+
@hosts
|
375
|
+
end
|
376
|
+
end
|
377
|
+
|
378
|
+
def setup_basic_auth(user, password)
|
379
|
+
return {} unless user && password && password.value
|
380
|
+
|
381
|
+
token = ::Base64.strict_encode64("#{user}:#{password.value}")
|
382
|
+
{ Authorization: "Basic #{token}" }
|
383
|
+
end
|
384
|
+
|
385
|
+
def setup_api_key(api_key)
|
386
|
+
return {} unless (api_key && api_key.value)
|
387
|
+
|
388
|
+
token = ::Base64.strict_encode64(api_key.value)
|
389
|
+
{ Authorization: "ApiKey #{token}" }
|
361
390
|
end
|
362
391
|
|
363
392
|
def fill_user_password_from_cloud_auth
|
364
393
|
return unless @cloud_auth
|
365
394
|
|
366
|
-
if @user || @password
|
367
|
-
raise LogStash::ConfigurationError, 'Both cloud_auth and user/password specified, please only use one.'
|
368
|
-
end
|
369
395
|
@user, @password = parse_user_password_from_cloud_auth(@cloud_auth)
|
370
396
|
params['user'], params['password'] = @user, @password
|
371
397
|
end
|
372
398
|
|
399
|
+
def fill_hosts_from_cloud_id
|
400
|
+
return unless @cloud_id
|
401
|
+
|
402
|
+
if @hosts && !hosts_default?(@hosts)
|
403
|
+
raise LogStash::ConfigurationError, 'Both cloud_id and hosts specified, please only use one of those.'
|
404
|
+
end
|
405
|
+
@hosts = parse_host_uri_from_cloud_id(@cloud_id)
|
406
|
+
end
|
407
|
+
|
373
408
|
def parse_host_uri_from_cloud_id(cloud_id)
|
374
409
|
begin # might not be available on older LS
|
375
410
|
require 'logstash/util/cloud_setting_id'
|
@@ -1,7 +1,7 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
|
3
3
|
s.name = 'logstash-input-elasticsearch'
|
4
|
-
s.version = '4.
|
4
|
+
s.version = '4.7.0'
|
5
5
|
s.licenses = ['Apache License (2.0)']
|
6
6
|
s.summary = "Reads query results from an Elasticsearch cluster"
|
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"
|
@@ -583,7 +583,37 @@ describe LogStash::Inputs::TestableElasticsearch do
|
|
583
583
|
let(:config) { super.merge({ 'cloud_auth' => 'elastic:my-passwd-00', 'user' => 'another' }) }
|
584
584
|
|
585
585
|
it "should fail" do
|
586
|
-
expect { plugin.register }.to raise_error LogStash::ConfigurationError, /
|
586
|
+
expect { plugin.register }.to raise_error LogStash::ConfigurationError, /Multiple authentication options are specified/
|
587
|
+
end
|
588
|
+
end
|
589
|
+
end if LOGSTASH_VERSION > '6.0'
|
590
|
+
|
591
|
+
describe "api_key" do
|
592
|
+
context "without ssl" do
|
593
|
+
let(:config) { super.merge({ 'api_key' => LogStash::Util::Password.new('foo:bar') }) }
|
594
|
+
|
595
|
+
it "should fail" do
|
596
|
+
expect { plugin.register }.to raise_error LogStash::ConfigurationError, /api_key authentication requires SSL\/TLS/
|
597
|
+
end
|
598
|
+
end
|
599
|
+
|
600
|
+
context "with ssl" do
|
601
|
+
let(:config) { super.merge({ 'api_key' => LogStash::Util::Password.new('foo:bar'), "ssl" => true }) }
|
602
|
+
|
603
|
+
it "should set authorization" do
|
604
|
+
plugin.register
|
605
|
+
client = plugin.send(:client)
|
606
|
+
auth_header = client.transport.options[:transport_options][:headers][:Authorization]
|
607
|
+
|
608
|
+
expect( auth_header ).to eql "ApiKey #{Base64.strict_encode64('foo:bar')}"
|
609
|
+
end
|
610
|
+
|
611
|
+
context 'user also set' do
|
612
|
+
let(:config) { super.merge({ 'api_key' => 'foo:bar', 'user' => 'another' }) }
|
613
|
+
|
614
|
+
it "should fail" do
|
615
|
+
expect { plugin.register }.to raise_error LogStash::ConfigurationError, /Multiple authentication options are specified/
|
616
|
+
end
|
587
617
|
end
|
588
618
|
end
|
589
619
|
end if LOGSTASH_VERSION > '6.0'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logstash-input-elasticsearch
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.
|
4
|
+
version: 4.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Elastic
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-06-
|
11
|
+
date: 2020-06-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|