You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Introduce query_params option to accept drop_null_columns, set default timestampt converter to LogStash::Timestamp, dotted fields extended to nested fields.
Copy file name to clipboardExpand all lines: docs/index.asciidoc
+33-1Lines changed: 33 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -266,7 +266,13 @@ The following is a basic scheduled ES|QL query that runs hourly:
266
266
267
267
Set `config.support_escapes: true` in `logstash.yml` if you need to escape special chars in the query.
268
268
269
-
NOTE: With ES|QL query, {ls} doesn't generate `event.original`
269
+
NOTE: With ES|QL query, {ls} doesn't generate `event.original`.
270
+
271
+
Consider the following caveat scenarios:
272
+
273
+
- ES|QL by default returns entire columns even if their values are `null`. The plugin provides a `drop_null_columns` option via <<plugins-{type}s-{plugin}-query_params>>. Enabling this parameter instructs {es} to automatically exclude columns with null values from query results.
274
+
- If your {es} index uses https://www.elastic.co/docs/reference/elasticsearch/mapping-reference/multi-fields[multi-fields] mapping(s), ES|QL query fetches all parent and sub-fields fields. Since {ls} events cannot contain parent field's concrete value and sub-field values together, we recommend using the `DROP` keyword in your ES|QL query explicitly remove sub-fields.
275
+
- If your {es} index contains top level `tags` field, this will conflict with {ls} event's reserved `tags` field. {ls} moves `tags` field values to the `_tags` and populates `tags` with `["_tagsparsefailure"]`.
270
276
271
277
For comprehensive ES|QL syntax reference and best practices, see the https://www.elastic.co/guide/en/elasticsearch/reference/current/esql-syntax.html[official {es} documentation].
272
278
@@ -297,6 +303,7 @@ Please check out <<plugins-{type}s-{plugin}-obsolete-options>> for details.
@@ -544,6 +551,31 @@ documentation] for more information.
544
551
When <<plugins-{type}s-{plugin}-search_api>> resolves to `search_after` and the query does not specify `sort`,
545
552
the default sort `'{ "sort": { "_shard_doc": "asc" } }'` will be added to the query. Please refer to the {ref}/paginate-search-results.html#search-after[Elasticsearch search_after] parameter to know more.
546
553
554
+
[id="plugins-{type}s-{plugin}-query_params"]
555
+
===== `query_params`
556
+
Parameters to send to {es} together with <<plugins-{type}s-{plugin}-query>>.
557
+
558
+
Accepted options:
559
+
[cols="2,1,3",options="header"]
560
+
|===
561
+
|Option name |Default value | Description
562
+
563
+
|`drop_null_columns` |`false` | Requests {es} to filter out `null` columns
564
+
|===
565
+
566
+
Example
567
+
[source, ruby]
568
+
input {
569
+
elasticsearch {
570
+
response_type => 'esql'
571
+
query => 'FROM access-logs* | WHERE type="apache"'
@retries < 0 && fail(LogStash::ConfigurationError,"Elasticsearch Input Plugin's `retries` option must be equal or greater than zero, got `#{@retries}`")
325
329
330
+
validate_query_params!
326
331
validate_authentication
327
332
fill_user_password_from_cloud_auth
328
333
@@ -751,6 +756,17 @@ def validate_esql_query!
751
756
fail(LogStash::ConfigurationError,"`query` needs to start with any of #{source_commands}")unlesscontains_source_command
752
757
end
753
758
759
+
defvalidate_query_params!
760
+
# keep the original, remove ES|QL accepted params and validate
761
+
cloned_query_params=@query_params.clone
762
+
if@response_type == 'esql'
763
+
cloned_query_params.delete("drop_null_columns")
764
+
fail(LogStash::ConfigurationError,"#{cloned_query_params} not accepted when `response_type => 'esql'`")ifcloned_query_params.any?
765
+
else
766
+
fail(LogStash::ConfigurationError,"#{@query_params} not accepted when `response_type => #{@response_type}`")if@query_params.any?
expect{plugin.send(:validate_query_params!)}.toraise_error(LogStash::ConfigurationError,"{\"test\"=>\"hi\"} not accepted when `response_type => 'esql'`")
0 commit comments