-
Notifications
You must be signed in to change notification settings - Fork 24.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Collect and display execution metadata for ES|QL cross cluster searches #112595
Changes from 28 commits
6ebc396
512fdec
39428fa
892cd99
fb10109
797cc8c
fa7bbb0
71a33ed
ab347a6
c39111b
1a3a7f8
544aaeb
ca2de85
f839132
3f3139b
e090437
b2b2542
5e7876e
3e16fbb
ed5b9db
661a243
9535bdd
699b16a
228eed2
fa9c7c4
c51719e
d365c37
8688dbf
5b93774
449e1a7
0083ae7
5462d6b
5f27325
9e77c28
fd6d3bf
6e87174
b474fc7
1649962
20c9356
e6aa92a
59d1480
8bb1b7f
6323cdf
4875a66
24e0c02
940ef22
617cbec
c45d181
13a34de
9ac5746
3afb7a1
b118406
fc53eb7
d50658c
dc467ac
711c1f8
8e5f170
838e6a9
77cc107
0e71453
a69f3db
a7efbec
aa8bbaa
e5e45b5
9a304c2
d79af98
826aab7
ec99687
02092e9
8569bfa
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
pr: 112595 | ||
summary: Collect and display execution metadata for ES|QL cross cluster searches | ||
area: ES|QL | ||
type: enhancement | ||
issues: | ||
- 112402 |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -85,7 +85,7 @@ POST /_security/role/remote1 | |
"privileges": [ "read","read_cross_cluster" ], <4> | ||
"clusters" : ["my_remote_cluster"] <5> | ||
} | ||
], | ||
], | ||
"remote_cluster": [ <6> | ||
{ | ||
"privileges": [ | ||
|
@@ -174,6 +174,184 @@ FROM *:my-index-000001 | |
| LIMIT 10 | ||
---- | ||
|
||
[discrete] | ||
[[ccq-cluster-details]] | ||
==== Cross-cluster metadata | ||
|
||
ES|QL {ccs} responses include metadata about the search on each cluster when the response format is JSON. | ||
Here we show an example using the async search endpoint. {ccs-cap} metadata is also present in the synchronous | ||
search endpoint. | ||
|
||
[source,esql] | ||
---- | ||
POST /_query/async?format=json | ||
{ | ||
"query": """ | ||
FROM my-index-000001,cluster_one:my-index-000001,cluster_two:my-index* | ||
| KEEP author, name, page_count | ||
| SORT page_count DESC | ||
| LIMIT 50 | ||
""" | ||
} | ||
---- | ||
|
||
Which returns: | ||
|
||
[source,console-result] | ||
---- | ||
{ | ||
"is_running": false, | ||
"took": 42, <1> | ||
"columns": [ | ||
... // not shown | ||
], | ||
"values": [ | ||
... // not shown | ||
], | ||
"_clusters": { <2> | ||
"total": 3, | ||
"successful": 3, | ||
"running": 0, | ||
"skipped": 0, | ||
"partial": 0, | ||
"failed": 0, | ||
"details": { <3> | ||
"(local)": { <4> | ||
"status": "successful", | ||
"indices": "blogs", | ||
"took": 36, <5> | ||
"_shards": { <6> | ||
"total": 13, | ||
"successful": 13, | ||
"skipped": 0, | ||
"failed": 0 | ||
} | ||
}, | ||
"cluster_one": { | ||
"status": "successful", | ||
"indices": "cluster_one:my-index-000001", | ||
"took": 38, | ||
"_shards": { | ||
"total": 4, | ||
"successful": 4, | ||
"skipped": 0, | ||
"failed": 0 | ||
} | ||
}, | ||
"cluster_two": { | ||
"status": "successful", | ||
"indices": "cluster_two:my-index-000001", <7> | ||
"took": 41, | ||
"_shards": { | ||
"total": 18, | ||
"successful": 18, | ||
"skipped": 1, | ||
"failed": 0 | ||
} | ||
} | ||
} | ||
} | ||
} | ||
---- | ||
// TEST[skip: cross-cluster testing env not set up] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The local cluster should be available, right? Could we remove the multi-cluster output so we get the assertion that the shape is pretty close? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I spent several hours trying but unless you know of a trick to do clever multi-line matching I don't see how this is possible. Among the things I tried was adding "m" to the end of the matcher to indicate multi-line matching (as in Perl matching), but that doesn't work. Mostly I just get failed runs with no information as to what is wrong. Plus I'm not really sure it's worth it? The whole point of this section is to show the We probably need another ticket to enable the multi-cluster testing setup that search-across-clusters.asciidoc uses, as that was not set up for this test. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
|
||
<1> How the long the entire search (across all clusters) took, in milliseconds. | ||
quux00 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
<2> This section of counters shows all possible cluster search states and how many cluster | ||
searches are currently in that state. The clusters can be one of the following statuses: *running*, | ||
quux00 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
*successful* (searches on all shards were successful), *partial* (searches on at least | ||
one shard of the cluster was successful and at least one failed), *skipped* (the search | ||
failed on a cluster marked with `skip_unavailable`=`true`) or *failed* (the search | ||
failed on a cluster marked with `skip_unavailable`=`false`). | ||
<3> The `_clusters/details` section shows metadata about the search on each cluster. | ||
<4> If you included indices from the local cluster you sent the request to in your {ccs}, | ||
it is identified as "(local)". | ||
<5> How long (in milliseconds) the search took on each cluster. This can be useful to determine | ||
which clusters have slower response times than others. | ||
<6> The shard details for the search on that cluster, including a count of shards that were | ||
skipped due to the can-match phase indicating it had no matching data so it did not need | ||
to be included in the full ESQL query. | ||
quux00 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
<7> The index expression supplied by the user. If you provide a wildcard such as `my-index*`, | ||
this section will show the resolved index name(s) here, unless no matching indices could | ||
be found on that cluster, in which case the wildcard expression will be retained here. | ||
|
||
|
||
The cross-cluster metadata can be used to determine if any data came back from a cluster. | ||
For instance in this query, you see that wildcard expression for `cluster-one` did not | ||
resolve to a concrete index (or indices) and that the total number of shards searched is | ||
zero. This indicates that no matching index was found on that cluster. But since the other | ||
cluster did have a matching index, the search did not return an error, but instead | ||
returned all the matching data it could find. | ||
|
||
[source,esql] | ||
---- | ||
POST /_query/async?format=json | ||
{ | ||
"query": """ | ||
FROM cluster_one:my-index*,cluster_two:logs* | ||
| KEEP author, name, page_count | ||
| SORT page_count DESC | ||
| LIMIT 5 | ||
""" | ||
} | ||
---- | ||
|
||
Which returns: | ||
|
||
[source,console-result] | ||
---- | ||
{ | ||
"is_running": false, | ||
"took": 55, | ||
"columns": [ | ||
... // not shown | ||
], | ||
"values": [ | ||
... // not shown | ||
], | ||
"_clusters": { | ||
"total": 2, | ||
"successful": 2, | ||
"running": 0, | ||
"skipped": 0, | ||
"partial": 0, | ||
"failed": 0, | ||
"details": { | ||
"cluster_one": { | ||
"status": "successful", | ||
"indices": "cluster_one:my-index-000001", | ||
"took": 38, | ||
"_shards": { | ||
"total": 4, | ||
"successful": 4, | ||
"skipped": 0, | ||
"failed": 0 | ||
} | ||
}, | ||
"cluster_two": { | ||
"status": "successful", <1> | ||
"indices": "cluster_two:logs*", <2> | ||
"took": 0, | ||
"_shards": { | ||
"total": 0, <3> | ||
"successful": 0, | ||
"skipped": 0, | ||
"failed": 0 | ||
} | ||
} | ||
} | ||
} | ||
} | ||
---- | ||
// TEST[skip: cross-cluster testing env not set up] | ||
|
||
<1> This search is still marked as successful, even though no data was searched. | ||
<2> Since there were no matching indices for the wildcard pattern provided, the original | ||
index expression provided by the user is retained here. | ||
<3> Indicates that no shards were searched (due to not having any matching indices). | ||
|
||
|
||
|
||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @naj-h and @tylerperk - Please review proposed end user docs changes. |
||
[discrete] | ||
[[ccq-enrich]] | ||
==== Enrich across clusters | ||
|
@@ -331,8 +509,7 @@ setting. As a result, if a remote cluster specified in the request is | |
unavailable or failed, {ccs} for {esql} queries will fail regardless of the setting. | ||
|
||
We are actively working to align the behavior of {ccs} for {esql} with other | ||
{ccs} APIs. This includes providing detailed execution information for each cluster | ||
in the response, such as execution time, selected target indices, and shards. | ||
{ccs} APIs. | ||
|
||
[discrete] | ||
[[ccq-during-upgrade]] | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you make this a
console
snippet instead and make the test runner happy with it with something like// TEST[setup:my_index]
. That way we run it so if it ever goes out of date we fail the build.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess we'd have to do
// TEST[s/cluster_one:my-index-000001,cluster_two:my-index//]
to remove the multi-cluster from the test case.....There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I have changed the two queries I added to actually be executed, but (see comment below) I am unable to find a way to test the response JSON, so I have left that as "TEST[skip...]".