logstash-input-elasticsearch 4.6.0 → 4.8.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 +16 -0
- data/LICENSE +199 -10
- data/docs/index.asciidoc +67 -17
- data/lib/logstash/inputs/elasticsearch.rb +157 -63
- data/logstash-input-elasticsearch.gemspec +1 -1
- data/spec/inputs/elasticsearch_spec.rb +94 -5
- 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: 74690fbfa461c4c9087181c3f95e4feb33f68e6398cc357a1c8d12d6bca8d837
|
4
|
+
data.tar.gz: 67425c9a092529e779e0c7693cc8afa9eaed0cfb188509026881d1972f970f3c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 63482d80b537ba41ca5d3ed34a1e35dc6550887747b7d50a7320564dbd5fcac3336519cae21c21363322616f6a1c66f803743e2246e2d2dc8adf2b03b0a23231
|
7
|
+
data.tar.gz: 98547555319b8d856ea58ed33b8236fcf15c2483594ca45c9c2e09791b4a20f6250ae7019e4e1be341f2000816a90e522b8c6fb21bec3b1aebc6b511cce2e09a
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,19 @@
|
|
1
|
+
## 4.8.0
|
2
|
+
- Added the ability to configure connection-, request-, and socket-timeouts with `connect_timeout_seconds`, `request_timeout_seconds`, and `socket_timeout_seconds` [#121](https://github.com/logstash-plugins/logstash-input-elasticsearch/issues/121)
|
3
|
+
|
4
|
+
## 4.7.1
|
5
|
+
- [DOC] Updated sliced scroll link to resolve to correct location after doc structure change [#135](https://github.com/logstash-plugins/logstash-input-elasticsearch/pull/135)
|
6
|
+
- [DOC] Added usage example of docinfo metadata [#98](https://github.com/logstash-plugins/logstash-input-elasticsearch/pull/98)
|
7
|
+
|
8
|
+
## 4.7.0
|
9
|
+
- Added api_key support [#131](https://github.com/logstash-plugins/logstash-input-elasticsearch/pull/131)
|
10
|
+
|
11
|
+
## 4.6.2
|
12
|
+
- Added scroll clearing and better handling of scroll expiration [#128](https://github.com/logstash-plugins/logstash-input-elasticsearch/pull/128)
|
13
|
+
|
14
|
+
## 4.6.1
|
15
|
+
- [DOC] Removed outdated compatibility notice [#124](https://github.com/logstash-plugins/logstash-input-elasticsearch/pull/124)
|
16
|
+
|
1
17
|
## 4.6.0
|
2
18
|
- Feat: added option to specify proxy for ES [#114](https://github.com/logstash-plugins/logstash-input-elasticsearch/pull/114)
|
3
19
|
|
data/LICENSE
CHANGED
@@ -1,13 +1,202 @@
|
|
1
|
-
Copyright (c) 2012-2018 Elasticsearch <http://www.elastic.co>
|
2
1
|
|
3
|
-
|
4
|
-
|
5
|
-
|
2
|
+
Apache License
|
3
|
+
Version 2.0, January 2004
|
4
|
+
http://www.apache.org/licenses/
|
6
5
|
|
7
|
-
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
8
7
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
8
|
+
1. Definitions.
|
9
|
+
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
12
|
+
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
14
|
+
the copyright owner that is granting the License.
|
15
|
+
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
17
|
+
other entities that control, are controlled by, or are under common
|
18
|
+
control with that entity. For the purposes of this definition,
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
20
|
+
direction or management of such entity, whether by contract or
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
23
|
+
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
25
|
+
exercising permissions granted by this License.
|
26
|
+
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
28
|
+
including but not limited to software source code, documentation
|
29
|
+
source, and configuration files.
|
30
|
+
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
32
|
+
transformation or translation of a Source form, including but
|
33
|
+
not limited to compiled object code, generated documentation,
|
34
|
+
and conversions to other media types.
|
35
|
+
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
37
|
+
Object form, made available under the License, as indicated by a
|
38
|
+
copyright notice that is included in or attached to the work
|
39
|
+
(an example is provided in the Appendix below).
|
40
|
+
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
47
|
+
the Work and Derivative Works thereof.
|
48
|
+
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
50
|
+
the original version of the Work and any modifications or additions
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
62
|
+
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
65
|
+
subsequently incorporated within the Work.
|
66
|
+
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
73
|
+
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
79
|
+
where such license applies only to those patent claims licensable
|
80
|
+
by such Contributor that are necessarily infringed by their
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
83
|
+
institute patent litigation against any entity (including a
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
86
|
+
or contributory patent infringement, then any patent licenses
|
87
|
+
granted to You under this License for that Work shall terminate
|
88
|
+
as of the date such litigation is filed.
|
89
|
+
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
92
|
+
modifications, and in Source or Object form, provided that You
|
93
|
+
meet the following conditions:
|
94
|
+
|
95
|
+
(a) You must give any other recipients of the Work or
|
96
|
+
Derivative Works a copy of this License; and
|
97
|
+
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
99
|
+
stating that You changed the files; and
|
100
|
+
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
103
|
+
attribution notices from the Source form of the Work,
|
104
|
+
excluding those notices that do not pertain to any part of
|
105
|
+
the Derivative Works; and
|
106
|
+
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
109
|
+
include a readable copy of the attribution notices contained
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
112
|
+
of the following places: within a NOTICE text file distributed
|
113
|
+
as part of the Derivative Works; within the Source form or
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
115
|
+
within a display generated by the Derivative Works, if and
|
116
|
+
wherever such third-party notices normally appear. The contents
|
117
|
+
of the NOTICE file are for informational purposes only and
|
118
|
+
do not modify the License. You may add Your own attribution
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
121
|
+
that such additional attribution notices cannot be construed
|
122
|
+
as modifying the License.
|
123
|
+
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
125
|
+
may provide additional or different license terms and conditions
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
129
|
+
the conditions stated in this License.
|
130
|
+
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
134
|
+
this License, without any additional terms or conditions.
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
136
|
+
the terms of any separate license agreement you may have executed
|
137
|
+
with Licensor regarding such Contributions.
|
138
|
+
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
141
|
+
except as required for reasonable and customary use in describing the
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
143
|
+
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
153
|
+
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
159
|
+
incidental, or consequential damages of any character arising as a
|
160
|
+
result of this License or out of the use or inability to use the
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
163
|
+
other commercial damages or losses), even if such Contributor
|
164
|
+
has been advised of the possibility of such damages.
|
165
|
+
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
169
|
+
or other liability obligations and/or rights consistent with this
|
170
|
+
License. However, in accepting such obligations, You may act only
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
175
|
+
of your accepting any such warranty or additional liability.
|
176
|
+
|
177
|
+
END OF TERMS AND CONDITIONS
|
178
|
+
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
180
|
+
|
181
|
+
To apply the Apache License to your work, attach the following
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
183
|
+
replaced with your own identifying information. (Don't include
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
185
|
+
comment syntax for the file format. We also recommend that a
|
186
|
+
file or class name and description of purpose be included on the
|
187
|
+
same "printed page" as the copyright notice for easier
|
188
|
+
identification within third-party archives.
|
189
|
+
|
190
|
+
Copyright 2020 Elastic and contributors
|
191
|
+
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
193
|
+
you may not use this file except in compliance with the License.
|
194
|
+
You may obtain a copy of the License at
|
195
|
+
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
197
|
+
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
201
|
+
See the License for the specific language governing permissions and
|
202
|
+
limitations under the License.
|
data/docs/index.asciidoc
CHANGED
@@ -21,16 +21,6 @@ include::{include_path}/plugin_header.asciidoc[]
|
|
21
21
|
|
22
22
|
==== Description
|
23
23
|
|
24
|
-
.Compatibility Note
|
25
|
-
[NOTE]
|
26
|
-
================================================================================
|
27
|
-
Starting with Elasticsearch 5.3, there's an {ref}/modules-http.html[HTTP setting]
|
28
|
-
called `http.content_type.required`. If this option is set to `true`, and you
|
29
|
-
are using Logstash 2.4 through 5.2, you need to update the Elasticsearch input
|
30
|
-
plugin to version 4.0.2 or higher.
|
31
|
-
|
32
|
-
================================================================================
|
33
|
-
|
34
24
|
Read from an Elasticsearch cluster, based on search query results.
|
35
25
|
This is useful for replaying test logs, reindexing, etc.
|
36
26
|
You can periodically schedule ingestion using a cron syntax
|
@@ -78,6 +68,16 @@ Further documentation describing this syntax can be found
|
|
78
68
|
https://github.com/jmettraux/rufus-scheduler#parsing-cronlines-and-time-strings[here].
|
79
69
|
|
80
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
|
+
|
81
81
|
[id="plugins-{type}s-{plugin}-options"]
|
82
82
|
==== Elasticsearch Input Configuration Options
|
83
83
|
|
@@ -86,9 +86,11 @@ This plugin supports the following configuration options plus the <<plugins-{typ
|
|
86
86
|
[cols="<,<,<",options="header",]
|
87
87
|
|=======================================================================
|
88
88
|
|Setting |Input type|Required
|
89
|
+
| <<plugins-{type}s-{plugin}-api_key>> |<<password,password>>|No
|
89
90
|
| <<plugins-{type}s-{plugin}-ca_file>> |a valid filesystem path|No
|
90
91
|
| <<plugins-{type}s-{plugin}-cloud_auth>> |<<password,password>>|No
|
91
92
|
| <<plugins-{type}s-{plugin}-cloud_id>> |<<string,string>>|No
|
93
|
+
| <<plugins-{type}s-{plugin}-connect_timeout_seconds>> | <<number,number>>|No
|
92
94
|
| <<plugins-{type}s-{plugin}-docinfo>> |<<boolean,boolean>>|No
|
93
95
|
| <<plugins-{type}s-{plugin}-docinfo_fields>> |<<array,array>>|No
|
94
96
|
| <<plugins-{type}s-{plugin}-docinfo_target>> |<<string,string>>|No
|
@@ -97,11 +99,13 @@ This plugin supports the following configuration options plus the <<plugins-{typ
|
|
97
99
|
| <<plugins-{type}s-{plugin}-password>> |<<password,password>>|No
|
98
100
|
| <<plugins-{type}s-{plugin}-proxy>> |<<uri,uri>>|No
|
99
101
|
| <<plugins-{type}s-{plugin}-query>> |<<string,string>>|No
|
102
|
+
| <<plugins-{type}s-{plugin}-request_timeout_seconds>> | <<number,number>>|No
|
100
103
|
| <<plugins-{type}s-{plugin}-schedule>> |<<string,string>>|No
|
101
104
|
| <<plugins-{type}s-{plugin}-scroll>> |<<string,string>>|No
|
102
105
|
| <<plugins-{type}s-{plugin}-size>> |<<number,number>>|No
|
103
106
|
| <<plugins-{type}s-{plugin}-slices>> |<<number,number>>|No
|
104
107
|
| <<plugins-{type}s-{plugin}-ssl>> |<<boolean,boolean>>|No
|
108
|
+
| <<plugins-{type}s-{plugin}-socket_timeout_seconds>> | <<number,number>>|No
|
105
109
|
| <<plugins-{type}s-{plugin}-user>> |<<string,string>>|No
|
106
110
|
|=======================================================================
|
107
111
|
|
@@ -110,6 +114,16 @@ input plugins.
|
|
110
114
|
|
111
115
|
|
112
116
|
|
117
|
+
[id="plugins-{type}s-{plugin}-api_key"]
|
118
|
+
===== `api_key`
|
119
|
+
|
120
|
+
* Value type is <<password,password>>
|
121
|
+
* There is no default value for this setting.
|
122
|
+
|
123
|
+
Authenticate using Elasticsearch API key. Note that this option also requires enabling the `ssl` option.
|
124
|
+
|
125
|
+
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].
|
126
|
+
|
113
127
|
[id="plugins-{type}s-{plugin}-ca_file"]
|
114
128
|
===== `ca_file`
|
115
129
|
|
@@ -138,6 +152,15 @@ Cloud ID, from the Elastic Cloud web console. If set `hosts` should not be used.
|
|
138
152
|
|
139
153
|
For more info, check out the https://www.elastic.co/guide/en/logstash/current/connecting-to-cloud.html#_cloud_id[Logstash-to-Cloud documentation]
|
140
154
|
|
155
|
+
[id="plugins-{type}s-{plugin}-connect_timeout_seconds"]
|
156
|
+
===== `connect_timeout_seconds`
|
157
|
+
|
158
|
+
* Value type is <<number,number>>
|
159
|
+
* Default value is `10`
|
160
|
+
|
161
|
+
The maximum amount of time, in seconds, to wait while establishing a connection to Elasticsearch.
|
162
|
+
Connect timeouts tend to occur when Elasticsearch or an intermediate proxy is overloaded with requests and has exhausted its connection pool.
|
163
|
+
|
141
164
|
[id="plugins-{type}s-{plugin}-docinfo"]
|
142
165
|
===== `docinfo`
|
143
166
|
|
@@ -173,11 +196,19 @@ Example
|
|
173
196
|
}
|
174
197
|
}
|
175
198
|
|
199
|
+
If set, you can use metadata information in the <<plugins-{type}s-{plugin}-add_field>> common option.
|
200
|
+
|
201
|
+
Example
|
202
|
+
[source, ruby]
|
203
|
+
input {
|
204
|
+
elasticsearch {
|
205
|
+
docinfo => true
|
206
|
+
add_field => {
|
207
|
+
identifier => %{[@metadata][_index]}:%{[@metadata][_type]}:%{[@metadata][_id]}"
|
208
|
+
}
|
209
|
+
}
|
210
|
+
}
|
176
211
|
|
177
|
-
NOTE: Starting with Logstash 6.0, the `document_type` option is
|
178
|
-
deprecated due to the
|
179
|
-
https://www.elastic.co/guide/en/elasticsearch/reference/6.0/removal-of-types.html[removal of types in Logstash 6.0].
|
180
|
-
It will be removed in the next major version of Logstash.
|
181
212
|
|
182
213
|
[id="plugins-{type}s-{plugin}-docinfo_fields"]
|
183
214
|
===== `docinfo_fields`
|
@@ -252,6 +283,16 @@ The query to be executed. Read the
|
|
252
283
|
https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl.html[Elasticsearch query DSL documentation]
|
253
284
|
for more information.
|
254
285
|
|
286
|
+
[id="plugins-{type}s-{plugin}-request_timeout_seconds"]
|
287
|
+
===== `request_timeout_seconds`
|
288
|
+
|
289
|
+
* Value type is <<number,number>>
|
290
|
+
* Default value is `60`
|
291
|
+
|
292
|
+
The maximum amount of time, in seconds, for a single request to Elasticsearch.
|
293
|
+
Request timeouts tend to occur when an individual page of data is very large, such as when it contains large-payload
|
294
|
+
documents and/or the <<plugins-{type}s-{plugin}-size>> has been specified as a large value.
|
295
|
+
|
255
296
|
[id="plugins-{type}s-{plugin}-schedule"]
|
256
297
|
===== `schedule`
|
257
298
|
|
@@ -290,8 +331,8 @@ This allows you to set the maximum number of hits returned per scroll.
|
|
290
331
|
* Sensible values range from 2 to about 8.
|
291
332
|
|
292
333
|
In some cases, it is possible to improve overall throughput by consuming multiple
|
293
|
-
distinct slices of a query simultaneously using
|
294
|
-
https://www.elastic.co/guide/en/elasticsearch/reference/current/search-
|
334
|
+
distinct slices of a query simultaneously using
|
335
|
+
https://www.elastic.co/guide/en/elasticsearch/reference/current/paginate-search-results.html#slice-scroll[sliced scrolls],
|
295
336
|
especially if the pipeline is spending significant time waiting on Elasticsearch
|
296
337
|
to provide results.
|
297
338
|
|
@@ -315,6 +356,15 @@ instructions into the query.
|
|
315
356
|
If enabled, SSL will be used when communicating with the Elasticsearch
|
316
357
|
server (i.e. HTTPS will be used instead of plain HTTP).
|
317
358
|
|
359
|
+
[id="plugins-{type}s-{plugin}-socket_timeout_seconds"]
|
360
|
+
===== `socket_timeout_seconds`
|
361
|
+
|
362
|
+
* Value type is <<number,number>>
|
363
|
+
* Default value is `60`
|
364
|
+
|
365
|
+
The maximum amount of time, in seconds, to wait on an incomplete response from Elasticsearch while no additional data has been appended.
|
366
|
+
Socket timeouts usually occur while waiting for the first byte of a response, such as when executing a particularly complex query.
|
367
|
+
|
318
368
|
[id="plugins-{type}s-{plugin}-user"]
|
319
369
|
===== `user`
|
320
370
|
|
@@ -330,4 +380,4 @@ empty string authentication will be disabled.
|
|
330
380
|
[id="plugins-{type}s-{plugin}-common-options"]
|
331
381
|
include::{include_path}/{type}.asciidoc[]
|
332
382
|
|
333
|
-
:default_codec!:
|
383
|
+
: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,29 @@ class LogStash::Inputs::Elasticsearch < LogStash::Inputs::Base
|
|
140
135
|
# Basic Auth - password
|
141
136
|
config :password, :validate => :password
|
142
137
|
|
138
|
+
# Connection Timeout, in Seconds
|
139
|
+
config :connect_timeout_seconds, :validate => :positive_whole_number, :default => 10
|
140
|
+
|
141
|
+
# Request Timeout, in Seconds
|
142
|
+
config :request_timeout_seconds, :validate => :positive_whole_number, :default => 60
|
143
|
+
|
144
|
+
# Socket Timeout, in Seconds
|
145
|
+
config :socket_timeout_seconds, :validate => :positive_whole_number, :default => 60
|
146
|
+
|
147
|
+
# Cloud ID, from the Elastic Cloud web console. If set `hosts` should not be used.
|
148
|
+
#
|
149
|
+
# For more info, check out the https://www.elastic.co/guide/en/logstash/current/connecting-to-cloud.html#_cloud_id[Logstash-to-Cloud documentation]
|
150
|
+
config :cloud_id, :validate => :string
|
151
|
+
|
143
152
|
# Cloud authentication string ("<username>:<password>" format) is an alternative for the `user`/`password` configuration.
|
144
153
|
#
|
145
154
|
# 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
155
|
config :cloud_auth, :validate => :password
|
147
156
|
|
157
|
+
# Authenticate using Elasticsearch API key.
|
158
|
+
# 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])
|
159
|
+
config :api_key, :validate => :password
|
160
|
+
|
148
161
|
# Set the address of a forward HTTP proxy.
|
149
162
|
config :proxy, :validate => :uri_or_empty
|
150
163
|
|
@@ -177,54 +190,34 @@ class LogStash::Inputs::Elasticsearch < LogStash::Inputs::Base
|
|
177
190
|
@slices < 1 && fail(LogStash::ConfigurationError, "Elasticsearch Input Plugin's `slices` option must be greater than zero, got `#{@slices}`")
|
178
191
|
end
|
179
192
|
|
180
|
-
|
181
|
-
|
193
|
+
validate_authentication
|
182
194
|
fill_user_password_from_cloud_auth
|
195
|
+
fill_hosts_from_cloud_id
|
183
196
|
|
184
|
-
if @user && @password
|
185
|
-
token = Base64.strict_encode64("#{@user}:#{@password.value}")
|
186
|
-
transport_options[:headers] = { :Authorization => "Basic #{token}" }
|
187
|
-
end
|
188
197
|
|
189
|
-
|
190
|
-
|
198
|
+
transport_options = {:headers => {}}
|
199
|
+
transport_options[:headers].merge!(setup_basic_auth(user, password))
|
200
|
+
transport_options[:headers].merge!(setup_api_key(api_key))
|
201
|
+
transport_options[:request_timeout] = @request_timeout_seconds unless @request_timeout_seconds.nil?
|
202
|
+
transport_options[:connect_timeout] = @connect_timeout_seconds unless @connect_timeout_seconds.nil?
|
203
|
+
transport_options[:socket_timeout] = @socket_timeout_seconds unless @socket_timeout_seconds.nil?
|
191
204
|
|
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 ||= {}
|
205
|
+
hosts = setup_hosts
|
206
|
+
ssl_options = setup_ssl
|
202
207
|
|
203
208
|
@logger.warn "Supplied proxy setting (proxy => '') has no effect" if @proxy.eql?('')
|
204
209
|
|
205
210
|
transport_options[:proxy] = @proxy.to_s if @proxy && !@proxy.eql?('')
|
206
211
|
|
207
|
-
@client = Elasticsearch::Client.new(
|
208
|
-
|
209
|
-
|
212
|
+
@client = Elasticsearch::Client.new(
|
213
|
+
:hosts => hosts,
|
214
|
+
:transport_options => transport_options,
|
215
|
+
:transport_class => ::Elasticsearch::Transport::Transport::HTTP::Manticore,
|
216
|
+
:ssl => ssl_options
|
217
|
+
)
|
210
218
|
end
|
211
219
|
|
212
|
-
##
|
213
|
-
# @override to handle proxy => '' as if none was set
|
214
|
-
# @param value [Array<Object>]
|
215
|
-
# @param validator [nil,Array,Symbol]
|
216
|
-
# @return [Array(true,Object)]: if validation is a success, a tuple containing `true` and the coerced value
|
217
|
-
# @return [Array(false,String)]: if validation is a failure, a tuple containing `false` and the failure reason.
|
218
|
-
def self.validate_value(value, validator)
|
219
|
-
return super unless validator == :uri_or_empty
|
220
|
-
|
221
|
-
value = deep_replace(value)
|
222
|
-
value = hash_or_array(value)
|
223
220
|
|
224
|
-
return true, value.first if value.size == 1 && value.first.empty?
|
225
|
-
|
226
|
-
return super(value, :uri)
|
227
|
-
end
|
228
221
|
|
229
222
|
def run(output_queue)
|
230
223
|
if @schedule
|
@@ -266,25 +259,41 @@ class LogStash::Inputs::Elasticsearch < LogStash::Inputs::Base
|
|
266
259
|
slice_options = @options.merge(:body => LogStash::Json.dump(slice_query) )
|
267
260
|
|
268
261
|
logger.info("Slice starting", slice_id: slice_id, slices: @slices) unless slice_id.nil?
|
269
|
-
r = search_request(slice_options)
|
270
262
|
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
has_hits = r['hits']['hits'].any?
|
263
|
+
scroll_id = nil
|
264
|
+
begin
|
265
|
+
r = search_request(slice_options)
|
275
266
|
|
276
|
-
|
277
|
-
r = process_next_scroll(output_queue, r['_scroll_id'])
|
267
|
+
r['hits']['hits'].each { |hit| push_hit(hit, output_queue) }
|
278
268
|
logger.debug("Slice progress", slice_id: slice_id, slices: @slices) unless slice_id.nil?
|
279
|
-
|
269
|
+
|
270
|
+
has_hits = r['hits']['hits'].any?
|
271
|
+
scroll_id = r['_scroll_id']
|
272
|
+
|
273
|
+
while has_hits && scroll_id && !stop?
|
274
|
+
has_hits, scroll_id = process_next_scroll(output_queue, scroll_id)
|
275
|
+
logger.debug("Slice progress", slice_id: slice_id, slices: @slices) if logger.debug? && slice_id
|
276
|
+
end
|
277
|
+
logger.info("Slice complete", slice_id: slice_id, slices: @slices) unless slice_id.nil?
|
278
|
+
ensure
|
279
|
+
clear_scroll(scroll_id)
|
280
280
|
end
|
281
|
-
logger.info("Slice complete", slice_id: slice_id, slices: @slices) unless slice_id.nil?
|
282
281
|
end
|
283
282
|
|
283
|
+
##
|
284
|
+
# @param output_queue [#<<]
|
285
|
+
# @param scroll_id [String]: a scroll id to resume
|
286
|
+
# @return [Array(Boolean,String)]: a tuple representing whether the response
|
287
|
+
#
|
284
288
|
def process_next_scroll(output_queue, scroll_id)
|
285
289
|
r = scroll_request(scroll_id)
|
286
290
|
r['hits']['hits'].each { |hit| push_hit(hit, output_queue) }
|
287
|
-
|
291
|
+
[r['hits']['hits'].any?, r['_scroll_id']]
|
292
|
+
rescue => e
|
293
|
+
# this will typically be triggered by a scroll timeout
|
294
|
+
logger.error("Scroll request error, aborting scroll", error: e.inspect)
|
295
|
+
# return no hits and original scroll_id so we can try to clear it
|
296
|
+
[false, scroll_id]
|
288
297
|
end
|
289
298
|
|
290
299
|
def push_hit(hit, output_queue)
|
@@ -313,39 +322,86 @@ class LogStash::Inputs::Elasticsearch < LogStash::Inputs::Base
|
|
313
322
|
output_queue << event
|
314
323
|
end
|
315
324
|
|
325
|
+
def clear_scroll(scroll_id)
|
326
|
+
@client.clear_scroll(scroll_id: scroll_id) if scroll_id
|
327
|
+
rescue => e
|
328
|
+
# ignore & log any clear_scroll errors
|
329
|
+
logger.warn("Ignoring clear_scroll exception", message: e.message)
|
330
|
+
end
|
331
|
+
|
316
332
|
def scroll_request scroll_id
|
317
|
-
client.scroll(:body => { :scroll_id => scroll_id }, :scroll => @scroll)
|
333
|
+
@client.scroll(:body => { :scroll_id => scroll_id }, :scroll => @scroll)
|
318
334
|
end
|
319
335
|
|
320
336
|
def search_request(options)
|
321
|
-
client.search(options)
|
337
|
+
@client.search(options)
|
322
338
|
end
|
323
339
|
|
324
|
-
attr_reader :client
|
325
|
-
|
326
340
|
def hosts_default?(hosts)
|
327
341
|
hosts.nil? || ( hosts.is_a?(Array) && hosts.empty? )
|
328
342
|
end
|
329
343
|
|
330
|
-
def
|
331
|
-
|
344
|
+
def validate_authentication
|
345
|
+
authn_options = 0
|
346
|
+
authn_options += 1 if @cloud_auth
|
347
|
+
authn_options += 1 if (@api_key && @api_key.value)
|
348
|
+
authn_options += 1 if (@user || (@password && @password.value))
|
332
349
|
|
333
|
-
if
|
334
|
-
raise LogStash::ConfigurationError, '
|
350
|
+
if authn_options > 1
|
351
|
+
raise LogStash::ConfigurationError, 'Multiple authentication options are specified, please only use one of user/password, cloud_auth or api_key'
|
335
352
|
end
|
336
|
-
|
353
|
+
|
354
|
+
if @api_key && @api_key.value && @ssl != true
|
355
|
+
raise(LogStash::ConfigurationError, "Using api_key authentication requires SSL/TLS secured communication using the `ssl => true` option")
|
356
|
+
end
|
357
|
+
end
|
358
|
+
|
359
|
+
def setup_ssl
|
360
|
+
@ssl && @ca_file ? { :ssl => true, :ca_file => @ca_file } : {}
|
361
|
+
end
|
362
|
+
|
363
|
+
def setup_hosts
|
364
|
+
@hosts = Array(@hosts).map { |host| host.to_s } # potential SafeURI#to_s
|
365
|
+
if @ssl
|
366
|
+
@hosts.map do |h|
|
367
|
+
host, port = h.split(":")
|
368
|
+
{ :host => host, :scheme => 'https', :port => port }
|
369
|
+
end
|
370
|
+
else
|
371
|
+
@hosts
|
372
|
+
end
|
373
|
+
end
|
374
|
+
|
375
|
+
def setup_basic_auth(user, password)
|
376
|
+
return {} unless user && password && password.value
|
377
|
+
|
378
|
+
token = ::Base64.strict_encode64("#{user}:#{password.value}")
|
379
|
+
{ Authorization: "Basic #{token}" }
|
380
|
+
end
|
381
|
+
|
382
|
+
def setup_api_key(api_key)
|
383
|
+
return {} unless (api_key && api_key.value)
|
384
|
+
|
385
|
+
token = ::Base64.strict_encode64(api_key.value)
|
386
|
+
{ Authorization: "ApiKey #{token}" }
|
337
387
|
end
|
338
388
|
|
339
389
|
def fill_user_password_from_cloud_auth
|
340
390
|
return unless @cloud_auth
|
341
391
|
|
342
|
-
if @user || @password
|
343
|
-
raise LogStash::ConfigurationError, 'Both cloud_auth and user/password specified, please only use one.'
|
344
|
-
end
|
345
392
|
@user, @password = parse_user_password_from_cloud_auth(@cloud_auth)
|
346
393
|
params['user'], params['password'] = @user, @password
|
347
394
|
end
|
348
395
|
|
396
|
+
def fill_hosts_from_cloud_id
|
397
|
+
return unless @cloud_id
|
398
|
+
|
399
|
+
if @hosts && !hosts_default?(@hosts)
|
400
|
+
raise LogStash::ConfigurationError, 'Both cloud_id and hosts specified, please only use one of those.'
|
401
|
+
end
|
402
|
+
@hosts = parse_host_uri_from_cloud_id(@cloud_id)
|
403
|
+
end
|
404
|
+
|
349
405
|
def parse_host_uri_from_cloud_id(cloud_id)
|
350
406
|
begin # might not be available on older LS
|
351
407
|
require 'logstash/util/cloud_setting_id'
|
@@ -380,4 +436,42 @@ class LogStash::Inputs::Elasticsearch < LogStash::Inputs::Base
|
|
380
436
|
[ cloud_auth.username, cloud_auth.password ]
|
381
437
|
end
|
382
438
|
|
439
|
+
module URIOrEmptyValidator
|
440
|
+
##
|
441
|
+
# @override to provide :uri_or_empty validator
|
442
|
+
# @param value [Array<Object>]
|
443
|
+
# @param validator [nil,Array,Symbol]
|
444
|
+
# @return [Array(true,Object)]: if validation is a success, a tuple containing `true` and the coerced value
|
445
|
+
# @return [Array(false,String)]: if validation is a failure, a tuple containing `false` and the failure reason.
|
446
|
+
def validate_value(value, validator)
|
447
|
+
return super unless validator == :uri_or_empty
|
448
|
+
|
449
|
+
value = deep_replace(value)
|
450
|
+
value = hash_or_array(value)
|
451
|
+
|
452
|
+
return true, value.first if value.size == 1 && value.first.empty?
|
453
|
+
|
454
|
+
return super(value, :uri)
|
455
|
+
end
|
456
|
+
end
|
457
|
+
extend(URIOrEmptyValidator)
|
458
|
+
|
459
|
+
module PositiveWholeNumberValidator
|
460
|
+
##
|
461
|
+
# @override to provide :positive_whole_number validator
|
462
|
+
# @param value [Array<Object>]
|
463
|
+
# @param validator [nil,Array,Symbol]
|
464
|
+
# @return [Array(true,Object)]: if validation is a success, a tuple containing `true` and the coerced value
|
465
|
+
# @return [Array(false,String)]: if validation is a failure, a tuple containing `false` and the failure reason.
|
466
|
+
def validate_value(value, validator)
|
467
|
+
return super unless validator == :positive_whole_number
|
468
|
+
|
469
|
+
is_number, coerced_number = super(value, :number)
|
470
|
+
|
471
|
+
return [true, coerced_number.to_i] if is_number && coerced_number.denominator == 1 && coerced_number > 0
|
472
|
+
|
473
|
+
return [false, "Expected positive whole number, got `#{value.inspect}`"]
|
474
|
+
end
|
475
|
+
end
|
476
|
+
extend(PositiveWholeNumberValidator)
|
383
477
|
end
|
@@ -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.8.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"
|
@@ -1,5 +1,6 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
require "logstash/devutils/rspec/spec_helper"
|
3
|
+
require "logstash/devutils/rspec/shared_examples"
|
3
4
|
require "logstash/inputs/elasticsearch"
|
4
5
|
require "elasticsearch"
|
5
6
|
require "timecop"
|
@@ -7,9 +8,13 @@ require "stud/temporary"
|
|
7
8
|
require "time"
|
8
9
|
require "date"
|
9
10
|
|
10
|
-
|
11
|
+
class LogStash::Inputs::TestableElasticsearch < LogStash::Inputs::Elasticsearch
|
12
|
+
attr_reader :client
|
13
|
+
end
|
14
|
+
|
15
|
+
describe LogStash::Inputs::TestableElasticsearch do
|
11
16
|
|
12
|
-
let(:plugin) { LogStash::Inputs::
|
17
|
+
let(:plugin) { LogStash::Inputs::TestableElasticsearch.new(config) }
|
13
18
|
let(:queue) { Queue.new }
|
14
19
|
|
15
20
|
it_behaves_like "an interruptible input plugin" do
|
@@ -31,6 +36,7 @@ describe LogStash::Inputs::Elasticsearch do
|
|
31
36
|
}
|
32
37
|
allow(esclient).to receive(:search) { { "hits" => { "hits" => [hit] } } }
|
33
38
|
allow(esclient).to receive(:scroll) { { "hits" => { "hits" => [hit] } } }
|
39
|
+
allow(esclient).to receive(:clear_scroll).and_return(nil)
|
34
40
|
end
|
35
41
|
end
|
36
42
|
|
@@ -75,13 +81,14 @@ describe LogStash::Inputs::Elasticsearch do
|
|
75
81
|
expect(Elasticsearch::Client).to receive(:new).with(any_args).and_return(client)
|
76
82
|
expect(client).to receive(:search).with(any_args).and_return(response)
|
77
83
|
expect(client).to receive(:scroll).with({ :body => { :scroll_id => "cXVlcnlUaGVuRmV0Y2g" }, :scroll=> "1m" }).and_return(scroll_reponse)
|
84
|
+
expect(client).to receive(:clear_scroll).and_return(nil)
|
78
85
|
|
79
86
|
event = input(config) do |pipeline, queue|
|
80
87
|
queue.pop
|
81
88
|
end
|
82
89
|
|
83
|
-
|
84
|
-
|
90
|
+
expect(event).to be_a(LogStash::Event)
|
91
|
+
expect(event.get("message")).to eql [ "ohayo" ]
|
85
92
|
end
|
86
93
|
|
87
94
|
|
@@ -256,6 +263,8 @@ describe LogStash::Inputs::Elasticsearch do
|
|
256
263
|
expect(Elasticsearch::Client).to receive(:new).with(any_args).and_return(client)
|
257
264
|
plugin.register
|
258
265
|
|
266
|
+
expect(client).to receive(:clear_scroll).and_return(nil)
|
267
|
+
|
259
268
|
# SLICE0 is a three-page scroll in which the last page is empty
|
260
269
|
slice0_query = LogStash::Json.dump(query.merge('slice' => { 'id' => 0, 'max' => 2}))
|
261
270
|
expect(client).to receive(:search).with(hash_including(:body => slice0_query)).and_return(slice0_response0)
|
@@ -359,6 +368,7 @@ describe LogStash::Inputs::Elasticsearch do
|
|
359
368
|
expect(Elasticsearch::Client).to receive(:new).with(any_args).and_return(client)
|
360
369
|
expect(client).to receive(:search).with(any_args).and_return(response)
|
361
370
|
allow(client).to receive(:scroll).with({ :body => {:scroll_id => "cXVlcnlUaGVuRmV0Y2g"}, :scroll => "1m" }).and_return(scroll_reponse)
|
371
|
+
allow(client).to receive(:clear_scroll).and_return(nil)
|
362
372
|
end
|
363
373
|
|
364
374
|
context 'when defining docinfo' do
|
@@ -404,6 +414,7 @@ describe LogStash::Inputs::Elasticsearch do
|
|
404
414
|
"docinfo_target" => 'metadata_with_string'
|
405
415
|
} }
|
406
416
|
it 'thows an exception if the `docinfo_target` exist but is not of type hash' do
|
417
|
+
expect(client).not_to receive(:clear_scroll)
|
407
418
|
plugin.register
|
408
419
|
expect { plugin.run([]) }.to raise_error(Exception, /incompatible event/)
|
409
420
|
end
|
@@ -572,7 +583,37 @@ describe LogStash::Inputs::Elasticsearch do
|
|
572
583
|
let(:config) { super.merge({ 'cloud_auth' => 'elastic:my-passwd-00', 'user' => 'another' }) }
|
573
584
|
|
574
585
|
it "should fail" do
|
575
|
-
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
|
576
617
|
end
|
577
618
|
end
|
578
619
|
end if LOGSTASH_VERSION > '6.0'
|
@@ -599,6 +640,54 @@ describe LogStash::Inputs::Elasticsearch do
|
|
599
640
|
end
|
600
641
|
end
|
601
642
|
end
|
643
|
+
|
644
|
+
shared_examples'configurable timeout' do |config_name, manticore_transport_option|
|
645
|
+
let(:config_value) { fail NotImplementedError }
|
646
|
+
let(:config) { super().merge(config_name => config_value) }
|
647
|
+
{
|
648
|
+
:string => 'banana',
|
649
|
+
:negative => -123,
|
650
|
+
:zero => 0,
|
651
|
+
}.each do |value_desc, value|
|
652
|
+
let(:config_value) { value }
|
653
|
+
context "with an invalid #{value_desc} value" do
|
654
|
+
it 'prevents instantiation with a helpful message' do
|
655
|
+
expect(described_class.logger).to receive(:error).with(/Expected positive whole number/)
|
656
|
+
expect { described_class.new(config) }.to raise_error(LogStash::ConfigurationError)
|
657
|
+
end
|
658
|
+
end
|
659
|
+
end
|
660
|
+
|
661
|
+
context 'with a valid value' do
|
662
|
+
let(:config_value) { 17 }
|
663
|
+
|
664
|
+
it "instantiates the elasticsearch client with the timeout value set via #{manticore_transport_option} in the transport options" do
|
665
|
+
expect(Elasticsearch::Client).to receive(:new) do |new_elasticsearch_client_params|
|
666
|
+
# We rely on Manticore-specific transport options, fail early if we are using a different
|
667
|
+
# transport or are allowing the client to determine its own transport class.
|
668
|
+
expect(new_elasticsearch_client_params).to include(:transport_class)
|
669
|
+
expect(new_elasticsearch_client_params[:transport_class].name).to match(/\bManticore\b/)
|
670
|
+
|
671
|
+
expect(new_elasticsearch_client_params).to include(:transport_options)
|
672
|
+
transport_options = new_elasticsearch_client_params[:transport_options]
|
673
|
+
expect(transport_options).to include(manticore_transport_option)
|
674
|
+
expect(transport_options[manticore_transport_option]).to eq(config_value.to_i)
|
675
|
+
end
|
676
|
+
|
677
|
+
plugin.register
|
678
|
+
end
|
679
|
+
end
|
680
|
+
end
|
681
|
+
|
682
|
+
context 'connect_timeout_seconds' do
|
683
|
+
include_examples('configurable timeout', 'connect_timeout_seconds', :connect_timeout)
|
684
|
+
end
|
685
|
+
context 'request_timeout_seconds' do
|
686
|
+
include_examples('configurable timeout', 'request_timeout_seconds', :request_timeout)
|
687
|
+
end
|
688
|
+
context 'socket_timeout_seconds' do
|
689
|
+
include_examples('configurable timeout', 'socket_timeout_seconds', :socket_timeout)
|
690
|
+
end
|
602
691
|
end
|
603
692
|
|
604
693
|
context "when scheduling" do
|
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.8.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-
|
11
|
+
date: 2020-08-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|