logstash-filter-elasticsearch 3.19.1 → 4.0.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 +9 -14
- data/docs/index.asciidoc +25 -246
- data/lib/logstash/filters/elasticsearch/client.rb +4 -57
- data/lib/logstash/filters/elasticsearch.rb +125 -179
- data/logstash-filter-elasticsearch.gemspec +4 -7
- data/spec/filters/elasticsearch_spec.rb +278 -206
- data/spec/filters/elasticsearch_ssl_spec.rb +17 -0
- data/spec/filters/integration/elasticsearch_spec.rb +2 -9
- metadata +14 -68
- data/lib/logstash/filters/elasticsearch/dsl_executor.rb +0 -140
- data/lib/logstash/filters/elasticsearch/esql_executor.rb +0 -178
- data/spec/filters/elasticsearch_dsl_spec.rb +0 -372
- data/spec/filters/elasticsearch_esql_spec.rb +0 -211
- data/spec/filters/integration/elasticsearch_esql_spec.rb +0 -167
- data/version +0 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 015a98dbd36122dd3fc4c74da5744a31f6182f67023f802189cc73e837d5ba7a
|
|
4
|
+
data.tar.gz: 8f1c3a79c0af3fc4154501d16bf775e01b6aa7575627852cb18954a0dd952d91
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: fc3971541568e34c0ef644c250243fefcb48c778b2471f81f5e87a1b59535a6f5ccc2a2c13d57f5123e0577efb80962b85f8096d3d6f70e0721df4f716d705e1
|
|
7
|
+
data.tar.gz: 5fe74aa6d8179e6dd3d9c69a6d0c81f284035bd82343543132f129be7bfb3355e01678eddbd051d9d4c360e9704f8a234737096e757f710b395b5d366f57936f
|
data/CHANGELOG.md
CHANGED
|
@@ -1,17 +1,12 @@
|
|
|
1
|
-
##
|
|
2
|
-
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
## 3.17.1
|
|
11
|
-
- Add elastic-transport client support used in elasticsearch-ruby 8.x [#193](https://github.com/logstash-plugins/logstash-filter-elasticsearch/pull/193)
|
|
12
|
-
|
|
13
|
-
## 3.17.0
|
|
14
|
-
- Added support for custom headers [#190](https://github.com/logstash-plugins/logstash-filter-elasticsearch/pull/190)
|
|
1
|
+
## 4.0.0
|
|
2
|
+
- SSL settings that were marked deprecated in version `3.15.0` are now marked obsolete, and will prevent the plugin from starting.
|
|
3
|
+
- These settings are:
|
|
4
|
+
- `ca_file`, which should be replaced by `ssl_certificate_authorities`
|
|
5
|
+
- `keystore`, which should be replaced by `ssl_keystore_path`
|
|
6
|
+
- `keystore_password`, which should be replaced by `ssl_keystore_password`
|
|
7
|
+
- `keystore_type`, which should be replaced by `ssl_keystore_password`
|
|
8
|
+
- `ssl`, which should be replaced by `ssl_enabled`
|
|
9
|
+
- [#183](https://github.com/logstash-plugins/logstash-filter-elasticsearch/pull/183)
|
|
15
10
|
|
|
16
11
|
## 3.16.2
|
|
17
12
|
- Add `x-elastic-product-origin` header to Elasticsearch requests [#185](https://github.com/logstash-plugins/logstash-filter-elasticsearch/pull/185)
|
data/docs/index.asciidoc
CHANGED
|
@@ -54,7 +54,7 @@ if [type] == "end" {
|
|
|
54
54
|
|
|
55
55
|
The example below reproduces the above example but utilises the query_template.
|
|
56
56
|
This query_template represents a full Elasticsearch query DSL and supports the
|
|
57
|
-
standard
|
|
57
|
+
standard Logstash field substitution syntax. The example below issues
|
|
58
58
|
the same query as the first example but uses the template shown.
|
|
59
59
|
|
|
60
60
|
[source,ruby]
|
|
@@ -110,7 +110,7 @@ Authentication to a secure Elasticsearch cluster is possible using _one_ of the
|
|
|
110
110
|
* <<plugins-{type}s-{plugin}-user>> AND <<plugins-{type}s-{plugin}-password>>
|
|
111
111
|
* <<plugins-{type}s-{plugin}-cloud_auth>>
|
|
112
112
|
* <<plugins-{type}s-{plugin}-api_key>>
|
|
113
|
-
* <<plugins-{type}s-{plugin}-
|
|
113
|
+
* <<plugins-{type}s-{plugin}-ssl_keystore_path>> and/or <<plugins-{type}s-{plugin}-ssl_keystore_password>>
|
|
114
114
|
|
|
115
115
|
[id="plugins-{type}s-{plugin}-autz"]
|
|
116
116
|
==== Authorization
|
|
@@ -118,114 +118,13 @@ Authentication to a secure Elasticsearch cluster is possible using _one_ of the
|
|
|
118
118
|
Authorization to a secure Elasticsearch cluster requires `read` permission at index level and `monitoring` permissions at cluster level.
|
|
119
119
|
The `monitoring` permission at cluster level is necessary to perform periodic connectivity checks.
|
|
120
120
|
|
|
121
|
-
[id="plugins-{type}s-{plugin}-esql"]
|
|
122
|
-
==== {esql} support
|
|
123
|
-
|
|
124
|
-
.Technical Preview
|
|
125
|
-
****
|
|
126
|
-
The {esql} feature that allows using ES|QL queries with this plugin is in Technical Preview.
|
|
127
|
-
Configuration options and implementation details are subject to change in minor releases without being preceded by deprecation warnings.
|
|
128
|
-
****
|
|
129
|
-
|
|
130
|
-
{es} Query Language ({esql}) provides a SQL-like interface for querying your {es} data.
|
|
131
|
-
|
|
132
|
-
To use {esql}, this plugin needs to be installed in {ls} 8.17.4 or newer, and must be connected to {es} 8.11 or newer.
|
|
133
|
-
|
|
134
|
-
To configure {esql} query in the plugin, set your {esql} query in the `query` parameter.
|
|
135
|
-
|
|
136
|
-
IMPORTANT: We recommend understanding {ref}/esql-limitations.html[{esql} current limitations] before using it in production environments.
|
|
137
|
-
|
|
138
|
-
The following is a basic {esql} query that sets the food name to transaction event based on upstream event's food ID:
|
|
139
|
-
[source, ruby]
|
|
140
|
-
filter {
|
|
141
|
-
elasticsearch {
|
|
142
|
-
hosts => [ 'https://..']
|
|
143
|
-
api_key => '....'
|
|
144
|
-
query => '
|
|
145
|
-
FROM food-index
|
|
146
|
-
| WHERE id == ?food_id
|
|
147
|
-
'
|
|
148
|
-
query_params => {
|
|
149
|
-
"food_id" => "[food][id]"
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
Set `config.support_escapes: true` in `logstash.yml` if you need to escape special chars in the query.
|
|
155
|
-
|
|
156
|
-
In the result event, the plugin sets total result size in `[@metadata][total_values]` field.
|
|
157
|
-
|
|
158
|
-
[id="plugins-{type}s-{plugin}-esql-event-mapping"]
|
|
159
|
-
===== Mapping {esql} result to {ls} event
|
|
160
|
-
{esql} returns query results in a structured tabular format, where data is organized into _columns_ (fields) and _values_ (entries).
|
|
161
|
-
The plugin maps each value entry to an event, populating corresponding fields.
|
|
162
|
-
For example, a query might produce a table like:
|
|
163
|
-
|
|
164
|
-
[cols="2,1,1,1,2",options="header"]
|
|
165
|
-
|===
|
|
166
|
-
|`timestamp` |`user_id` | `action` | `status.code` | `status.desc`
|
|
167
|
-
|
|
168
|
-
|2025-04-10T12:00:00 |123 |login |200 | Success
|
|
169
|
-
|2025-04-10T12:05:00 |456 |purchase |403 | Forbidden (unauthorized user)
|
|
170
|
-
|===
|
|
171
|
-
|
|
172
|
-
For this case, the plugin creates two JSON look like objects as below and places them into the `target` field of the event if `target` is defined.
|
|
173
|
-
If `target` is not defined, the plugin places the _only_ first result at the root of the event.
|
|
174
|
-
[source, json]
|
|
175
|
-
[
|
|
176
|
-
{
|
|
177
|
-
"timestamp": "2025-04-10T12:00:00",
|
|
178
|
-
"user_id": 123,
|
|
179
|
-
"action": "login",
|
|
180
|
-
"status": {
|
|
181
|
-
"code": 200,
|
|
182
|
-
"desc": "Success"
|
|
183
|
-
}
|
|
184
|
-
},
|
|
185
|
-
{
|
|
186
|
-
"timestamp": "2025-04-10T12:05:00",
|
|
187
|
-
"user_id": 456,
|
|
188
|
-
"action": "purchase",
|
|
189
|
-
"status": {
|
|
190
|
-
"code": 403,
|
|
191
|
-
"desc": "Forbidden (unauthorized user)"
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
]
|
|
195
|
-
|
|
196
|
-
NOTE: If your index has a mapping with sub-objects where `status.code` and `status.desc` actually dotted fields, they appear in {ls} events as a nested structure.
|
|
197
|
-
|
|
198
|
-
[id="plugins-{type}s-{plugin}-esql-multifields"]
|
|
199
|
-
===== Conflict on multi-fields
|
|
200
|
-
|
|
201
|
-
{esql} query fetches all parent and sub-fields fields if your {es} index has https://www.elastic.co/docs/reference/elasticsearch/mapping-reference/multi-fields[multi-fields] or https://www.elastic.co/docs/reference/elasticsearch/mapping-reference/subobjects[subobjects].
|
|
202
|
-
Since {ls} events cannot contain parent field's concrete value and sub-field values together, the plugin ignores sub-fields with warning and includes parent.
|
|
203
|
-
We recommend using the `RENAME` (or `DROP` to avoid warning) keyword in your {esql} query explicitly rename the fields to include sub-fields into the event.
|
|
204
|
-
|
|
205
|
-
This is a common occurrence if your template or mapping follows the pattern of always indexing strings as "text" (`field`) + " keyword" (`field.keyword`) multi-field.
|
|
206
|
-
In this case it's recommended to do `KEEP field` if the string is identical and there is only one subfield as the engine will optimize and retrieve the keyword, otherwise you can do `KEEP field.keyword | RENAME field.keyword as field`.
|
|
207
|
-
|
|
208
|
-
To illustrate the situation with example, assuming your mapping has a time `time` field with `time.min` and `time.max` sub-fields as following:
|
|
209
|
-
[source, ruby]
|
|
210
|
-
"properties": {
|
|
211
|
-
"time": { "type": "long" },
|
|
212
|
-
"time.min": { "type": "long" },
|
|
213
|
-
"time.max": { "type": "long" }
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
The {esql} result will contain all three fields but the plugin cannot map them into {ls} event.
|
|
217
|
-
To avoid this, you can use the `RENAME` keyword to rename the `time` parent field to get all three fields with unique fields.
|
|
218
|
-
[source, ruby]
|
|
219
|
-
...
|
|
220
|
-
query => 'FROM my-index | RENAME time AS time.current'
|
|
221
|
-
...
|
|
222
|
-
|
|
223
|
-
For comprehensive ES|QL syntax reference and best practices, see the https://www.elastic.co/guide/en/elasticsearch/reference/current/esql-syntax.html[{esql} documentation].
|
|
224
|
-
|
|
225
121
|
[id="plugins-{type}s-{plugin}-options"]
|
|
226
122
|
==== Elasticsearch Filter Configuration Options
|
|
227
123
|
|
|
228
|
-
This plugin supports the following configuration options plus the <<plugins-{type}s-{plugin}-common-options>>
|
|
124
|
+
This plugin supports the following configuration options plus the <<plugins-{type}s-{plugin}-common-options>> described later.
|
|
125
|
+
|
|
126
|
+
NOTE: As of version `4.0.0` of this plugin, a number of previously deprecated settings related to SSL have been removed. Please see the
|
|
127
|
+
<<plugins-{type}s-{plugin}-obsolete-options>> for more details.
|
|
229
128
|
|
|
230
129
|
[cols="<,<,<",options="header",]
|
|
231
130
|
|=======================================================================
|
|
@@ -235,7 +134,6 @@ This plugin supports the following configuration options plus the <<plugins-{typ
|
|
|
235
134
|
| <<plugins-{type}s-{plugin}-ca_trusted_fingerprint>> |<<string,string>>|No
|
|
236
135
|
| <<plugins-{type}s-{plugin}-cloud_auth>> |<<password,password>>|No
|
|
237
136
|
| <<plugins-{type}s-{plugin}-cloud_id>> |<<string,string>>|No
|
|
238
|
-
| <<plugins-{type}s-{plugin}-custom_headers>> |<<hash,hash>>|No
|
|
239
137
|
| <<plugins-{type}s-{plugin}-docinfo_fields>> |<<hash,hash>>|No
|
|
240
138
|
| <<plugins-{type}s-{plugin}-enable_sort>> |<<boolean,boolean>>|No
|
|
241
139
|
| <<plugins-{type}s-{plugin}-fields>> |<<array,array>>|No
|
|
@@ -244,14 +142,11 @@ This plugin supports the following configuration options plus the <<plugins-{typ
|
|
|
244
142
|
| <<plugins-{type}s-{plugin}-password>> |<<password,password>>|No
|
|
245
143
|
| <<plugins-{type}s-{plugin}-proxy>> |<<uri,uri>>|No
|
|
246
144
|
| <<plugins-{type}s-{plugin}-query>> |<<string,string>>|No
|
|
247
|
-
| <<plugins-{type}s-{plugin}-query_type>> |<<string,string>>, one of `["dsl", "esql"]`|No
|
|
248
|
-
| <<plugins-{type}s-{plugin}-query_params>> |<<hash,hash>> or <<hash,hash>>|No
|
|
249
145
|
| <<plugins-{type}s-{plugin}-query_template>> |<<string,string>>|No
|
|
250
146
|
| <<plugins-{type}s-{plugin}-result_size>> |<<number,number>>|No
|
|
251
147
|
| <<plugins-{type}s-{plugin}-retry_on_failure>> |<<number,number>>|No
|
|
252
148
|
| <<plugins-{type}s-{plugin}-retry_on_status>> |<<array,array>>|No
|
|
253
149
|
| <<plugins-{type}s-{plugin}-sort>> |<<string,string>>|No
|
|
254
|
-
| <<plugins-{type}s-{plugin}-ssl>> |<<boolean,boolean>>|__Deprecated__
|
|
255
150
|
| <<plugins-{type}s-{plugin}-ssl_certificate>> |<<path,path>>|No
|
|
256
151
|
| <<plugins-{type}s-{plugin}-ssl_certificate_authorities>> |list of <<path,path>>|No
|
|
257
152
|
| <<plugins-{type}s-{plugin}-ssl_cipher_suites>> |list of <<string,string>>|No
|
|
@@ -266,7 +161,6 @@ This plugin supports the following configuration options plus the <<plugins-{typ
|
|
|
266
161
|
| <<plugins-{type}s-{plugin}-ssl_truststore_type>> |<<string,string>>|No
|
|
267
162
|
| <<plugins-{type}s-{plugin}-ssl_verification_mode>> |<<string,string>>, one of `["full", "none"]`|No
|
|
268
163
|
| <<plugins-{type}s-{plugin}-tag_on_failure>> |<<array,array>>|No
|
|
269
|
-
| <<plugins-{type}s-{plugin}-target>> |<<string,string>>|No
|
|
270
164
|
| <<plugins-{type}s-{plugin}-user>> |<<string,string>>|No
|
|
271
165
|
|=======================================================================
|
|
272
166
|
|
|
@@ -280,11 +174,8 @@ filter plugins.
|
|
|
280
174
|
|
|
281
175
|
* Value type is <<hash,hash>>
|
|
282
176
|
* Default value is `{}`
|
|
283
|
-
* Format: `"aggregation_name" => "[path][on][event]"`:
|
|
284
|
-
** `aggregation_name`: aggregation name in result from {es}
|
|
285
|
-
** `[path][on][event]`: path for where to place the value on the current event, using field-reference notation
|
|
286
177
|
|
|
287
|
-
|
|
178
|
+
Hash of aggregation names to copy from elasticsearch response into Logstash event fields
|
|
288
179
|
|
|
289
180
|
Example:
|
|
290
181
|
[source,ruby]
|
|
@@ -305,12 +196,8 @@ Example:
|
|
|
305
196
|
Authenticate using Elasticsearch API key. Note that this option also requires
|
|
306
197
|
enabling the <<plugins-{type}s-{plugin}-ssl_enabled>> option.
|
|
307
198
|
|
|
308
|
-
|
|
309
|
-
Elasticsearch
|
|
310
|
-
{ref}/security-api-create-api-key.html[Create
|
|
311
|
-
API key API]. The base64-encoded form of that pair is also accepted, as is an
|
|
312
|
-
https://www.elastic.co/docs/deploy-manage/api-keys/elastic-cloud-api-keys[Elastic Cloud API key]
|
|
313
|
-
(prefixed with `essu_`), which is used as-is.
|
|
199
|
+
Format is `id:api_key` where `id` and `api_key` are as returned by the
|
|
200
|
+
Elasticsearch {ref}/security-api-create-api-key.html[Create API key API].
|
|
314
201
|
|
|
315
202
|
[id="plugins-{type}s-{plugin}-ca_trusted_fingerprint"]
|
|
316
203
|
===== `ca_trusted_fingerprint`
|
|
@@ -343,26 +230,13 @@ Cloud ID, from the Elastic Cloud web console. If set `hosts` should not be used.
|
|
|
343
230
|
For more info, check out the
|
|
344
231
|
{logstash-ref}/connecting-to-cloud.html[Logstash-to-Cloud documentation].
|
|
345
232
|
|
|
346
|
-
|
|
347
|
-
[id="plugins-{type}s-{plugin}-custom_headers"]
|
|
348
|
-
===== `custom_headers`
|
|
349
|
-
|
|
350
|
-
* Value type is <<hash,hash>>
|
|
351
|
-
* Default value is empty
|
|
352
|
-
|
|
353
|
-
Pass a set of key value pairs as the headers sent in each request to Elasticsearch.
|
|
354
|
-
These custom headers will override any headers previously set by the plugin such as the User Agent or Authorization headers.
|
|
355
|
-
|
|
356
233
|
[id="plugins-{type}s-{plugin}-docinfo_fields"]
|
|
357
234
|
===== `docinfo_fields`
|
|
358
235
|
|
|
359
236
|
* Value type is <<hash,hash>>
|
|
360
237
|
* Default value is `{}`
|
|
361
|
-
* Format: `"path.in.source" => "[path][on][event]"`:
|
|
362
|
-
** `path.in.source`: field path in document source of result from {es}, using dot-notation
|
|
363
|
-
** `[path][on][event]`: path for where to place the value on the current event, using field-reference notation
|
|
364
238
|
|
|
365
|
-
|
|
239
|
+
Hash of docinfo fields to copy from old event (found via elasticsearch) into new event
|
|
366
240
|
|
|
367
241
|
Example:
|
|
368
242
|
[source,ruby]
|
|
@@ -388,11 +262,9 @@ Whether results should be sorted or not
|
|
|
388
262
|
|
|
389
263
|
* Value type is <<array,array>>
|
|
390
264
|
* Default value is `{}`
|
|
391
|
-
* Format: `"path.in.result" => "[path][on][event]"`:
|
|
392
|
-
** `path.in.result`: field path in indexed result from {es}, using dot-notation
|
|
393
|
-
** `[path][on][event]`: path for where to place the value on the current event, using field-reference notation
|
|
394
265
|
|
|
395
|
-
|
|
266
|
+
An array of fields to copy from the old event (found via elasticsearch) into the
|
|
267
|
+
new event, currently being processed.
|
|
396
268
|
|
|
397
269
|
In the following example, the values of `@timestamp` and `event_id` on the event
|
|
398
270
|
found via elasticsearch are copied to the current event's
|
|
@@ -447,30 +319,11 @@ environment variables e.g. `proxy => '${LS_PROXY:}'`.
|
|
|
447
319
|
* Value type is <<string,string>>
|
|
448
320
|
* There is no default value for this setting.
|
|
449
321
|
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
string documentation] or {ref}/esql.html[{es} ES|QL documentation] for more information.
|
|
455
|
-
|
|
456
|
-
[id="plugins-{type}s-{plugin}-query_type"]
|
|
457
|
-
===== `query_type`
|
|
458
|
-
|
|
459
|
-
* Value can be `dsl` or `esql`
|
|
460
|
-
* Default value is `dsl`
|
|
461
|
-
|
|
462
|
-
Defines the <<plugins-{type}s-{plugin}-query>> shape.
|
|
463
|
-
When `dsl`, the query shape must be valid {es} JSON-style string.
|
|
464
|
-
When `esql`, the query shape must be a valid {esql} string and `index`, `query_template` and `sort` parameters are not allowed.
|
|
465
|
-
|
|
466
|
-
[id="plugins-{type}s-{plugin}-query_params"]
|
|
467
|
-
===== `query_params`
|
|
468
|
-
|
|
469
|
-
* The value type is <<hash,hash>> or <<array,array>>. When an array provided, the array elements are pairs of `key` and `value`.
|
|
470
|
-
* There is no default value for this setting
|
|
322
|
+
Elasticsearch query string. More information is available in the
|
|
323
|
+
{ref}/query-dsl-query-string-query.html#query-string-syntax[Elasticsearch query
|
|
324
|
+
string documentation].
|
|
325
|
+
Use either `query` or `query_template`.
|
|
471
326
|
|
|
472
|
-
Named parameters in {esql} to send to {es} together with <<plugins-{type}s-{plugin}-query>>.
|
|
473
|
-
Visit {ref}/esql-rest.html#esql-rest-params[passing parameters to query page] for more information.
|
|
474
327
|
|
|
475
328
|
[id="plugins-{type}s-{plugin}-query_template"]
|
|
476
329
|
===== `query_template`
|
|
@@ -659,44 +512,6 @@ WARNING: Setting certificate verification to `none` disables many security benef
|
|
|
659
512
|
|
|
660
513
|
Tags the event on failure to look up previous log event information. This can be used in later analysis.
|
|
661
514
|
|
|
662
|
-
[id="plugins-{type}s-{plugin}-target"]
|
|
663
|
-
===== `target`
|
|
664
|
-
|
|
665
|
-
* Value type is <<string,string>>
|
|
666
|
-
* There is no default value for this setting.
|
|
667
|
-
|
|
668
|
-
Define the target field for placing the result data.
|
|
669
|
-
If this setting is omitted, the target will be the root (top level) of the event.
|
|
670
|
-
It is highly recommended to set when using `query_type=>'esql'` to set all query results into the event.
|
|
671
|
-
|
|
672
|
-
When `query_type=>'dsl'`, the destination fields specified in <<plugins-{type}s-{plugin}-fields>>, <<plugins-{type}s-{plugin}-aggregation_fields>>, and <<plugins-{type}s-{plugin}-docinfo_fields>> are relative to this target.
|
|
673
|
-
|
|
674
|
-
For example, if you want the data to be put in the `operation` field:
|
|
675
|
-
[source,ruby]
|
|
676
|
-
if [type] == "end" {
|
|
677
|
-
filter {
|
|
678
|
-
query => "type:start AND transaction:%{[transactionId]}"
|
|
679
|
-
elasticsearch {
|
|
680
|
-
target => "transaction"
|
|
681
|
-
fields => {
|
|
682
|
-
"@timestamp" => "started"
|
|
683
|
-
"transaction_id" => "id"
|
|
684
|
-
}
|
|
685
|
-
}
|
|
686
|
-
}
|
|
687
|
-
}
|
|
688
|
-
|
|
689
|
-
`fields` fields will be expanded into a data structure in the `target` field, overall shape looks like this:
|
|
690
|
-
[source,ruby]
|
|
691
|
-
{
|
|
692
|
-
"transaction" => {
|
|
693
|
-
"started" => "2025-04-29T12:01:46.263Z"
|
|
694
|
-
"id" => "1234567890"
|
|
695
|
-
}
|
|
696
|
-
}
|
|
697
|
-
|
|
698
|
-
NOTE: when writing to a field that already exists on the event, the previous value will be overwritten.
|
|
699
|
-
|
|
700
515
|
[id="plugins-{type}s-{plugin}-user"]
|
|
701
516
|
===== `user`
|
|
702
517
|
|
|
@@ -706,57 +521,21 @@ NOTE: when writing to a field that already exists on the event, the previous val
|
|
|
706
521
|
Basic Auth - username
|
|
707
522
|
|
|
708
523
|
|
|
709
|
-
[id="plugins-{type}s-{plugin}-
|
|
710
|
-
==== Elasticsearch Filter
|
|
711
|
-
|
|
712
|
-
This plugin supports the following deprecated configurations.
|
|
524
|
+
[id="plugins-{type}s-{plugin}-obsolete-options"]
|
|
525
|
+
==== Elasticsearch Filter Obsolete Configuration Options
|
|
713
526
|
|
|
714
|
-
WARNING:
|
|
527
|
+
WARNING: As of version `4.0.0` of this plugin, some configuration options have been replaced.
|
|
528
|
+
The plugin will fail to start if it contains any of these obsolete options.
|
|
715
529
|
|
|
716
530
|
[cols="<,<,<",options="header",]
|
|
717
531
|
|=======================================================================
|
|
718
|
-
|Setting|
|
|
719
|
-
|
|
|
720
|
-
|
|
|
721
|
-
|
|
|
532
|
+
|Setting|Replaced by
|
|
533
|
+
| ca_file |<<plugins-{type}s-{plugin}-ssl_certificate_authorities>>
|
|
534
|
+
| keystore |<<plugins-{type}s-{plugin}-ssl_keystore_path>>
|
|
535
|
+
| keystore_password |<<plugins-{type}s-{plugin}-ssl_keystore_password>>
|
|
536
|
+
| ssl |<<plugins-{type}s-{plugin}-ssl_enabled>>
|
|
722
537
|
|=======================================================================
|
|
723
538
|
|
|
724
|
-
[id="plugins-{type}s-{plugin}-ca_file"]
|
|
725
|
-
===== `ca_file`
|
|
726
|
-
deprecated[3.15.0, Replaced by <<plugins-{type}s-{plugin}-ssl_certificate_authorities>>]
|
|
727
|
-
|
|
728
|
-
* Value type is <<path,path>>
|
|
729
|
-
* There is no default value for this setting.
|
|
730
|
-
|
|
731
|
-
SSL Certificate Authority file
|
|
732
|
-
|
|
733
|
-
[id="plugins-{type}s-{plugin}-ssl"]
|
|
734
|
-
===== `ssl`
|
|
735
|
-
deprecated[3.15.0, Replaced by <<plugins-{type}s-{plugin}-ssl_enabled>>]
|
|
736
|
-
|
|
737
|
-
* Value type is <<boolean,boolean>>
|
|
738
|
-
* Default value is `false`
|
|
739
|
-
|
|
740
|
-
SSL
|
|
741
|
-
|
|
742
|
-
[id="plugins-{type}s-{plugin}-keystore"]
|
|
743
|
-
===== `keystore`
|
|
744
|
-
deprecated[3.15.0, Replaced by <<plugins-{type}s-{plugin}-ssl_keystore_path>>]
|
|
745
|
-
|
|
746
|
-
* Value type is <<path,path>>
|
|
747
|
-
* There is no default value for this setting.
|
|
748
|
-
|
|
749
|
-
The keystore used to present a certificate to the server. It can be either .jks or .p12
|
|
750
|
-
|
|
751
|
-
[id="plugins-{type}s-{plugin}-keystore_password"]
|
|
752
|
-
===== `keystore_password`
|
|
753
|
-
deprecated[3.15.0, Replaced by <<plugins-{type}s-{plugin}-ssl_keystore_password>>]
|
|
754
|
-
|
|
755
|
-
* Value type is <<password,password>>
|
|
756
|
-
* There is no default value for this setting.
|
|
757
|
-
|
|
758
|
-
Set the keystore password
|
|
759
|
-
|
|
760
539
|
|
|
761
540
|
[id="plugins-{type}s-{plugin}-common-options"]
|
|
762
541
|
include::{include_path}/{type}.asciidoc[]
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# encoding: utf-8
|
|
2
2
|
require "elasticsearch"
|
|
3
3
|
require "base64"
|
|
4
|
+
require "elasticsearch/transport/transport/http/manticore"
|
|
4
5
|
|
|
5
6
|
|
|
6
7
|
module LogStash
|
|
@@ -8,7 +9,6 @@ module LogStash
|
|
|
8
9
|
class ElasticsearchClient
|
|
9
10
|
|
|
10
11
|
attr_reader :client
|
|
11
|
-
attr_reader :es_transport_client_type
|
|
12
12
|
|
|
13
13
|
BUILD_FLAVOR_SERVERLESS = 'serverless'.freeze
|
|
14
14
|
DEFAULT_EAV_HEADER = { "Elastic-Api-Version" => "2023-10-31" }.freeze
|
|
@@ -20,8 +20,6 @@ module LogStash
|
|
|
20
20
|
api_key = options.fetch(:api_key, nil)
|
|
21
21
|
proxy = options.fetch(:proxy, nil)
|
|
22
22
|
user_agent = options[:user_agent]
|
|
23
|
-
custom_headers = options[:custom_headers]
|
|
24
|
-
|
|
25
23
|
|
|
26
24
|
transport_options = { }
|
|
27
25
|
transport_options[:headers] = options.fetch(:serverless, false) ? DEFAULT_EAV_HEADER.dup : {}
|
|
@@ -29,7 +27,6 @@ module LogStash
|
|
|
29
27
|
transport_options[:headers].merge!(setup_api_key(api_key))
|
|
30
28
|
transport_options[:headers].merge!({ 'user-agent' => "#{user_agent}" })
|
|
31
29
|
transport_options[:headers].merge!(INTERNAL_ORIGIN_HEADER)
|
|
32
|
-
transport_options[:headers].merge!(custom_headers) unless custom_headers.empty?
|
|
33
30
|
|
|
34
31
|
transport_options[:pool_max] = 1000
|
|
35
32
|
transport_options[:pool_max_per_route] = 100
|
|
@@ -44,7 +41,7 @@ module LogStash
|
|
|
44
41
|
|
|
45
42
|
client_options = {
|
|
46
43
|
hosts: hosts,
|
|
47
|
-
transport_class:
|
|
44
|
+
transport_class: ::Elasticsearch::Transport::Transport::HTTP::Manticore,
|
|
48
45
|
transport_options: transport_options,
|
|
49
46
|
ssl: ssl_options,
|
|
50
47
|
retry_on_failure: options[:retry_on_failure],
|
|
@@ -58,19 +55,11 @@ module LogStash
|
|
|
58
55
|
def search(params={})
|
|
59
56
|
@client.search(params)
|
|
60
57
|
end
|
|
61
|
-
|
|
62
|
-
def esql_query(params={})
|
|
63
|
-
@client.esql.query(params)
|
|
64
|
-
end
|
|
65
58
|
|
|
66
59
|
def info
|
|
67
60
|
@client.info
|
|
68
61
|
end
|
|
69
62
|
|
|
70
|
-
def es_version
|
|
71
|
-
info&.dig('version', 'number')
|
|
72
|
-
end
|
|
73
|
-
|
|
74
63
|
def build_flavor
|
|
75
64
|
@build_flavor ||= info&.dig('version', 'build_flavor')
|
|
76
65
|
end
|
|
@@ -101,53 +90,11 @@ module LogStash
|
|
|
101
90
|
end
|
|
102
91
|
|
|
103
92
|
def setup_api_key(api_key)
|
|
104
|
-
return {} unless (api_key
|
|
93
|
+
return {} unless (api_key && api_key.value)
|
|
105
94
|
|
|
106
|
-
token =
|
|
95
|
+
token = ::Base64.strict_encode64(api_key.value)
|
|
107
96
|
{ 'Authorization' => "ApiKey #{token}" }
|
|
108
97
|
end
|
|
109
|
-
|
|
110
|
-
# Resolves the `api_key` value into the credential used in the
|
|
111
|
-
# `Authorization: ApiKey` header. An already base64-encoded key and an Elastic
|
|
112
|
-
# Cloud API key are used as-is; a raw `id:api_key` pair is base64-encoded. An
|
|
113
|
-
# unrecognized value is rejected so a malformed key surfaces at startup rather
|
|
114
|
-
# than as a later authentication failure.
|
|
115
|
-
def resolve_api_key(key_value)
|
|
116
|
-
if base64?(key_value) || cloud_api_key?(key_value)
|
|
117
|
-
key_value
|
|
118
|
-
elsif key_value.match?(/\A[^:]+:[^:]+\z/)
|
|
119
|
-
Base64.strict_encode64(key_value)
|
|
120
|
-
else
|
|
121
|
-
raise LogStash::ConfigurationError, "Invalid api_key format. Expected a base64-encoded key, an 'id:api_key' pair, or a Cloud API key (essu_ prefix)."
|
|
122
|
-
end
|
|
123
|
-
end
|
|
124
|
-
|
|
125
|
-
# Elastic Cloud API keys (such as the unified Serverless keys) are opaque
|
|
126
|
-
# tokens prefixed with `essu_` that Elasticsearch accepts verbatim in the
|
|
127
|
-
# `Authorization: ApiKey` header, with no base64 encoding.
|
|
128
|
-
def cloud_api_key?(string)
|
|
129
|
-
string.match?(/\Aessu_.+/)
|
|
130
|
-
end
|
|
131
|
-
|
|
132
|
-
def base64?(string)
|
|
133
|
-
string == Base64.strict_encode64(Base64.strict_decode64(string))
|
|
134
|
-
rescue ArgumentError
|
|
135
|
-
false
|
|
136
|
-
end
|
|
137
|
-
|
|
138
|
-
def get_transport_client_class
|
|
139
|
-
# LS-core includes `elasticsearch` gem. The gem is composed of two separate gems: `elasticsearch-api` and `elasticsearch-transport`
|
|
140
|
-
# And now `elasticsearch-transport` is old, instead we have `elastic-transport`.
|
|
141
|
-
# LS-core updated `elasticsearch` > 8: https://github.com/elastic/logstash/pull/17161
|
|
142
|
-
# Following source bits are for the compatibility to support both `elasticsearch-transport` and `elastic-transport` gems
|
|
143
|
-
require "elasticsearch/transport/transport/http/manticore"
|
|
144
|
-
es_transport_client_type = "elasticsearch_transport"
|
|
145
|
-
::Elasticsearch::Transport::Transport::HTTP::Manticore
|
|
146
|
-
rescue ::LoadError
|
|
147
|
-
require "elastic/transport/transport/http/manticore"
|
|
148
|
-
es_transport_client_type = "elastic_transport"
|
|
149
|
-
::Elastic::Transport::Transport::HTTP::Manticore
|
|
150
|
-
end
|
|
151
98
|
end
|
|
152
99
|
end
|
|
153
100
|
end
|