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
Collect and display execution metadata for ES|QL cross cluster searches (elastic#112595)
Enhance ES|QL responses to include information about `took` time (search latency), shards, and
clusters against which the query was executed.
The goal of this PR is to begin to provide parity between the metadata displayed for
cross-cluster searches in _search and ES|QL.
This PR adds the following features:
- add overall `took` time to all ES|QL query responses. And to emphasize: "all" here
means: async search, sync search, local-only and cross-cluster searches, so it goes
beyond just CCS.
- add `_clusters` metadata to the final response for cross-cluster searches, for both
async and sync search (see example below)
- tracking/reporting counts of skipped shards from the can_match (SearchShards API)
phase of ES|QL processing
- marking clusters as skipped if they cannot be connected to (during the field-caps
phase of processing)
Out of scope for this PR:
- honoring the `skip_unavailable` cluster setting
- showing `_clusters` metadata in the async response **while** the search is still running
- showing any shard failure messages (since any shard search failures in ES|QL are
automatically fatal and _cluster/details is not shown in 4xx/5xx error responses). Note that
this also means that the `failed` shard count is always 0 in ES|QL `_clusters` section.
Things changed with respect to behavior in `_search`:
- the `timed_out` field in `_clusters/details/mycluster` was removed in the ESQL
response, since ESQL does not support timeouts. It could be added back later
if/when ESQL supports timeouts.
- the `failures` array in `_clusters/details/mycluster/_shards` was removed in the ESQL
response, since any shard failure causes the whole query to fail.
Example output from ES|QL CCS:
```es
POST /_query
{
"query": "from blogs,remote2:bl*,remote1:blogs|\nkeep authors.first_name,publish_date|\n limit 5"
}
```
```json
{
"took": 49,
"columns": [
{
"name": "authors.first_name",
"type": "text"
},
{
"name": "publish_date",
"type": "date"
}
],
"values": [
[
"Tammy",
"2009-11-04T04:08:07.000Z"
],
[
"Theresa",
"2019-05-10T21:22:32.000Z"
],
[
"Jason",
"2021-11-23T00:57:30.000Z"
],
[
"Craig",
"2019-12-14T21:24:29.000Z"
],
[
"Alexandra",
"2013-02-15T18:13:24.000Z"
]
],
"_clusters": {
"total": 3,
"successful": 2,
"running": 0,
"skipped": 1,
"partial": 0,
"failed": 0,
"details": {
"(local)": {
"status": "successful",
"indices": "blogs",
"took": 43,
"_shards": {
"total": 13,
"successful": 13,
"skipped": 0,
"failed": 0
}
},
"remote2": {
"status": "skipped", // remote2 was offline when this query was run
"indices": "remote2:bl*",
"took": 0,
"_shards": {
"total": 0,
"successful": 0,
"skipped": 0,
"failed": 0
}
},
"remote1": {
"status": "successful",
"indices": "remote1:blogs",
"took": 47,
"_shards": {
"total": 13,
"successful": 13,
"skipped": 0,
"failed": 0
}
}
}
}
}
```
Fixeselastic#112402 and elastic#110935
@@ -100,15 +100,23 @@ POST /_security/role/remote1
100
100
----
101
101
102
102
<1> The `cross_cluster_search` cluster privilege is required for the _local_ cluster.
103
-
<2> Typically, users will have permissions to read both local and remote indices. However, for cases where the role is intended to ONLY search the remote cluster, the `read` permission is still required for the local cluster. To provide read access to the local cluster, but disallow reading any indices in the local cluster, the `names` field may be an empty string.
104
-
<3> The indices allowed read access to the remote cluster. The configured <<security-api-create-cross-cluster-api-key,cross-cluster API key>> must also allow this index to be read.
105
-
<4> The `read_cross_cluster` privilege is always required when using {esql} across clusters with the API key based security model.
103
+
<2> Typically, users will have permissions to read both local and remote indices. However, for cases where the role
104
+
is intended to ONLY search the remote cluster, the `read` permission is still required for the local cluster.
105
+
To provide read access to the local cluster, but disallow reading any indices in the local cluster, the `names`
106
+
field may be an empty string.
107
+
<3> The indices allowed read access to the remote cluster. The configured
108
+
<<security-api-create-cross-cluster-api-key,cross-cluster API key>> must also allow this index to be read.
109
+
<4> The `read_cross_cluster` privilege is always required when using {esql} across clusters with the API key based
110
+
security model.
106
111
<5> The remote clusters to which these privileges apply.
107
-
This remote cluster must be configured with a <<security-api-create-cross-cluster-api-key,cross-cluster API key>> and connected to the remote cluster before the remote index can be queried.
112
+
This remote cluster must be configured with a <<security-api-create-cross-cluster-api-key,cross-cluster API key>>
113
+
and connected to the remote cluster before the remote index can be queried.
108
114
Verify connection using the <<cluster-remote-info, Remote cluster info>> API.
109
-
<6> Required to allow remote enrichment. Without this, the user cannot read from the `.enrich` indices on the remote cluster. The `remote_cluster` security privilege was introduced in version *8.15.0*.
115
+
<6> Required to allow remote enrichment. Without this, the user cannot read from the `.enrich` indices on the
116
+
remote cluster. The `remote_cluster` security privilege was introduced in version *8.15.0*.
110
117
111
-
You will then need a user or API key with the permissions you created above. The following example API call creates a user with the `remote1` role.
118
+
You will then need a user or API key with the permissions you created above. The following example API call creates
119
+
a user with the `remote1` role.
112
120
113
121
[source,console]
114
122
----
@@ -119,11 +127,13 @@ POST /_security/user/remote_user
119
127
}
120
128
----
121
129
122
-
Remember that all cross-cluster requests from the local cluster are bound by the cross cluster API key’s privileges, which are controlled by the remote cluster's administrator.
130
+
Remember that all cross-cluster requests from the local cluster are bound by the cross cluster API key’s privileges,
131
+
which are controlled by the remote cluster's administrator.
123
132
124
133
[TIP]
125
134
====
126
-
Cross cluster API keys created in versions prior to 8.15.0 will need to replaced or updated to add the new permissions required for {esql} with ENRICH.
135
+
Cross cluster API keys created in versions prior to 8.15.0 will need to replaced or updated to add the new permissions
136
+
required for {esql} with ENRICH.
127
137
====
128
138
129
139
[discrete]
@@ -174,6 +184,189 @@ FROM *:my-index-000001
174
184
| LIMIT 10
175
185
----
176
186
187
+
[discrete]
188
+
[[ccq-cluster-details]]
189
+
==== Cross-cluster metadata
190
+
191
+
ES|QL {ccs} responses include metadata about the search on each cluster when the response format is JSON.
192
+
Here we show an example using the async search endpoint. {ccs-cap} metadata is also present in the synchronous
193
+
search endpoint.
194
+
195
+
[source,console]
196
+
----
197
+
POST /_query/async?format=json
198
+
{
199
+
"query": """
200
+
FROM my-index-000001,cluster_one:my-index-000001,cluster_two:my-index*
201
+
| STATS COUNT(http.response.status_code) BY user.id
0 commit comments