logstash-output-elasticsearch 10.2.3-java → 10.3.0-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 +23 -2
- data/lib/logstash/outputs/elasticsearch.rb +8 -3
- data/lib/logstash/outputs/elasticsearch/common.rb +63 -0
- data/lib/logstash/outputs/elasticsearch/common_configs.rb +9 -2
- data/logstash-output-elasticsearch.gemspec +1 -1
- data/spec/unit/outputs/elasticsearch_spec.rb +84 -10
- 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: 95ca05594f4d76e1bb341f14088bcafab677339c4322db449c24022d320d22ee
|
4
|
+
data.tar.gz: 79ec3c6d83999b68f9ebfca2c144c5556badfb9046d1f5c968628319623001d4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '049db8893d70c206be9cfe8e3e93354c98bfbd50d0718b936db79f6e9a07a3927fcdacc352f6e0eec02c0ac22ebd5cc866cd8193efa18a93a9c87f1a40251e7e'
|
7
|
+
data.tar.gz: 6509ec1cc74743832955ed52ecd868546f64712d99f6984285390b41adb71dd09d179d3e180decf9596e587f1b374cf611d0bda33e1e93b8421625d439fd8ae1
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
## 10.3.0
|
2
|
+
- Feat: Added support for cloud_id and cloud_auth [#906](https://github.com/logstash-plugins/logstash-output-elasticsearch/pull/906)
|
3
|
+
|
1
4
|
## 10.2.3
|
2
5
|
- Opened type removal logic for extension. This allows X-Pack Elasticsearch output to continue using types for special case `/_monitoring` bulk endpoint, enabling a fix for LogStash #11312. [#900](https://github.com/logstash-plugins/logstash-output-elasticsearch/pull/900)
|
3
6
|
|
data/docs/index.asciidoc
CHANGED
@@ -230,6 +230,8 @@ This plugin supports the following configuration options plus the <<plugins-{typ
|
|
230
230
|
| <<plugins-{type}s-{plugin}-action>> |<<string,string>>|No
|
231
231
|
| <<plugins-{type}s-{plugin}-bulk_path>> |<<string,string>>|No
|
232
232
|
| <<plugins-{type}s-{plugin}-cacert>> |a valid filesystem path|No
|
233
|
+
| <<plugins-{type}s-{plugin}-cloud_auth>> |<<password,password>>|No
|
234
|
+
| <<plugins-{type}s-{plugin}-cloud_id>> |<<string,string>>|No
|
233
235
|
| <<plugins-{type}s-{plugin}-custom_headers>> |<<hash,hash>>|No
|
234
236
|
| <<plugins-{type}s-{plugin}-doc_as_upsert>> |<<boolean,boolean>>|No
|
235
237
|
| <<plugins-{type}s-{plugin}-document_id>> |<<string,string>>|No
|
@@ -325,6 +327,26 @@ this defaults to a concatenation of the path parameter and "_bulk"
|
|
325
327
|
|
326
328
|
The .cer or .pem file to validate the server's certificate
|
327
329
|
|
330
|
+
[id="plugins-{type}s-{plugin}-cloud_auth"]
|
331
|
+
===== `cloud_auth`
|
332
|
+
|
333
|
+
* Value type is <<password,password>>
|
334
|
+
* There is no default value for this setting.
|
335
|
+
|
336
|
+
Cloud authentication string ("<username>:<password>" format) is an alternative for the `user`/`password` pair.
|
337
|
+
|
338
|
+
For mode details, check out the https://www.elastic.co/guide/en/logstash/current/connecting-to-cloud.html#_cloud_auth[cloud documentation]
|
339
|
+
|
340
|
+
[id="plugins-{type}s-{plugin}-cloud_id"]
|
341
|
+
===== `cloud_id`
|
342
|
+
|
343
|
+
* Value type is <<string,string>>
|
344
|
+
* There is no default value for this setting.
|
345
|
+
|
346
|
+
Cloud ID, from the Elastic Cloud web console. If set `hosts` should not be used.
|
347
|
+
|
348
|
+
For mode details, check out the https://www.elastic.co/guide/en/logstash/current/connecting-to-cloud.html#_cloud_id[cloud documentation]
|
349
|
+
|
328
350
|
[id="plugins-{type}s-{plugin}-doc_as_upsert"]
|
329
351
|
===== `doc_as_upsert`
|
330
352
|
|
@@ -340,8 +362,7 @@ Create a new document with source if `document_id` doesn't exist in Elasticsearc
|
|
340
362
|
* Value type is <<string,string>>
|
341
363
|
* There is no default value for this setting.
|
342
364
|
|
343
|
-
The document ID for the index. Useful for overwriting existing entries in
|
344
|
-
Elasticsearch with the same ID.
|
365
|
+
The document ID for the index. Useful for overwriting existing entries in Elasticsearch with the same ID.
|
345
366
|
|
346
367
|
[id="plugins-{type}s-{plugin}-document_type"]
|
347
368
|
===== `document_type`
|
@@ -17,7 +17,7 @@ require "forwardable"
|
|
17
17
|
# called `http.content_type.required`. If this option is set to `true`, and you
|
18
18
|
# are using Logstash 2.4 through 5.2, you need to update the Elasticsearch output
|
19
19
|
# plugin to version 6.2.5 or higher.
|
20
|
-
#
|
20
|
+
#
|
21
21
|
# ================================================================================
|
22
22
|
#
|
23
23
|
# This plugin is the recommended method of storing logs in Elasticsearch.
|
@@ -26,8 +26,8 @@ require "forwardable"
|
|
26
26
|
# This output only speaks the HTTP protocol. HTTP is the preferred protocol for interacting with Elasticsearch as of Logstash 2.0.
|
27
27
|
# We strongly encourage the use of HTTP over the node protocol for a number of reasons. HTTP is only marginally slower,
|
28
28
|
# yet far easier to administer and work with. When using the HTTP protocol one may upgrade Elasticsearch versions without having
|
29
|
-
# to upgrade Logstash in lock-step.
|
30
|
-
#
|
29
|
+
# to upgrade Logstash in lock-step.
|
30
|
+
#
|
31
31
|
# You can learn more about Elasticsearch at <https://www.elastic.co/products/elasticsearch>
|
32
32
|
#
|
33
33
|
# ==== Template management for Elasticsearch 5.x
|
@@ -122,6 +122,11 @@ class LogStash::Outputs::ElasticSearch < LogStash::Outputs::Base
|
|
122
122
|
# Password to authenticate to a secure Elasticsearch cluster
|
123
123
|
config :password, :validate => :password
|
124
124
|
|
125
|
+
# Cloud authentication string ("<username>:<password>" format) is an alternative for the `user`/`password` configuration.
|
126
|
+
#
|
127
|
+
# For mode details, check out the https://www.elastic.co/guide/en/logstash/current/connecting-to-cloud.html#_cloud_auth[cloud documentation]
|
128
|
+
config :cloud_auth, :validate => :password
|
129
|
+
|
125
130
|
# HTTP Path at which the Elasticsearch server lives. Use this if you must run Elasticsearch behind a proxy that remaps
|
126
131
|
# the root path for the Elasticsearch HTTP API lives.
|
127
132
|
# Note that if you use paths as components of URLs in the 'hosts' field you may
|
@@ -21,6 +21,8 @@ module LogStash; module Outputs; class ElasticSearch;
|
|
21
21
|
# To support BWC, we check if DLQ exists in core (< 5.4). If it doesn't, we use nil to resort to previous behavior.
|
22
22
|
@dlq_writer = dlq_enabled? ? execution_context.dlq_writer : nil
|
23
23
|
|
24
|
+
fill_hosts_from_cloud_id
|
25
|
+
fill_user_password_from_cloud_auth
|
24
26
|
setup_hosts # properly sets @hosts
|
25
27
|
build_client
|
26
28
|
setup_after_successful_connection
|
@@ -118,6 +120,67 @@ module LogStash; module Outputs; class ElasticSearch;
|
|
118
120
|
end
|
119
121
|
end
|
120
122
|
|
123
|
+
def hosts_default?(hosts)
|
124
|
+
# NOTE: would be nice if pipeline allowed us a clean way to detect a config default :
|
125
|
+
hosts.is_a?(Array) && hosts.size == 1 && hosts.first.equal?(CommonConfigs::DEFAULT_HOST)
|
126
|
+
end
|
127
|
+
private :hosts_default?
|
128
|
+
|
129
|
+
def fill_hosts_from_cloud_id
|
130
|
+
return unless @cloud_id
|
131
|
+
|
132
|
+
if @hosts && !hosts_default?(@hosts)
|
133
|
+
raise LogStash::ConfigurationError, 'Both cloud_id and hosts specified, please only use one of those.'
|
134
|
+
end
|
135
|
+
@hosts = parse_host_uri_from_cloud_id(@cloud_id)
|
136
|
+
end
|
137
|
+
|
138
|
+
def fill_user_password_from_cloud_auth
|
139
|
+
return unless @cloud_auth
|
140
|
+
|
141
|
+
if @user || @password
|
142
|
+
raise LogStash::ConfigurationError, 'Both cloud_auth and user/password specified, please only use one.'
|
143
|
+
end
|
144
|
+
@user, @password = parse_user_password_from_cloud_auth(@cloud_auth)
|
145
|
+
params['user'], params['password'] = @user, @password
|
146
|
+
end
|
147
|
+
|
148
|
+
def parse_host_uri_from_cloud_id(cloud_id)
|
149
|
+
begin # might not be available on older LS
|
150
|
+
require 'logstash/util/cloud_setting_id'
|
151
|
+
rescue LoadError
|
152
|
+
raise LogStash::ConfigurationError, 'The cloud_id setting is not supported by your version of Logstash, ' +
|
153
|
+
'please upgrade your installation (or set hosts instead).'
|
154
|
+
end
|
155
|
+
|
156
|
+
begin
|
157
|
+
cloud_id = LogStash::Util::CloudSettingId.new(cloud_id) # already does append ':{port}' to host
|
158
|
+
rescue ArgumentError => e
|
159
|
+
raise LogStash::ConfigurationError, e.message.to_s.sub(/Cloud Id/i, 'cloud_id')
|
160
|
+
end
|
161
|
+
cloud_uri = "#{cloud_id.elasticsearch_scheme}://#{cloud_id.elasticsearch_host}"
|
162
|
+
LogStash::Util::SafeURI.new(cloud_uri)
|
163
|
+
end
|
164
|
+
private :parse_host_uri_from_cloud_id
|
165
|
+
|
166
|
+
def parse_user_password_from_cloud_auth(cloud_auth)
|
167
|
+
begin # might not be available on older LS
|
168
|
+
require 'logstash/util/cloud_setting_auth'
|
169
|
+
rescue LoadError
|
170
|
+
raise LogStash::ConfigurationError, 'The cloud_auth setting is not supported by your version of Logstash, ' +
|
171
|
+
'please upgrade your installation (or set user/password instead).'
|
172
|
+
end
|
173
|
+
|
174
|
+
cloud_auth = cloud_auth.value if cloud_auth.is_a?(LogStash::Util::Password)
|
175
|
+
begin
|
176
|
+
cloud_auth = LogStash::Util::CloudSettingAuth.new(cloud_auth)
|
177
|
+
rescue ArgumentError => e
|
178
|
+
raise LogStash::ConfigurationError, e.message.to_s.sub(/Cloud Auth/i, 'cloud_auth')
|
179
|
+
end
|
180
|
+
[ cloud_auth.username, cloud_auth.password ]
|
181
|
+
end
|
182
|
+
private :parse_user_password_from_cloud_auth
|
183
|
+
|
121
184
|
def maximum_seen_major_version
|
122
185
|
client.maximum_seen_major_version
|
123
186
|
end
|
@@ -7,6 +7,8 @@ module LogStash; module Outputs; class ElasticSearch
|
|
7
7
|
DEFAULT_POLICY = "logstash-policy"
|
8
8
|
DEFAULT_ROLLOVER_ALIAS = 'logstash'
|
9
9
|
|
10
|
+
DEFAULT_HOST = ::LogStash::Util::SafeURI.new("//127.0.0.1")
|
11
|
+
|
10
12
|
def self.included(mod)
|
11
13
|
# The index to write events to. This can be dynamic using the `%{foo}` syntax.
|
12
14
|
# The default value will partition your indices by day so you can more easily
|
@@ -93,9 +95,14 @@ module LogStash; module Outputs; class ElasticSearch
|
|
93
95
|
# `["https://127.0.0.1:9200/mypath"]` (If using a proxy on a subpath)
|
94
96
|
# It is important to exclude http://www.elastic.co/guide/en/elasticsearch/reference/current/modules-node.html[dedicated master nodes] from the `hosts` list
|
95
97
|
# to prevent LS from sending bulk requests to the master nodes. So this parameter should only reference either data or client nodes in Elasticsearch.
|
96
|
-
#
|
98
|
+
#
|
97
99
|
# Any special characters present in the URLs here MUST be URL escaped! This means `#` should be put in as `%23` for instance.
|
98
|
-
mod.config :hosts, :validate => :uri, :default => [
|
100
|
+
mod.config :hosts, :validate => :uri, :default => [ DEFAULT_HOST ], :list => true
|
101
|
+
|
102
|
+
# Cloud ID, from the Elastic Cloud web console. If set `hosts` should not be used.
|
103
|
+
#
|
104
|
+
# For mode details, check out the https://www.elastic.co/guide/en/logstash/current/connecting-to-cloud.html#_cloud_id[cloud documentation]
|
105
|
+
mod.config :cloud_id, :validate => :string
|
99
106
|
|
100
107
|
# Set upsert content for update mode.s
|
101
108
|
# Create a new document with this parameter as json string if `document_id` doesn't exists
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'logstash-output-elasticsearch'
|
3
|
-
s.version = '10.
|
3
|
+
s.version = '10.3.0'
|
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"
|
@@ -337,18 +337,9 @@ describe LogStash::Outputs::ElasticSearch do
|
|
337
337
|
|
338
338
|
describe "SSL end to end" do
|
339
339
|
let(:do_register) { false } # skip the register in the global before block, as is called here.
|
340
|
-
let(:manticore_double) do
|
341
|
-
double("manticoreX#{self.inspect}")
|
342
|
-
end
|
343
340
|
|
344
341
|
before(:each) do
|
345
|
-
|
346
|
-
# Allow healtchecks
|
347
|
-
allow(manticore_double).to receive(:head).with(any_args).and_return(response_double)
|
348
|
-
allow(manticore_double).to receive(:get).with(any_args).and_return(response_double)
|
349
|
-
allow(manticore_double).to receive(:close)
|
350
|
-
|
351
|
-
allow(::Manticore::Client).to receive(:new).and_return(manticore_double)
|
342
|
+
stub_manticore_client!
|
352
343
|
subject.register
|
353
344
|
end
|
354
345
|
|
@@ -522,6 +513,75 @@ describe LogStash::Outputs::ElasticSearch do
|
|
522
513
|
end
|
523
514
|
end
|
524
515
|
|
516
|
+
describe "cloud.id" do
|
517
|
+
let(:do_register) { false }
|
518
|
+
|
519
|
+
let(:valid_cloud_id) do
|
520
|
+
'sample:dXMtY2VudHJhbDEuZ2NwLmNsb3VkLmVzLmlvJGFjMzFlYmI5MDI0MTc3MzE1NzA0M2MzNGZkMjZmZDQ2OjkyNDMkYTRjMDYyMzBlNDhjOGZjZTdiZTg4YTA3NGEzYmIzZTA6OTI0NA=='
|
521
|
+
end
|
522
|
+
|
523
|
+
let(:options) { { 'cloud_id' => valid_cloud_id } }
|
524
|
+
|
525
|
+
before(:each) do
|
526
|
+
stub_manticore_client!
|
527
|
+
end
|
528
|
+
|
529
|
+
it "should set host(s)" do
|
530
|
+
subject.register
|
531
|
+
es_url = subject.client.pool.urls.first
|
532
|
+
expect( es_url.to_s ).to eql('https://ac31ebb90241773157043c34fd26fd46.us-central1.gcp.cloud.es.io:9243/')
|
533
|
+
end
|
534
|
+
|
535
|
+
context 'invalid' do
|
536
|
+
let(:options) { { 'cloud_id' => 'invalid:dXMtY2VudHJhbDEuZ2NwLmNsb3VkLmVzLmlv' } }
|
537
|
+
|
538
|
+
it "should fail" do
|
539
|
+
expect { subject.register }.to raise_error LogStash::ConfigurationError, /cloud_id.*? is invalid/
|
540
|
+
end
|
541
|
+
end
|
542
|
+
|
543
|
+
context 'hosts also set' do
|
544
|
+
let(:options) { { 'cloud_id' => valid_cloud_id, 'hosts' => [ 'localhost' ] } }
|
545
|
+
|
546
|
+
it "should fail" do
|
547
|
+
expect { subject.register }.to raise_error LogStash::ConfigurationError, /cloud_id and hosts/
|
548
|
+
end
|
549
|
+
end
|
550
|
+
end
|
551
|
+
|
552
|
+
describe "cloud.auth" do
|
553
|
+
let(:do_register) { false }
|
554
|
+
|
555
|
+
let(:options) { { 'cloud_auth' => LogStash::Util::Password.new('elastic:my-passwd-00') } }
|
556
|
+
|
557
|
+
before(:each) do
|
558
|
+
stub_manticore_client!
|
559
|
+
end
|
560
|
+
|
561
|
+
it "should set host(s)" do
|
562
|
+
subject.register
|
563
|
+
es_url = subject.client.pool.urls.first
|
564
|
+
expect( es_url.user ).to eql('elastic')
|
565
|
+
expect( es_url.password ).to eql('my-passwd-00')
|
566
|
+
end
|
567
|
+
|
568
|
+
context 'invalid' do
|
569
|
+
let(:options) { { 'cloud_auth' => 'invalid-format' } }
|
570
|
+
|
571
|
+
it "should fail" do
|
572
|
+
expect { subject.register }.to raise_error LogStash::ConfigurationError, /cloud_auth.*? format/
|
573
|
+
end
|
574
|
+
end
|
575
|
+
|
576
|
+
context 'user also set' do
|
577
|
+
let(:options) { { 'cloud_auth' => 'elastic:my-passwd-00', 'user' => 'another' } }
|
578
|
+
|
579
|
+
it "should fail" do
|
580
|
+
expect { subject.register }.to raise_error LogStash::ConfigurationError, /cloud_auth and user/
|
581
|
+
end
|
582
|
+
end
|
583
|
+
end
|
584
|
+
|
525
585
|
context 'handling elasticsearch document-level status meant for the DLQ' do
|
526
586
|
let(:options) { { "manage_template" => false } }
|
527
587
|
|
@@ -598,4 +658,18 @@ describe LogStash::Outputs::ElasticSearch do
|
|
598
658
|
end
|
599
659
|
end
|
600
660
|
end
|
661
|
+
|
662
|
+
@private
|
663
|
+
|
664
|
+
def stub_manticore_client!(manticore_double = nil)
|
665
|
+
manticore_double ||= double("manticore #{self.inspect}")
|
666
|
+
response_double = double("manticore response").as_null_object
|
667
|
+
# Allow healtchecks
|
668
|
+
allow(manticore_double).to receive(:head).with(any_args).and_return(response_double)
|
669
|
+
allow(manticore_double).to receive(:get).with(any_args).and_return(response_double)
|
670
|
+
allow(manticore_double).to receive(:close)
|
671
|
+
|
672
|
+
allow(::Manticore::Client).to receive(:new).and_return(manticore_double)
|
673
|
+
end
|
674
|
+
|
601
675
|
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: 10.
|
4
|
+
version: 10.3.0
|
5
5
|
platform: java
|
6
6
|
authors:
|
7
7
|
- Elastic
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-01-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|