logstash-input-elasticsearch 4.4.0 → 4.7.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 +16 -1
- data/LICENSE +199 -10
- data/docs/index.asciidoc +56 -18
- data/lib/logstash/inputs/elasticsearch.rb +186 -28
- data/logstash-input-elasticsearch.gemspec +1 -1
- data/spec/inputs/elasticsearch_spec.rb +142 -33
- 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,5 +1,20 @@
|
|
|
1
|
+
## 4.7.0
|
|
2
|
+
- Added api_key support [#131](https://github.com/logstash-plugins/logstash-input-elasticsearch/pull/131)
|
|
3
|
+
|
|
4
|
+
## 4.6.2
|
|
5
|
+
- Added scroll clearing and better handling of scroll expiration [#128](https://github.com/logstash-plugins/logstash-input-elasticsearch/pull/128)
|
|
6
|
+
|
|
7
|
+
## 4.6.1
|
|
8
|
+
- [DOC] Removed outdated compatibility notice [#124](https://github.com/logstash-plugins/logstash-input-elasticsearch/pull/124)
|
|
9
|
+
|
|
10
|
+
## 4.6.0
|
|
11
|
+
- Feat: added option to specify proxy for ES [#114](https://github.com/logstash-plugins/logstash-input-elasticsearch/pull/114)
|
|
12
|
+
|
|
13
|
+
## 4.5.0
|
|
14
|
+
- Feat: Added support for cloud_id / cloud_auth configuration [#112](https://github.com/logstash-plugins/logstash-input-elasticsearch/pull/112)
|
|
15
|
+
|
|
1
16
|
## 4.4.0
|
|
2
|
-
- Changed Elasticsearch Client transport to use Manticore[#111](https://github.com/logstash-plugins/logstash-input-elasticsearch/pull/111)
|
|
17
|
+
- Changed Elasticsearch Client transport to use Manticore [#111](https://github.com/logstash-plugins/logstash-input-elasticsearch/pull/111)
|
|
3
18
|
|
|
4
19
|
## 4.3.3
|
|
5
20
|
- Loosen restrictions on Elasticsearch gem [#110](https://github.com/logstash-plugins/logstash-input-elasticsearch/pull/110)
|
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,13 +86,17 @@ This plugin supports the following configuration options plus the < |
|
|
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
|
|
91
|
+
| <<plugins-{type}s-{plugin}-cloud_auth>> |<<password,password>>|No
|
|
92
|
+
| <<plugins-{type}s-{plugin}-cloud_id>> |<<string,string>>|No
|
|
90
93
|
| <<plugins-{type}s-{plugin}-docinfo>> |<<boolean,boolean>>|No
|
|
91
94
|
| <<plugins-{type}s-{plugin}-docinfo_fields>> |<<array,array>>|No
|
|
92
95
|
| <<plugins-{type}s-{plugin}-docinfo_target>> |<<string,string>>|No
|
|
93
96
|
| <<plugins-{type}s-{plugin}-hosts>> |<<array,array>>|No
|
|
94
97
|
| <<plugins-{type}s-{plugin}-index>> |<<string,string>>|No
|
|
95
98
|
| <<plugins-{type}s-{plugin}-password>> |<<password,password>>|No
|
|
99
|
+
| <<plugins-{type}s-{plugin}-proxy>> |<<uri,uri>>|No
|
|
96
100
|
| <<plugins-{type}s-{plugin}-query>> |<<string,string>>|No
|
|
97
101
|
| <<plugins-{type}s-{plugin}-schedule>> |<<string,string>>|No
|
|
98
102
|
| <<plugins-{type}s-{plugin}-scroll>> |<<string,string>>|No
|
|
@@ -107,14 +111,43 @@ input plugins.
|
|
|
107
111
|
|
|
108
112
|
|
|
109
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
|
+
|
|
110
124
|
[id="plugins-{type}s-{plugin}-ca_file"]
|
|
111
125
|
===== `ca_file`
|
|
112
126
|
|
|
113
127
|
* Value type is <<path,path>>
|
|
114
128
|
* There is no default value for this setting.
|
|
115
129
|
|
|
116
|
-
SSL Certificate Authority file in PEM encoded format, must also
|
|
117
|
-
|
|
130
|
+
SSL Certificate Authority file in PEM encoded format, must also include any chain certificates as necessary.
|
|
131
|
+
|
|
132
|
+
[id="plugins-{type}s-{plugin}-cloud_auth"]
|
|
133
|
+
===== `cloud_auth`
|
|
134
|
+
|
|
135
|
+
* Value type is <<password,password>>
|
|
136
|
+
* There is no default value for this setting.
|
|
137
|
+
|
|
138
|
+
Cloud authentication string ("<username>:<password>" format) is an alternative for the `user`/`password` pair.
|
|
139
|
+
|
|
140
|
+
For more info, check out the https://www.elastic.co/guide/en/logstash/current/connecting-to-cloud.html#_cloud_auth[Logstash-to-Cloud documentation]
|
|
141
|
+
|
|
142
|
+
[id="plugins-{type}s-{plugin}-cloud_id"]
|
|
143
|
+
===== `cloud_id`
|
|
144
|
+
|
|
145
|
+
* Value type is <<string,string>>
|
|
146
|
+
* There is no default value for this setting.
|
|
147
|
+
|
|
148
|
+
Cloud ID, from the Elastic Cloud web console. If set `hosts` should not be used.
|
|
149
|
+
|
|
150
|
+
For more info, check out the https://www.elastic.co/guide/en/logstash/current/connecting-to-cloud.html#_cloud_id[Logstash-to-Cloud documentation]
|
|
118
151
|
|
|
119
152
|
[id="plugins-{type}s-{plugin}-docinfo"]
|
|
120
153
|
===== `docinfo`
|
|
@@ -152,11 +185,6 @@ Example
|
|
|
152
185
|
}
|
|
153
186
|
|
|
154
187
|
|
|
155
|
-
NOTE: Starting with Logstash 6.0, the `document_type` option is
|
|
156
|
-
deprecated due to the
|
|
157
|
-
https://www.elastic.co/guide/en/elasticsearch/reference/6.0/removal-of-types.html[removal of types in Logstash 6.0].
|
|
158
|
-
It will be removed in the next major version of Logstash.
|
|
159
|
-
|
|
160
188
|
[id="plugins-{type}s-{plugin}-docinfo_fields"]
|
|
161
189
|
===== `docinfo_fields`
|
|
162
190
|
|
|
@@ -210,6 +238,16 @@ The password to use together with the username in the `user` option
|
|
|
210
238
|
when authenticating to the Elasticsearch server. If set to an empty
|
|
211
239
|
string authentication will be disabled.
|
|
212
240
|
|
|
241
|
+
[id="plugins-{type}s-{plugin}-proxy"]
|
|
242
|
+
===== `proxy`
|
|
243
|
+
|
|
244
|
+
* Value type is <<uri,uri>>
|
|
245
|
+
* There is no default value for this setting.
|
|
246
|
+
|
|
247
|
+
Set the address of a forward HTTP proxy.
|
|
248
|
+
An empty string is treated as if proxy was not set, this is useful when using
|
|
249
|
+
environment variables e.g. `proxy => '${LS_PROXY:}'`.
|
|
250
|
+
|
|
213
251
|
[id="plugins-{type}s-{plugin}-query"]
|
|
214
252
|
===== `query`
|
|
215
253
|
|
|
@@ -298,4 +336,4 @@ empty string authentication will be disabled.
|
|
|
298
336
|
[id="plugins-{type}s-{plugin}-common-options"]
|
|
299
337
|
include::{include_path}/{type}.asciidoc[]
|
|
300
338
|
|
|
301
|
-
:default_codec!:
|
|
339
|
+
:default_codec!:
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
require "logstash/inputs/base"
|
|
3
3
|
require "logstash/namespace"
|
|
4
4
|
require "logstash/json"
|
|
5
|
+
require "logstash/util/safe_uri"
|
|
5
6
|
require "base64"
|
|
6
7
|
|
|
7
8
|
|
|
@@ -134,6 +135,23 @@ class LogStash::Inputs::Elasticsearch < LogStash::Inputs::Base
|
|
|
134
135
|
# Basic Auth - password
|
|
135
136
|
config :password, :validate => :password
|
|
136
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
|
+
# Cloud authentication string ("<username>:<password>" format) is an alternative for the `user`/`password` configuration.
|
|
144
|
+
#
|
|
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
|
+
config :cloud_auth, :validate => :password
|
|
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
|
+
|
|
152
|
+
# Set the address of a forward HTTP proxy.
|
|
153
|
+
config :proxy, :validate => :uri_or_empty
|
|
154
|
+
|
|
137
155
|
# SSL
|
|
138
156
|
config :ssl, :validate => :boolean, :default => false
|
|
139
157
|
|
|
@@ -163,29 +181,46 @@ class LogStash::Inputs::Elasticsearch < LogStash::Inputs::Base
|
|
|
163
181
|
@slices < 1 && fail(LogStash::ConfigurationError, "Elasticsearch Input Plugin's `slices` option must be greater than zero, got `#{@slices}`")
|
|
164
182
|
end
|
|
165
183
|
|
|
166
|
-
|
|
184
|
+
validate_authentication
|
|
185
|
+
fill_user_password_from_cloud_auth
|
|
186
|
+
fill_hosts_from_cloud_id
|
|
167
187
|
|
|
168
|
-
if @user && @password
|
|
169
|
-
token = Base64.strict_encode64("#{@user}:#{@password.value}")
|
|
170
|
-
transport_options[:headers] = { :Authorization => "Basic #{token}" }
|
|
171
|
-
end
|
|
172
188
|
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
{ :host => host, :scheme => 'https', :port => port }
|
|
177
|
-
end
|
|
178
|
-
else
|
|
179
|
-
@hosts
|
|
180
|
-
end
|
|
181
|
-
ssl_options = { :ssl => true, :ca_file => @ca_file } if @ssl && @ca_file
|
|
182
|
-
ssl_options ||= {}
|
|
189
|
+
transport_options = {:headers => {}}
|
|
190
|
+
transport_options[:headers].merge!(setup_basic_auth(user, password))
|
|
191
|
+
transport_options[:headers].merge!(setup_api_key(api_key))
|
|
183
192
|
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
193
|
+
hosts = setup_hosts
|
|
194
|
+
ssl_options = setup_ssl
|
|
195
|
+
|
|
196
|
+
@logger.warn "Supplied proxy setting (proxy => '') has no effect" if @proxy.eql?('')
|
|
197
|
+
|
|
198
|
+
transport_options[:proxy] = @proxy.to_s if @proxy && !@proxy.eql?('')
|
|
199
|
+
|
|
200
|
+
@client = Elasticsearch::Client.new(
|
|
201
|
+
:hosts => hosts,
|
|
202
|
+
:transport_options => transport_options,
|
|
203
|
+
:transport_class => ::Elasticsearch::Transport::Transport::HTTP::Manticore,
|
|
204
|
+
:ssl => ssl_options
|
|
205
|
+
)
|
|
187
206
|
end
|
|
188
207
|
|
|
208
|
+
##
|
|
209
|
+
# @override to handle proxy => '' as if none was set
|
|
210
|
+
# @param value [Array<Object>]
|
|
211
|
+
# @param validator [nil,Array,Symbol]
|
|
212
|
+
# @return [Array(true,Object)]: if validation is a success, a tuple containing `true` and the coerced value
|
|
213
|
+
# @return [Array(false,String)]: if validation is a failure, a tuple containing `false` and the failure reason.
|
|
214
|
+
def self.validate_value(value, validator)
|
|
215
|
+
return super unless validator == :uri_or_empty
|
|
216
|
+
|
|
217
|
+
value = deep_replace(value)
|
|
218
|
+
value = hash_or_array(value)
|
|
219
|
+
|
|
220
|
+
return true, value.first if value.size == 1 && value.first.empty?
|
|
221
|
+
|
|
222
|
+
return super(value, :uri)
|
|
223
|
+
end
|
|
189
224
|
|
|
190
225
|
def run(output_queue)
|
|
191
226
|
if @schedule
|
|
@@ -227,25 +262,41 @@ class LogStash::Inputs::Elasticsearch < LogStash::Inputs::Base
|
|
|
227
262
|
slice_options = @options.merge(:body => LogStash::Json.dump(slice_query) )
|
|
228
263
|
|
|
229
264
|
logger.info("Slice starting", slice_id: slice_id, slices: @slices) unless slice_id.nil?
|
|
230
|
-
r = search_request(slice_options)
|
|
231
|
-
|
|
232
|
-
r['hits']['hits'].each { |hit| push_hit(hit, output_queue) }
|
|
233
|
-
logger.debug("Slice progress", slice_id: slice_id, slices: @slices) unless slice_id.nil?
|
|
234
265
|
|
|
235
|
-
|
|
266
|
+
scroll_id = nil
|
|
267
|
+
begin
|
|
268
|
+
r = search_request(slice_options)
|
|
236
269
|
|
|
237
|
-
|
|
238
|
-
r = process_next_scroll(output_queue, r['_scroll_id'])
|
|
270
|
+
r['hits']['hits'].each { |hit| push_hit(hit, output_queue) }
|
|
239
271
|
logger.debug("Slice progress", slice_id: slice_id, slices: @slices) unless slice_id.nil?
|
|
240
|
-
|
|
272
|
+
|
|
273
|
+
has_hits = r['hits']['hits'].any?
|
|
274
|
+
scroll_id = r['_scroll_id']
|
|
275
|
+
|
|
276
|
+
while has_hits && scroll_id && !stop?
|
|
277
|
+
has_hits, scroll_id = process_next_scroll(output_queue, scroll_id)
|
|
278
|
+
logger.debug("Slice progress", slice_id: slice_id, slices: @slices) if logger.debug? && slice_id
|
|
279
|
+
end
|
|
280
|
+
logger.info("Slice complete", slice_id: slice_id, slices: @slices) unless slice_id.nil?
|
|
281
|
+
ensure
|
|
282
|
+
clear_scroll(scroll_id)
|
|
241
283
|
end
|
|
242
|
-
logger.info("Slice complete", slice_id: slice_id, slices: @slices) unless slice_id.nil?
|
|
243
284
|
end
|
|
244
285
|
|
|
286
|
+
##
|
|
287
|
+
# @param output_queue [#<<]
|
|
288
|
+
# @param scroll_id [String]: a scroll id to resume
|
|
289
|
+
# @return [Array(Boolean,String)]: a tuple representing whether the response
|
|
290
|
+
#
|
|
245
291
|
def process_next_scroll(output_queue, scroll_id)
|
|
246
292
|
r = scroll_request(scroll_id)
|
|
247
293
|
r['hits']['hits'].each { |hit| push_hit(hit, output_queue) }
|
|
248
|
-
|
|
294
|
+
[r['hits']['hits'].any?, r['_scroll_id']]
|
|
295
|
+
rescue => e
|
|
296
|
+
# this will typically be triggered by a scroll timeout
|
|
297
|
+
logger.error("Scroll request error, aborting scroll", error: e.inspect)
|
|
298
|
+
# return no hits and original scroll_id so we can try to clear it
|
|
299
|
+
[false, scroll_id]
|
|
249
300
|
end
|
|
250
301
|
|
|
251
302
|
def push_hit(hit, output_queue)
|
|
@@ -274,6 +325,13 @@ class LogStash::Inputs::Elasticsearch < LogStash::Inputs::Base
|
|
|
274
325
|
output_queue << event
|
|
275
326
|
end
|
|
276
327
|
|
|
328
|
+
def clear_scroll(scroll_id)
|
|
329
|
+
@client.clear_scroll(scroll_id: scroll_id) if scroll_id
|
|
330
|
+
rescue => e
|
|
331
|
+
# ignore & log any clear_scroll errors
|
|
332
|
+
logger.warn("Ignoring clear_scroll exception", message: e.message)
|
|
333
|
+
end
|
|
334
|
+
|
|
277
335
|
def scroll_request scroll_id
|
|
278
336
|
@client.scroll(:body => { :scroll_id => scroll_id }, :scroll => @scroll)
|
|
279
337
|
end
|
|
@@ -281,4 +339,104 @@ class LogStash::Inputs::Elasticsearch < LogStash::Inputs::Base
|
|
|
281
339
|
def search_request(options)
|
|
282
340
|
@client.search(options)
|
|
283
341
|
end
|
|
342
|
+
|
|
343
|
+
def hosts_default?(hosts)
|
|
344
|
+
hosts.nil? || ( hosts.is_a?(Array) && hosts.empty? )
|
|
345
|
+
end
|
|
346
|
+
|
|
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))
|
|
352
|
+
|
|
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'
|
|
355
|
+
end
|
|
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}" }
|
|
390
|
+
end
|
|
391
|
+
|
|
392
|
+
def fill_user_password_from_cloud_auth
|
|
393
|
+
return unless @cloud_auth
|
|
394
|
+
|
|
395
|
+
@user, @password = parse_user_password_from_cloud_auth(@cloud_auth)
|
|
396
|
+
params['user'], params['password'] = @user, @password
|
|
397
|
+
end
|
|
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
|
+
|
|
408
|
+
def parse_host_uri_from_cloud_id(cloud_id)
|
|
409
|
+
begin # might not be available on older LS
|
|
410
|
+
require 'logstash/util/cloud_setting_id'
|
|
411
|
+
rescue LoadError
|
|
412
|
+
raise LogStash::ConfigurationError, 'The cloud_id setting is not supported by your version of Logstash, ' +
|
|
413
|
+
'please upgrade your installation (or set hosts instead).'
|
|
414
|
+
end
|
|
415
|
+
|
|
416
|
+
begin
|
|
417
|
+
cloud_id = LogStash::Util::CloudSettingId.new(cloud_id) # already does append ':{port}' to host
|
|
418
|
+
rescue ArgumentError => e
|
|
419
|
+
raise LogStash::ConfigurationError, e.message.to_s.sub(/Cloud Id/i, 'cloud_id')
|
|
420
|
+
end
|
|
421
|
+
cloud_uri = "#{cloud_id.elasticsearch_scheme}://#{cloud_id.elasticsearch_host}"
|
|
422
|
+
LogStash::Util::SafeURI.new(cloud_uri)
|
|
423
|
+
end
|
|
424
|
+
|
|
425
|
+
def parse_user_password_from_cloud_auth(cloud_auth)
|
|
426
|
+
begin # might not be available on older LS
|
|
427
|
+
require 'logstash/util/cloud_setting_auth'
|
|
428
|
+
rescue LoadError
|
|
429
|
+
raise LogStash::ConfigurationError, 'The cloud_auth setting is not supported by your version of Logstash, ' +
|
|
430
|
+
'please upgrade your installation (or set user/password instead).'
|
|
431
|
+
end
|
|
432
|
+
|
|
433
|
+
cloud_auth = cloud_auth.value if cloud_auth.is_a?(LogStash::Util::Password)
|
|
434
|
+
begin
|
|
435
|
+
cloud_auth = LogStash::Util::CloudSettingAuth.new(cloud_auth)
|
|
436
|
+
rescue ArgumentError => e
|
|
437
|
+
raise LogStash::ConfigurationError, e.message.to_s.sub(/Cloud Auth/i, 'cloud_auth')
|
|
438
|
+
end
|
|
439
|
+
[ cloud_auth.username, cloud_auth.password ]
|
|
440
|
+
end
|
|
441
|
+
|
|
284
442
|
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.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"
|
|
@@ -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
|
|
@@ -504,6 +515,133 @@ describe LogStash::Inputs::Elasticsearch do
|
|
|
504
515
|
end
|
|
505
516
|
end
|
|
506
517
|
|
|
518
|
+
describe "client" do
|
|
519
|
+
let(:config) do
|
|
520
|
+
{
|
|
521
|
+
|
|
522
|
+
}
|
|
523
|
+
end
|
|
524
|
+
let(:plugin) { described_class.new(config) }
|
|
525
|
+
let(:event) { LogStash::Event.new({}) }
|
|
526
|
+
|
|
527
|
+
describe "cloud.id" do
|
|
528
|
+
let(:valid_cloud_id) do
|
|
529
|
+
'sample:dXMtY2VudHJhbDEuZ2NwLmNsb3VkLmVzLmlvJGFjMzFlYmI5MDI0MTc3MzE1NzA0M2MzNGZkMjZmZDQ2OjkyNDMkYTRjMDYyMzBlNDhjOGZjZTdiZTg4YTA3NGEzYmIzZTA6OTI0NA=='
|
|
530
|
+
end
|
|
531
|
+
|
|
532
|
+
let(:config) { super.merge({ 'cloud_id' => valid_cloud_id }) }
|
|
533
|
+
|
|
534
|
+
it "should set host(s)" do
|
|
535
|
+
plugin.register
|
|
536
|
+
client = plugin.send(:client)
|
|
537
|
+
expect( client.transport.hosts ).to eql [{
|
|
538
|
+
:scheme => "https",
|
|
539
|
+
:host => "ac31ebb90241773157043c34fd26fd46.us-central1.gcp.cloud.es.io",
|
|
540
|
+
:port => 9243,
|
|
541
|
+
:path => "",
|
|
542
|
+
:protocol => "https"
|
|
543
|
+
}]
|
|
544
|
+
end
|
|
545
|
+
|
|
546
|
+
context 'invalid' do
|
|
547
|
+
let(:config) { super.merge({ 'cloud_id' => 'invalid:dXMtY2VudHJhbDEuZ2NwLmNsb3VkLmVzLmlv' }) }
|
|
548
|
+
|
|
549
|
+
it "should fail" do
|
|
550
|
+
expect { plugin.register }.to raise_error LogStash::ConfigurationError, /cloud_id.*? is invalid/
|
|
551
|
+
end
|
|
552
|
+
end
|
|
553
|
+
|
|
554
|
+
context 'hosts also set' do
|
|
555
|
+
let(:config) { super.merge({ 'cloud_id' => valid_cloud_id, 'hosts' => [ 'localhost:9200' ] }) }
|
|
556
|
+
|
|
557
|
+
it "should fail" do
|
|
558
|
+
expect { plugin.register }.to raise_error LogStash::ConfigurationError, /cloud_id and hosts/
|
|
559
|
+
end
|
|
560
|
+
end
|
|
561
|
+
end if LOGSTASH_VERSION > '6.0'
|
|
562
|
+
|
|
563
|
+
describe "cloud.auth" do
|
|
564
|
+
let(:config) { super.merge({ 'cloud_auth' => LogStash::Util::Password.new('elastic:my-passwd-00') }) }
|
|
565
|
+
|
|
566
|
+
it "should set authorization" do
|
|
567
|
+
plugin.register
|
|
568
|
+
client = plugin.send(:client)
|
|
569
|
+
auth_header = client.transport.options[:transport_options][:headers][:Authorization]
|
|
570
|
+
|
|
571
|
+
expect( auth_header ).to eql "Basic #{Base64.encode64('elastic:my-passwd-00').rstrip}"
|
|
572
|
+
end
|
|
573
|
+
|
|
574
|
+
context 'invalid' do
|
|
575
|
+
let(:config) { super.merge({ 'cloud_auth' => 'invalid-format' }) }
|
|
576
|
+
|
|
577
|
+
it "should fail" do
|
|
578
|
+
expect { plugin.register }.to raise_error LogStash::ConfigurationError, /cloud_auth.*? format/
|
|
579
|
+
end
|
|
580
|
+
end
|
|
581
|
+
|
|
582
|
+
context 'user also set' do
|
|
583
|
+
let(:config) { super.merge({ 'cloud_auth' => 'elastic:my-passwd-00', 'user' => 'another' }) }
|
|
584
|
+
|
|
585
|
+
it "should fail" do
|
|
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
|
|
617
|
+
end
|
|
618
|
+
end
|
|
619
|
+
end if LOGSTASH_VERSION > '6.0'
|
|
620
|
+
|
|
621
|
+
describe "proxy" do
|
|
622
|
+
let(:config) { super.merge({ 'proxy' => 'http://localhost:1234' }) }
|
|
623
|
+
|
|
624
|
+
it "should set proxy" do
|
|
625
|
+
plugin.register
|
|
626
|
+
client = plugin.send(:client)
|
|
627
|
+
proxy = client.transport.options[:transport_options][:proxy]
|
|
628
|
+
|
|
629
|
+
expect( proxy ).to eql "http://localhost:1234"
|
|
630
|
+
end
|
|
631
|
+
|
|
632
|
+
context 'invalid' do
|
|
633
|
+
let(:config) { super.merge({ 'proxy' => '${A_MISSING_ENV_VAR:}' }) }
|
|
634
|
+
|
|
635
|
+
it "should not set proxy" do
|
|
636
|
+
plugin.register
|
|
637
|
+
client = plugin.send(:client)
|
|
638
|
+
|
|
639
|
+
expect( client.transport.options[:transport_options] ).to_not include(:proxy)
|
|
640
|
+
end
|
|
641
|
+
end
|
|
642
|
+
end
|
|
643
|
+
end
|
|
644
|
+
|
|
507
645
|
context "when scheduling" do
|
|
508
646
|
let(:config) do
|
|
509
647
|
{
|
|
@@ -513,39 +651,11 @@ describe LogStash::Inputs::Elasticsearch do
|
|
|
513
651
|
}
|
|
514
652
|
end
|
|
515
653
|
|
|
516
|
-
response = {
|
|
517
|
-
"_scroll_id" => "cXVlcnlUaGVuRmV0Y2g",
|
|
518
|
-
"took" => 27,
|
|
519
|
-
"timed_out" => false,
|
|
520
|
-
"_shards" => {
|
|
521
|
-
"total" => 169,
|
|
522
|
-
"successful" => 169,
|
|
523
|
-
"failed" => 0
|
|
524
|
-
},
|
|
525
|
-
"hits" => {
|
|
526
|
-
"total" => 1,
|
|
527
|
-
"max_score" => 1.0,
|
|
528
|
-
"hits" => [ {
|
|
529
|
-
"_index" => "logstash-2014.10.12",
|
|
530
|
-
"_type" => "logs",
|
|
531
|
-
"_id" => "C5b2xLQwTZa76jBmHIbwHQ",
|
|
532
|
-
"_score" => 1.0,
|
|
533
|
-
"_source" => { "message" => ["ohayo"] }
|
|
534
|
-
} ]
|
|
535
|
-
}
|
|
536
|
-
}
|
|
537
|
-
|
|
538
|
-
scroll_reponse = {
|
|
539
|
-
"_scroll_id" => "r453Wc1jh0caLJhSDg",
|
|
540
|
-
"hits" => { "hits" => [] }
|
|
541
|
-
}
|
|
542
|
-
|
|
543
654
|
before do
|
|
544
655
|
plugin.register
|
|
545
656
|
end
|
|
546
657
|
|
|
547
658
|
it "should properly schedule" do
|
|
548
|
-
|
|
549
659
|
Timecop.travel(Time.new(2000))
|
|
550
660
|
Timecop.scale(60)
|
|
551
661
|
runner = Thread.new do
|
|
@@ -564,5 +674,4 @@ describe LogStash::Inputs::Elasticsearch do
|
|
|
564
674
|
end
|
|
565
675
|
|
|
566
676
|
end
|
|
567
|
-
|
|
568
677
|
end
|
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:
|
|
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
|