Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
144 changes: 135 additions & 9 deletions docs/plugins/filters/elasticsearch.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
///////////////////////////////////////////
START - GENERATED VARIABLES, DO NOT EDIT!
///////////////////////////////////////////
:version: v3.18.0
:release_date: 2025-05-07
:changelog_url: https://github.com/logstash-plugins/logstash-filter-elasticsearch/blob/v3.18.0/CHANGELOG.md
:version: v3.19.0
:release_date: 2025-07-21
:changelog_url: https://github.com/logstash-plugins/logstash-filter-elasticsearch/blob/v3.19.0/CHANGELOG.md
:include_path: ../../../../logstash/docs/include
///////////////////////////////////////////
END - GENERATED VARIABLES, DO NOT EDIT!
Expand Down Expand Up @@ -55,7 +55,7 @@ if [type] == "end" {

The example below reproduces the above example but utilises the query_template.
This query_template represents a full Elasticsearch query DSL and supports the
standard Logstash field substitution syntax. The example below issues
standard {ls} field substitution syntax. The example below issues
the same query as the first example but uses the template shown.

[source,ruby]
Expand Down Expand Up @@ -119,6 +119,110 @@ Authentication to a secure Elasticsearch cluster is possible using _one_ of the
Authorization to a secure Elasticsearch cluster requires `read` permission at index level and `monitoring` permissions at cluster level.
The `monitoring` permission at cluster level is necessary to perform periodic connectivity checks.

[id="plugins-{type}s-{plugin}-esql"]
==== {esql} support

.Technical Preview
****
The {esql} feature that allows using ES|QL queries with this plugin is in Technical Preview.
Configuration options and implementation details are subject to change in minor releases without being preceded by deprecation warnings.
****

{es} Query Language ({esql}) provides a SQL-like interface for querying your {es} data.

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.

To configure {esql} query in the plugin, set your {esql} query in the `query` parameter.

IMPORTANT: We recommend understanding {ref}/esql-limitations.html[{esql} current limitations] before using it in production environments.

The following is a basic {esql} query that sets the food name to transaction event based on upstream event's food ID:
[source, ruby]
filter {
elasticsearch {
hosts => [ 'https://..']
api_key => '....'
query => '
FROM food-index
| WHERE id == ?food_id
'
query_params => {
"food_id" => "[food][id]"
}
}
}

Set `config.support_escapes: true` in `logstash.yml` if you need to escape special chars in the query.

In the result event, the plugin sets total result size in `[@metadata][total_values]` field.

[id="plugins-{type}s-{plugin}-esql-event-mapping"]
===== Mapping {esql} result to {ls} event
{esql} returns query results in a structured tabular format, where data is organized into _columns_ (fields) and _values_ (entries).
The plugin maps each value entry to an event, populating corresponding fields.
For example, a query might produce a table like:

[cols="2,1,1,1,2",options="header"]
|===
|`timestamp` |`user_id` | `action` | `status.code` | `status.desc`

|2025-04-10T12:00:00 |123 |login |200 | Success
|2025-04-10T12:05:00 |456 |purchase |403 | Forbidden (unauthorized user)
|===

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.
If `target` is not defined, the plugin places the _only_ first result at the root of the event.
[source, json]
[
{
"timestamp": "2025-04-10T12:00:00",
"user_id": 123,
"action": "login",
"status": {
"code": 200,
"desc": "Success"
}
},
{
"timestamp": "2025-04-10T12:05:00",
"user_id": 456,
"action": "purchase",
"status": {
"code": 403,
"desc": "Forbidden (unauthorized user)"
}
}
]

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.

[id="plugins-{type}s-{plugin}-esql-multifields"]
===== Conflict on multi-fields

{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].
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.
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.

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.
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`.

To illustrate the situation with example, assuming your mapping has a time `time` field with `time.min` and `time.max` sub-fields as following:
[source, ruby]
"properties": {
"time": { "type": "long" },
"time.min": { "type": "long" },
"time.max": { "type": "long" }
}

The {esql} result will contain all three fields but the plugin cannot map them into {ls} event.
To avoid this, you can use the `RENAME` keyword to rename the `time` parent field to get all three fields with unique fields.
[source, ruby]
...
query => 'FROM my-index | RENAME time AS time.current'
...

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].

[id="plugins-{type}s-{plugin}-options"]
==== Elasticsearch Filter Configuration Options

Expand All @@ -141,6 +245,8 @@ This plugin supports the following configuration options plus the <<plugins-{typ
| <<plugins-{type}s-{plugin}-password>> |<<password,password>>|No
| <<plugins-{type}s-{plugin}-proxy>> |<<uri,uri>>|No
| <<plugins-{type}s-{plugin}-query>> |<<string,string>>|No
| <<plugins-{type}s-{plugin}-query_type>> |<<string,string>>, one of `["dsl", "esql"]`|No
| <<plugins-{type}s-{plugin}-query_params>> |<<hash,hash>> or <<hash,hash>>|No
| <<plugins-{type}s-{plugin}-query_template>> |<<string,string>>|No
| <<plugins-{type}s-{plugin}-result_size>> |<<number,number>>|No
| <<plugins-{type}s-{plugin}-retry_on_failure>> |<<number,number>>|No
Expand Down Expand Up @@ -338,11 +444,30 @@ environment variables e.g. `proxy => '${LS_PROXY:}'`.
* Value type is <<string,string>>
* There is no default value for this setting.

Elasticsearch query string. More information is available in the
{ref}/query-dsl-query-string-query.html#query-string-syntax[Elasticsearch query
string documentation].
Use either `query` or `query_template`.
The query to be executed.
The accepted query shape is DSL query string or ES|QL.
For the DSL query string, use either `query` or `query_template`.
Read the {ref}/query-dsl-query-string-query.html[{es} query
string documentation] or {ref}/esql.html[{es} ES|QL documentation] for more information.

[id="plugins-{type}s-{plugin}-query_type"]
===== `query_type`

* Value can be `dsl` or `esql`
* Default value is `dsl`

Defines the <<plugins-{type}s-{plugin}-query>> shape.
When `dsl`, the query shape must be valid {es} JSON-style string.
When `esql`, the query shape must be a valid {esql} string and `index`, `query_template` and `sort` parameters are not allowed.

[id="plugins-{type}s-{plugin}-query_params"]
===== `query_params`

* The value type is <<hash,hash>> or <<array,array>>. When an array provided, the array elements are pairs of `key` and `value`.
* There is no default value for this setting

Named parameters in {esql} to send to {es} together with <<plugins-{type}s-{plugin}-query>>.
Visit {ref}/esql-rest.html#esql-rest-params[passing parameters to query page] for more information.

[id="plugins-{type}s-{plugin}-query_template"]
===== `query_template`
Expand Down Expand Up @@ -539,8 +664,9 @@ Tags the event on failure to look up previous log event information. This can be

Define the target field for placing the result data.
If this setting is omitted, the target will be the root (top level) of the event.
It is highly recommended to set when using `query_type=>'esql'` to set all query results into the event.

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.
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.

For example, if you want the data to be put in the `operation` field:
[source,ruby]
Expand Down
6 changes: 3 additions & 3 deletions docs/plugins/inputs/beats.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
///////////////////////////////////////////
START - GENERATED VARIABLES, DO NOT EDIT!
///////////////////////////////////////////
:version: v6.9.3
:release_date: 2025-02-12
:changelog_url: https://github.com/logstash-plugins/logstash-input-beats/blob/v6.9.3/CHANGELOG.md
:version: v6.9.4
:release_date: 2025-09-04
:changelog_url: https://github.com/logstash-plugins/logstash-input-beats/blob/v6.9.4/CHANGELOG.md
:include_path: ../../../../logstash/docs/include
///////////////////////////////////////////
END - GENERATED VARIABLES, DO NOT EDIT!
Expand Down
6 changes: 3 additions & 3 deletions docs/plugins/inputs/elastic_agent.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
///////////////////////////////////////////
START - GENERATED VARIABLES, DO NOT EDIT!
///////////////////////////////////////////
:version: v6.9.3
:release_date: 2025-02-12
:changelog_url: https://github.com/logstash-plugins/logstash-input-beats/blob/v6.9.3/CHANGELOG.md
:version: v6.9.4
:release_date: 2025-09-04
:changelog_url: https://github.com/logstash-plugins/logstash-input-beats/blob/v6.9.4/CHANGELOG.md
:include_path: ../../../../logstash/docs/include
///////////////////////////////////////////
END - GENERATED VARIABLES, DO NOT EDIT!
Expand Down
6 changes: 3 additions & 3 deletions docs/plugins/inputs/http.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
///////////////////////////////////////////
START - GENERATED VARIABLES, DO NOT EDIT!
///////////////////////////////////////////
:version: v3.10.2
:release_date: 2025-02-12
:changelog_url: https://github.com/logstash-plugins/logstash-input-http/blob/v3.10.2/CHANGELOG.md
:version: v3.10.3
:release_date: 2025-09-04
:changelog_url: https://github.com/logstash-plugins/logstash-input-http/blob/v3.10.3/CHANGELOG.md
:include_path: ../../../../logstash/docs/include
///////////////////////////////////////////
END - GENERATED VARIABLES, DO NOT EDIT!
Expand Down
6 changes: 3 additions & 3 deletions docs/plugins/inputs/jms.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
///////////////////////////////////////////
START - GENERATED VARIABLES, DO NOT EDIT!
///////////////////////////////////////////
:version: v3.3.0
:release_date: 2025-03-07
:changelog_url: https://github.com/logstash-plugins/logstash-input-jms/blob/v3.3.0/CHANGELOG.md
:version: v3.3.1
:release_date: 2025-09-08
:changelog_url: https://github.com/logstash-plugins/logstash-input-jms/blob/v3.3.1/CHANGELOG.md
:include_path: ../../../../logstash/docs/include
///////////////////////////////////////////
END - GENERATED VARIABLES, DO NOT EDIT!
Expand Down
6 changes: 3 additions & 3 deletions docs/plugins/inputs/kafka.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
///////////////////////////////////////////
START - GENERATED VARIABLES, DO NOT EDIT!
///////////////////////////////////////////
:version: v11.6.3
:release_date: 2025-06-12
:changelog_url: https://github.com/logstash-plugins/logstash-integration-kafka/blob/v11.6.3/CHANGELOG.md
:version: v11.6.4
:release_date: 2025-08-28
:changelog_url: https://github.com/logstash-plugins/logstash-integration-kafka/blob/v11.6.4/CHANGELOG.md
:include_path: ../../../../logstash/docs/include
///////////////////////////////////////////
END - GENERATED VARIABLES, DO NOT EDIT!
Expand Down
6 changes: 3 additions & 3 deletions docs/plugins/inputs/tcp.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
///////////////////////////////////////////
START - GENERATED VARIABLES, DO NOT EDIT!
///////////////////////////////////////////
:version: v6.4.6
:release_date: 2025-02-12
:changelog_url: https://github.com/logstash-plugins/logstash-input-tcp/blob/v6.4.6/CHANGELOG.md
:version: v6.4.7
:release_date: 2025-09-04
:changelog_url: https://github.com/logstash-plugins/logstash-input-tcp/blob/v6.4.7/CHANGELOG.md
:include_path: ../../../../logstash/docs/include
///////////////////////////////////////////
END - GENERATED VARIABLES, DO NOT EDIT!
Expand Down
6 changes: 3 additions & 3 deletions docs/plugins/integrations/kafka.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
///////////////////////////////////////////
START - GENERATED VARIABLES, DO NOT EDIT!
///////////////////////////////////////////
:version: v11.6.3
:release_date: 2025-06-12
:changelog_url: https://github.com/logstash-plugins/logstash-integration-kafka/blob/v11.6.3/CHANGELOG.md
:version: v11.6.4
:release_date: 2025-08-28
:changelog_url: https://github.com/logstash-plugins/logstash-integration-kafka/blob/v11.6.4/CHANGELOG.md
:include_path: ../../../../logstash/docs/include
///////////////////////////////////////////
END - GENERATED VARIABLES, DO NOT EDIT!
Expand Down
6 changes: 3 additions & 3 deletions docs/plugins/outputs/kafka.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
///////////////////////////////////////////
START - GENERATED VARIABLES, DO NOT EDIT!
///////////////////////////////////////////
:version: v11.6.3
:release_date: 2025-06-12
:changelog_url: https://github.com/logstash-plugins/logstash-integration-kafka/blob/v11.6.3/CHANGELOG.md
:version: v11.6.4
:release_date: 2025-08-28
:changelog_url: https://github.com/logstash-plugins/logstash-integration-kafka/blob/v11.6.4/CHANGELOG.md
:include_path: ../../../../logstash/docs/include
///////////////////////////////////////////
END - GENERATED VARIABLES, DO NOT EDIT!
Expand Down