Skip to content

Commit f18747a

Browse files
authored
Merge branch 'main' into entitlements/integtestSupport
2 parents c9608ef + a6f0f6f commit f18747a

File tree

154 files changed

+6727
-3028
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

154 files changed

+6727
-3028
lines changed

benchmarks/src/main/java/org/elasticsearch/benchmark/_nightly/esql/ValuesSourceReaderBenchmark.java

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,8 @@ public class ValuesSourceReaderBenchmark {
9292
"double",
9393
"keyword",
9494
"stored_keyword",
95-
"3_stored_keywords" };
95+
"3_stored_keywords",
96+
"keyword_mv" };
9697

9798
private static final int BLOCK_LENGTH = 16 * 1024;
9899
private static final int INDEX_SIZE = 10 * BLOCK_LENGTH;
@@ -332,7 +333,7 @@ public FieldNamesFieldMapper.FieldNamesFieldType fieldNames() {
332333
@Param({ "in_order", "shuffled" })
333334
public String layout;
334335

335-
@Param({ "long", "keyword", "stored_keyword" })
336+
@Param({ "long", "keyword", "stored_keyword", "keyword_mv" })
336337
public String name;
337338

338339
private Directory directory;
@@ -398,6 +399,22 @@ public void benchmark() {
398399
}
399400
}
400401
}
402+
case "keyword_mv" -> {
403+
BytesRef scratch = new BytesRef();
404+
BytesRefBlock values = op.getOutput().<BytesRefBlock>getBlock(1);
405+
for (int p = 0; p < values.getPositionCount(); p++) {
406+
int count = values.getValueCount(p);
407+
if (count > 0) {
408+
int first = values.getFirstValueIndex(p);
409+
for (int i = 0; i < count; i++) {
410+
BytesRef r = values.getBytesRef(first + i, scratch);
411+
r.offset++;
412+
r.length--;
413+
sum += Integer.parseInt(r.utf8ToString());
414+
}
415+
}
416+
}
417+
}
401418
}
402419
}
403420
long expected = 0;
@@ -407,6 +424,16 @@ public void benchmark() {
407424
expected += i % 1000;
408425
}
409426
break;
427+
case "keyword_mv":
428+
for (int i = 0; i < INDEX_SIZE; i++) {
429+
int v1 = i % 1000;
430+
expected += v1;
431+
int v2 = i % 500;
432+
if (v1 != v2) {
433+
expected += v2;
434+
}
435+
}
436+
break;
410437
case "3_stored_keywords":
411438
for (int i = 0; i < INDEX_SIZE; i++) {
412439
expected += 3 * (i % 1000);
@@ -461,7 +488,9 @@ private void setupIndex() throws IOException {
461488
new StoredField("double", (double) i),
462489
new KeywordFieldMapper.KeywordField("keyword_1", new BytesRef(c + i % 1000), keywordFieldType),
463490
new KeywordFieldMapper.KeywordField("keyword_2", new BytesRef(c + i % 1000), keywordFieldType),
464-
new KeywordFieldMapper.KeywordField("keyword_3", new BytesRef(c + i % 1000), keywordFieldType)
491+
new KeywordFieldMapper.KeywordField("keyword_3", new BytesRef(c + i % 1000), keywordFieldType),
492+
new KeywordFieldMapper.KeywordField("keyword_mv", new BytesRef(c + i % 1000), keywordFieldType),
493+
new KeywordFieldMapper.KeywordField("keyword_mv", new BytesRef(c + i % 500), keywordFieldType)
465494
)
466495
);
467496
if (i % COMMIT_INTERVAL == 0) {

benchmarks/src/main/java/org/elasticsearch/benchmark/compute/operator/ValuesAggregatorBenchmark.java

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,7 @@ static void selfTest() {
9595
try {
9696
for (String groups : ValuesAggregatorBenchmark.class.getField("groups").getAnnotationsByType(Param.class)[0].value()) {
9797
for (String dataType : ValuesAggregatorBenchmark.class.getField("dataType").getAnnotationsByType(Param.class)[0].value()) {
98-
run(Integer.parseInt(groups), dataType, 10, 0);
99-
run(Integer.parseInt(groups), dataType, 10, 1);
98+
run(Integer.parseInt(groups), dataType, 10);
10099
}
101100
}
102101
} catch (NoSuchFieldException e) {
@@ -114,10 +113,7 @@ static void selfTest() {
114113
@Param({ BYTES_REF, INT, LONG })
115114
public String dataType;
116115

117-
@Param({ "0", "1" })
118-
public int numOrdinalMerges;
119-
120-
private static Operator operator(DriverContext driverContext, int groups, String dataType, int numOrdinalMerges) {
116+
private static Operator operator(DriverContext driverContext, int groups, String dataType) {
121117
if (groups == 1) {
122118
return new AggregationOperator(
123119
List.of(supplier(dataType).aggregatorFactory(AggregatorMode.SINGLE, List.of(0)).apply(driverContext)),
@@ -132,20 +128,8 @@ private static Operator operator(DriverContext driverContext, int groups, String
132128
) {
133129
@Override
134130
public Page getOutput() {
135-
mergeOrdinal();
136131
return super.getOutput();
137132
}
138-
139-
// simulate OrdinalsGroupingOperator
140-
void mergeOrdinal() {
141-
var merged = supplier(dataType).groupingAggregatorFactory(AggregatorMode.SINGLE, List.of(1)).apply(driverContext);
142-
for (int i = 0; i < numOrdinalMerges; i++) {
143-
for (int p = 0; p < groups; p++) {
144-
merged.addIntermediateRow(p, aggregators.getFirst(), p);
145-
}
146-
}
147-
aggregators.set(0, merged);
148-
}
149133
};
150134
}
151135

@@ -352,12 +336,12 @@ private static Block groupingBlock(int groups) {
352336

353337
@Benchmark
354338
public void run() {
355-
run(groups, dataType, OP_COUNT, numOrdinalMerges);
339+
run(groups, dataType, OP_COUNT);
356340
}
357341

358-
private static void run(int groups, String dataType, int opCount, int numOrdinalMerges) {
342+
private static void run(int groups, String dataType, int opCount) {
359343
DriverContext driverContext = driverContext();
360-
try (Operator operator = operator(driverContext, groups, dataType, numOrdinalMerges)) {
344+
try (Operator operator = operator(driverContext, groups, dataType)) {
361345
Page page = page(groups, dataType);
362346
for (int i = 0; i < opCount; i++) {
363347
operator.addInput(page.shallowCopy());

docs/changelog/121914.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pr: 121914
2+
summary: Support Fields API in conditional ingest processors
3+
area: Infra/Core
4+
type: feature
5+
issues: []

docs/changelog/128639.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
pr: 128639
2+
summary: Substitue `date_trunc` with `round_to` when the pre-calculated rounding points
3+
are available
4+
area: ES|QL
5+
type: enhancement
6+
issues: []

docs/changelog/129929.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pr: 129929
2+
summary: Add support for RLIKE (LIST) with pushdown
3+
area: ES|QL
4+
type: enhancement
5+
issues: []

docs/changelog/131061.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pr: 131061
2+
summary: Speed up reading multivalued keywords
3+
area: ES|QL
4+
type: enhancement
5+
issues: []

docs/changelog/131173.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pr: 131173
2+
summary: Add attribute count to `SamlAttribute` `toString`
3+
area: Authentication
4+
type: enhancement
5+
issues: []

docs/reference/query-languages/esql.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,5 @@ This reference section provides detailed technical information about {{esql}} fe
2020
* [Advanced workflows](esql/esql-advanced.md): Learn how to handle more complex tasks with these guides, including how to extract, transform, and combine data from multiple indices
2121
* [Types and fields](esql/esql-types-and-fields.md): Learn about how {{esql}} handles different data types and special fields
2222
* [Limitations](esql/limitations.md): Learn about the current limitations of {{esql}}
23-
* [Examples](esql/esql-examples.md): Explore some example queries
23+
* [Examples](esql/esql-examples.md): Explore some example queries
24+
* [Troubleshooting](esql/esql-troubleshooting.md): Learn how to diagnose and resolve issues with {{esql}}

docs/reference/query-languages/esql/_snippets/operators/detailedDescription/rlike.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,17 @@ ROW message = "foo ( bar"
1717
| WHERE message RLIKE """foo \( bar"""
1818
```
1919

20+
```{applies_to}
21+
stack: ga 9.1
22+
serverless: ga
23+
```
24+
25+
Both a single pattern or a list of patterns are supported. If a list of patterns is provided,
26+
the expression will return true if any of the patterns match.
27+
28+
```esql
29+
ROW message = "foobar"
30+
| WHERE message RLIKE ("foo.*", "bar.")
31+
```
32+
2033

Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
---
2+
navigation_title: "Query log"
3+
---
4+
5+
# {{esql}} Query log [esql-query-log]
6+
7+
8+
The {{esql}} query log allows to log {{esql}} queries based on their execution time.
9+
10+
You can use these logs to investigate, analyze or troubleshoot your cluster’s historical {{esql}} performance.
11+
12+
{{esql}} query log reports task duration at coordinator level, but might not encompass the full task execution time observed on the client. For example, logs don’t surface HTTP network delays.
13+
14+
Events that meet the specified threshold are emitted into [{{es}} server logs](docs-content://deploy-manage/monitor/logging-configuration/update-elasticsearch-logging-levels.md).
15+
16+
These logs can be found in local {{es}} service logs directory. Slow log files have a suffix of `_esql_querylog.json`.
17+
18+
## Query log format [query-log-format]
19+
20+
The following is an example of a successful query event in the query log:
21+
22+
```js
23+
{
24+
"@timestamp": "2025-03-11T08:39:50.076Z",
25+
"log.level": "TRACE",
26+
"auth.type": "REALM",
27+
"elasticsearch.querylog.planning.took": 3108666,
28+
"elasticsearch.querylog.planning.took_millis": 3,
29+
"elasticsearch.querylog.query": "from index | limit 100",
30+
"elasticsearch.querylog.search_type": "ESQL",
31+
"elasticsearch.querylog.success": true,
32+
"elasticsearch.querylog.took": 8050416,
33+
"elasticsearch.querylog.took_millis": 8,
34+
"user.name": "elastic-admin",
35+
"user.realm": "default_file",
36+
"ecs.version": "1.2.0",
37+
"service.name": "ES_ECS",
38+
"event.dataset": "elasticsearch.esql_querylog",
39+
"process.thread.name": "elasticsearch[runTask-0][esql_worker][T#12]",
40+
"log.logger": "esql.querylog.query",
41+
"elasticsearch.cluster.uuid": "KZo1V7TcQM-O6fnqMm1t_g",
42+
"elasticsearch.node.id": "uPgRE2TrSfa9IvnUpNT1Uw",
43+
"elasticsearch.node.name": "runTask-0",
44+
"elasticsearch.cluster.name": "runTask"
45+
}
46+
```
47+
48+
The following is an example of a failing query event in the query log:
49+
50+
```js
51+
{
52+
"@timestamp": "2025-03-11T08:41:54.172Z",
53+
"log.level": "TRACE",
54+
"auth.type": "REALM",
55+
"elasticsearch.querylog.error.message": "line 1:15: mismatched input 'limitxyz' expecting {DEV_CHANGE_POINT, 'enrich', 'dissect', 'eval', 'grok', 'limit', 'sort', 'stats', 'where', DEV_INLINESTATS, DEV_FORK, 'lookup', DEV_JOIN_LEFT, DEV_JOIN_RIGHT, DEV_LOOKUP, 'mv_expand', 'drop', 'keep', DEV_INSIST, 'rename'}",
56+
"elasticsearch.querylog.error.type": "org.elasticsearch.xpack.esql.parser.ParsingException",
57+
"elasticsearch.querylog.query": "from person | limitxyz 100",
58+
"elasticsearch.querylog.search_type": "ESQL",
59+
"elasticsearch.querylog.success": false,
60+
"elasticsearch.querylog.took": 963750,
61+
"elasticsearch.querylog.took_millis": 0,
62+
"user.name": "elastic-admin",
63+
"user.realm": "default_file",
64+
"ecs.version": "1.2.0",
65+
"service.name": "ES_ECS",
66+
"event.dataset": "elasticsearch.esql_querylog",
67+
"process.thread.name": "elasticsearch[runTask-0][search][T#16]",
68+
"log.logger": "esql.querylog.query",
69+
"elasticsearch.cluster.uuid": "KZo1V7TcQM-O6fnqMm1t_g",
70+
"elasticsearch.node.id": "uPgRE2TrSfa9IvnUpNT1Uw",
71+
"elasticsearch.node.name": "runTask-0",
72+
"elasticsearch.cluster.name": "runTask"
73+
}
74+
```
75+
76+
77+
## Enable query logging [enable-query-log]
78+
79+
You can enable query logging at cluster level.
80+
81+
By default, all thresholds are set to `-1`, which results in no events being logged.
82+
83+
Query log thresholds can be enabled for the four logging levels: `trace`, `debug`, `info`, and `warn`.
84+
85+
To view the current query log settings, use the [get cluster settings API](https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-cluster-get-settings):
86+
87+
```console
88+
GET _cluster/settings?filter_path=*.esql.querylog.*
89+
```
90+
91+
You can use the `esql.querylog.include.user` setting to append `user.*` and `auth.type` fields to slow log entries. These fields contain information about the user who triggered the request.
92+
93+
The following snippet adjusts all available {{esql}} query log settings [update cluster settings API](https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-cluster-put-settings):
94+
95+
```console
96+
PUT /_cluster/settings
97+
{
98+
"transient": {
99+
"esql.querylog.threshold.warn": "10s",
100+
"esql.querylog.threshold.info": "5s",
101+
"esql.querylog.threshold.debug": "2s",
102+
"esql.querylog.threshold.trace": "500ms",
103+
"esql.querylog.include.user": true
104+
}
105+
}
106+
```
107+
108+
109+
110+
## Best practices for query logging [troubleshoot-query-log]
111+
112+
Logging slow requests can be resource intensive to your {{es}} cluster depending on the qualifying traffic’s volume. For example, emitted logs might increase the index disk usage of your [{{es}} monitoring](docs-content://deploy-manage/monitor/stack-monitoring.md) cluster. To reduce the impact of slow logs, consider the following:
113+
114+
* Set high thresholds to reduce the number of logged events.
115+
* Enable slow logs only when troubleshooting.
116+
117+
If you aren’t sure how to start investigating traffic issues, consider enabling the `warn` threshold with a high `30s` threshold at the index level using the [update cluster settings API](https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-cluster-put-settings):
118+
119+
Here is an example of how to change cluster settings to enable query logging at `warn` level, for queries taking more than 30 seconds, and include user information in the logs:
120+
121+
```console
122+
PUT /_cluster/settings
123+
{
124+
"transient": {
125+
"esql.querylog.include.user": true,
126+
"esql.querylog.threshold.warn": "30s"
127+
}
128+
}
129+
```
130+

0 commit comments

Comments
 (0)