Skip to content
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

[Console] Add autocompletion for data streams #198507

Merged

Conversation

ElenaStoeva
Copy link
Contributor

@ElenaStoeva ElenaStoeva commented Oct 31, 2024

Closes #190137

Summary

This PR adds Console autocompletion for data streams.

We use the patterns in the spec definitions to determine what autocomplete entity we should return. For example the {index} pattern in the endpoint means we should suggest indices and aliases. This pattern comes directly from the schema in the Elasticsearch specification repo, which is used to generate the Console spec definition.

Previously, for the pattern {index}, we would only suggest indices and aliases. However, for most of the endpoints where this pattern is used, we should suggest indices, aliases, and data streams (see the table below). For example, the Get Index API accepts indices, aliases, and data streams as the target, while the spec definition for the GET /<target> endpoint uses the {index} pattern.

In this PR, we make Console also suggest data streams for the {index} pattern.

List with some endpoints that use the {index} pattern:

Es API Endpoint (with link to specs) Expected target by Es (according to docs) Data stream compatible?
Get index API GET /<target> data streams, indices, and aliases
Async Search POST {index}/_async_search Not specified ✅ (tested locally)
Index API PUT/POST {index}/_create/{id} data stream or index
Bulk API POST/PUT {index}/_bulk data stream, index, or index alias
cat count API GET _cat/count/{index} data streams, indices, and aliases
cat indices API GET _cat/indices/{index} data streams, indices, and aliases
cat recovery API GET _cat/recovery/{index} data streams, indices, and aliases

Note: As discussed with @elastic/devtools-team, it is safe to assume that endpoints with the {index} pattern accept data streams, apart from indices and aliases. There are still a few edge cases though, such as alias APIs, which don't accept data streams. Temporarily, it's okay to display data stream suggestions for them, but we could try fixing this in a follow-up PR by utilizing the override specs and adding a pattern for indices and aliases only. Issue: #198588

@ElenaStoeva ElenaStoeva self-assigned this Oct 31, 2024
@ElenaStoeva ElenaStoeva added Feature:Console Dev Tools Console Feature Team:Kibana Management Dev Tools, Index Management, Upgrade Assistant, ILM, Ingest Node Pipelines, and more release_note:skip Skip the PR/issue when compiling release notes v9.0.0 backport:prev-minor Backport to (8.x) the previous minor version (i.e. one version back from main) v8.17.0 labels Oct 31, 2024
const dataStreams = await esClient.asCurrentUser.indices.getDataStream();
const dataStreams = await esClient.asCurrentUser.indices.getDataStream({
name: '*',
expand_wildcards: 'all',
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are adding the expand_wildcards property so that this returns all data streams, including the managed ones that are automatically created.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So was this previously loading dataStreams via the api but not using it in the client?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Outside the scope of this PR - I bet loading all indices / data streams is VERY slow in large clusters.

Copy link
Contributor Author

@ElenaStoeva ElenaStoeva Nov 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So was this previously loading dataStreams via the api but not using it in the client?

Yes, we didn't really use the loaded data streams.

Outside the scope of this PR - I bet loading all indices / data streams is VERY slow in large clusters.

Yes, it might be... We have an open issue for performance testing for the autocomplete route but haven't gotten to it yet: #151160

@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-management (Team:Kibana Management)

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
console 38.2KB 38.3KB +41.0B

cc @ElenaStoeva

@ElenaStoeva ElenaStoeva requested a review from mattkime November 7, 2024 19:23
Copy link
Contributor

@mattkime mattkime left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code changes look good and work well but it would be nice to see a test for this functionality. How difficult would that be?

@ElenaStoeva
Copy link
Contributor Author

ElenaStoeva commented Nov 8, 2024

it would be nice to see a test for this functionality. How difficult would that be?

I think it would be a significant effort, given that we would have to import some of the generated spec files, extract the endpoint pattern that should be typed in the editor, and check if the suggestions are correct (we should probably create some data streams/indices to check if they are suggested). There is a high chance of flakiness as we already have flakiness issues with the basic autocomplete tests. We have an issue for improving the testing process (#153451). I will merge this PR as is and we could look into improving the testing process separately.

@ElenaStoeva ElenaStoeva merged commit af2834f into elastic:main Nov 8, 2024
22 checks passed
@kibanamachine
Copy link
Contributor

Starting backport for target branches: 8.x

https://github.com/elastic/kibana/actions/runs/11740217808

kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Nov 8, 2024
Closes elastic#190137

## Summary

This PR adds Console autocompletion for data streams.

We use the patterns in the spec definitions to determine what
autocomplete entity we should return. For example the `{index}` pattern
in the endpoint means we should suggest indices and aliases. This
pattern comes directly from the schema in the [Elasticsearch
specification
repo](https://github.com/elastic/elasticsearch-specification/blob/main/output/schema/schema.json),
which is used to generate the Console spec definition.

Previously, for the pattern `{index}`, we would only suggest indices and
aliases. However, for most of the endpoints where this pattern is used,
we should suggest indices, aliases, **and data streams** (see the table
below). For example, the [Get Index
API](https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-get-index.html)
accepts indices, aliases, and data streams as the target, while the spec
definition for the `GET /<target>` endpoint uses the `{index}` pattern.

In this PR, we make Console also suggest data streams for the `{index}`
pattern.

List with some endpoints that use the `{index}` pattern:

Es API | Endpoint (with link to specs) | Expected target by Es
(according to docs) | Data stream compatible?
--- | --- | --- | ---
[Get index
API](https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-get-index.html)
| [`GET
/<target>`](https://github.com/elastic/kibana/blob/e0838147bddeee43edbcb83ced8d0346f917047c/src/plugins/console/server/lib/spec_definitions/json/generated/indices.get.json#L35)
| data streams, indices, and aliases | ✅
[Async
Search](https://www.elastic.co/guide/en/elasticsearch/reference/current/async-search.html)
| [`POST
{index}/_async_search`](https://github.com/elastic/kibana/blob/e0838147bddeee43edbcb83ced8d0346f917047c/src/plugins/console/server/lib/spec_definitions/json/generated/async_search.submit.json#L94)
| Not specified | ✅ (tested locally)
[Index
API](https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-index_.html)
| `PUT/POST {index}/_create/{id}` | data stream or index | ✅
[Bulk
API](https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-bulk.html)
| [`POST/PUT
{index}/_bulk`](https://github.com/elastic/kibana/blob/3ac902df8a93d4924996c5cd1584faeeff9be6cb/src/plugins/console/server/lib/spec_definitions/json/generated/bulk.json#L36)
| data stream, index, or index alias | ✅
[cat count
API](https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-count.html)
| [`GET
_cat/count/{index}`](https://github.com/elastic/kibana/blob/3ac902df8a93d4924996c5cd1584faeeff9be6cb/src/plugins/console/server/lib/spec_definitions/json/generated/cat.count.json#L27)
| data streams, indices, and aliases | ✅
[cat indices
API](https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-indices.html)
| `GET _cat/indices/{index}` | data streams, indices, and aliases | ✅
[cat recovery
API](https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-recovery.html)
| `GET _cat/recovery/{index}` | data streams, indices, and aliases | ✅

Note: As discussed with @elastic/devtools-team, it is safe to assume
that endpoints with the `{index}` pattern accept data streams, apart
from indices and aliases. There are still a few edge cases though, such
as alias APIs, which don't accept data streams. Temporarily, it's okay
to display data stream suggestions for them, but we could try fixing
this in a follow-up PR by utilizing the override specs and adding a
pattern for indices and aliases only. Issue:
elastic#198588

(cherry picked from commit af2834f)
@kibanamachine
Copy link
Contributor

💚 All backports created successfully

Status Branch Result
8.x

Note: Successful backport PRs will be merged automatically after passing CI.

Questions ?

Please refer to the Backport tool documentation

kibanamachine added a commit that referenced this pull request Nov 8, 2024
# Backport

This will backport the following commits from `main` to `8.x`:
- [[Console] Add autocompletion for data streams
(#198507)](#198507)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Elena
Stoeva","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-11-08T10:15:19Z","message":"[Console]
Add autocompletion for data streams (#198507)\n\nCloses
https://github.com/elastic/kibana/issues/190137\r\n\r\n##
Summary\r\n\r\nThis PR adds Console autocompletion for data
streams.\r\n\r\nWe use the patterns in the spec definitions to determine
what\r\nautocomplete entity we should return. For example the `{index}`
pattern\r\nin the endpoint means we should suggest indices and aliases.
This\r\npattern comes directly from the schema in the
[Elasticsearch\r\nspecification\r\nrepo](https://github.com/elastic/elasticsearch-specification/blob/main/output/schema/schema.json),\r\nwhich
is used to generate the Console spec definition.\r\n\r\nPreviously, for
the pattern `{index}`, we would only suggest indices and\r\naliases.
However, for most of the endpoints where this pattern is used,\r\nwe
should suggest indices, aliases, **and data streams** (see the
table\r\nbelow). For example, the [Get
Index\r\nAPI](https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-get-index.html)\r\naccepts
indices, aliases, and data streams as the target, while the
spec\r\ndefinition for the `GET /<target>` endpoint uses the `{index}`
pattern.\r\n\r\nIn this PR, we make Console also suggest data streams
for the `{index}`\r\npattern.\r\n\r\nList with some endpoints that use
the `{index}` pattern:\r\n\r\nEs API | Endpoint (with link to specs) |
Expected target by Es\r\n(according to docs) | Data stream
compatible?\r\n--- | --- | --- | --- \r\n[Get
index\r\nAPI](https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-get-index.html)\r\n|
[`GET\r\n/<target>`](https://github.com/elastic/kibana/blob/e0838147bddeee43edbcb83ced8d0346f917047c/src/plugins/console/server/lib/spec_definitions/json/generated/indices.get.json#L35)\r\n|
data streams, indices, and aliases |
✅\r\n[Async\r\nSearch](https://www.elastic.co/guide/en/elasticsearch/reference/current/async-search.html)\r\n|
[`POST\r\n{index}/_async_search`](https://github.com/elastic/kibana/blob/e0838147bddeee43edbcb83ced8d0346f917047c/src/plugins/console/server/lib/spec_definitions/json/generated/async_search.submit.json#L94)\r\n|
Not specified | ✅ (tested
locally)\r\n[Index\r\nAPI](https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-index_.html)\r\n|
`PUT/POST {index}/_create/{id}` | data stream or index |
✅\r\n[Bulk\r\nAPI](https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-bulk.html)\r\n|
[`POST/PUT\r\n{index}/_bulk`](https://github.com/elastic/kibana/blob/3ac902df8a93d4924996c5cd1584faeeff9be6cb/src/plugins/console/server/lib/spec_definitions/json/generated/bulk.json#L36)\r\n|
data stream, index, or index alias | ✅\r\n[cat
count\r\nAPI](https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-count.html)\r\n|
[`GET\r\n_cat/count/{index}`](https://github.com/elastic/kibana/blob/3ac902df8a93d4924996c5cd1584faeeff9be6cb/src/plugins/console/server/lib/spec_definitions/json/generated/cat.count.json#L27)\r\n|
data streams, indices, and aliases | ✅\r\n[cat
indices\r\nAPI](https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-indices.html)\r\n|
`GET _cat/indices/{index}` | data streams, indices, and aliases |
✅\r\n[cat
recovery\r\nAPI](https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-recovery.html)\r\n|
`GET _cat/recovery/{index}` | data streams, indices, and aliases |
✅\r\n\r\n\r\nNote: As discussed with @elastic/devtools-team, it is safe
to assume\r\nthat endpoints with the `{index}` pattern accept data
streams, apart\r\nfrom indices and aliases. There are still a few edge
cases though, such\r\nas alias APIs, which don't accept data streams.
Temporarily, it's okay\r\nto display data stream suggestions for them,
but we could try fixing\r\nthis in a follow-up PR by utilizing the
override specs and adding a\r\npattern for indices and aliases only.
Issue:\r\nhttps://github.com//issues/198588","sha":"af2834f5c3cb4cf3e576264ed8193e7d0abfab5f","branchLabelMapping":{"^v9.0.0$":"main","^v8.17.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Feature:Console","Team:Kibana
Management","release_note:skip","v9.0.0","backport:prev-minor","v8.17.0"],"title":"[Console]
Add autocompletion for data
streams","number":198507,"url":"https://github.com/elastic/kibana/pull/198507","mergeCommit":{"message":"[Console]
Add autocompletion for data streams (#198507)\n\nCloses
https://github.com/elastic/kibana/issues/190137\r\n\r\n##
Summary\r\n\r\nThis PR adds Console autocompletion for data
streams.\r\n\r\nWe use the patterns in the spec definitions to determine
what\r\nautocomplete entity we should return. For example the `{index}`
pattern\r\nin the endpoint means we should suggest indices and aliases.
This\r\npattern comes directly from the schema in the
[Elasticsearch\r\nspecification\r\nrepo](https://github.com/elastic/elasticsearch-specification/blob/main/output/schema/schema.json),\r\nwhich
is used to generate the Console spec definition.\r\n\r\nPreviously, for
the pattern `{index}`, we would only suggest indices and\r\naliases.
However, for most of the endpoints where this pattern is used,\r\nwe
should suggest indices, aliases, **and data streams** (see the
table\r\nbelow). For example, the [Get
Index\r\nAPI](https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-get-index.html)\r\naccepts
indices, aliases, and data streams as the target, while the
spec\r\ndefinition for the `GET /<target>` endpoint uses the `{index}`
pattern.\r\n\r\nIn this PR, we make Console also suggest data streams
for the `{index}`\r\npattern.\r\n\r\nList with some endpoints that use
the `{index}` pattern:\r\n\r\nEs API | Endpoint (with link to specs) |
Expected target by Es\r\n(according to docs) | Data stream
compatible?\r\n--- | --- | --- | --- \r\n[Get
index\r\nAPI](https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-get-index.html)\r\n|
[`GET\r\n/<target>`](https://github.com/elastic/kibana/blob/e0838147bddeee43edbcb83ced8d0346f917047c/src/plugins/console/server/lib/spec_definitions/json/generated/indices.get.json#L35)\r\n|
data streams, indices, and aliases |
✅\r\n[Async\r\nSearch](https://www.elastic.co/guide/en/elasticsearch/reference/current/async-search.html)\r\n|
[`POST\r\n{index}/_async_search`](https://github.com/elastic/kibana/blob/e0838147bddeee43edbcb83ced8d0346f917047c/src/plugins/console/server/lib/spec_definitions/json/generated/async_search.submit.json#L94)\r\n|
Not specified | ✅ (tested
locally)\r\n[Index\r\nAPI](https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-index_.html)\r\n|
`PUT/POST {index}/_create/{id}` | data stream or index |
✅\r\n[Bulk\r\nAPI](https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-bulk.html)\r\n|
[`POST/PUT\r\n{index}/_bulk`](https://github.com/elastic/kibana/blob/3ac902df8a93d4924996c5cd1584faeeff9be6cb/src/plugins/console/server/lib/spec_definitions/json/generated/bulk.json#L36)\r\n|
data stream, index, or index alias | ✅\r\n[cat
count\r\nAPI](https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-count.html)\r\n|
[`GET\r\n_cat/count/{index}`](https://github.com/elastic/kibana/blob/3ac902df8a93d4924996c5cd1584faeeff9be6cb/src/plugins/console/server/lib/spec_definitions/json/generated/cat.count.json#L27)\r\n|
data streams, indices, and aliases | ✅\r\n[cat
indices\r\nAPI](https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-indices.html)\r\n|
`GET _cat/indices/{index}` | data streams, indices, and aliases |
✅\r\n[cat
recovery\r\nAPI](https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-recovery.html)\r\n|
`GET _cat/recovery/{index}` | data streams, indices, and aliases |
✅\r\n\r\n\r\nNote: As discussed with @elastic/devtools-team, it is safe
to assume\r\nthat endpoints with the `{index}` pattern accept data
streams, apart\r\nfrom indices and aliases. There are still a few edge
cases though, such\r\nas alias APIs, which don't accept data streams.
Temporarily, it's okay\r\nto display data stream suggestions for them,
but we could try fixing\r\nthis in a follow-up PR by utilizing the
override specs and adding a\r\npattern for indices and aliases only.
Issue:\r\nhttps://github.com//issues/198588","sha":"af2834f5c3cb4cf3e576264ed8193e7d0abfab5f"}},"sourceBranch":"main","suggestedTargetBranches":["8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/198507","number":198507,"mergeCommit":{"message":"[Console]
Add autocompletion for data streams (#198507)\n\nCloses
https://github.com/elastic/kibana/issues/190137\r\n\r\n##
Summary\r\n\r\nThis PR adds Console autocompletion for data
streams.\r\n\r\nWe use the patterns in the spec definitions to determine
what\r\nautocomplete entity we should return. For example the `{index}`
pattern\r\nin the endpoint means we should suggest indices and aliases.
This\r\npattern comes directly from the schema in the
[Elasticsearch\r\nspecification\r\nrepo](https://github.com/elastic/elasticsearch-specification/blob/main/output/schema/schema.json),\r\nwhich
is used to generate the Console spec definition.\r\n\r\nPreviously, for
the pattern `{index}`, we would only suggest indices and\r\naliases.
However, for most of the endpoints where this pattern is used,\r\nwe
should suggest indices, aliases, **and data streams** (see the
table\r\nbelow). For example, the [Get
Index\r\nAPI](https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-get-index.html)\r\naccepts
indices, aliases, and data streams as the target, while the
spec\r\ndefinition for the `GET /<target>` endpoint uses the `{index}`
pattern.\r\n\r\nIn this PR, we make Console also suggest data streams
for the `{index}`\r\npattern.\r\n\r\nList with some endpoints that use
the `{index}` pattern:\r\n\r\nEs API | Endpoint (with link to specs) |
Expected target by Es\r\n(according to docs) | Data stream
compatible?\r\n--- | --- | --- | --- \r\n[Get
index\r\nAPI](https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-get-index.html)\r\n|
[`GET\r\n/<target>`](https://github.com/elastic/kibana/blob/e0838147bddeee43edbcb83ced8d0346f917047c/src/plugins/console/server/lib/spec_definitions/json/generated/indices.get.json#L35)\r\n|
data streams, indices, and aliases |
✅\r\n[Async\r\nSearch](https://www.elastic.co/guide/en/elasticsearch/reference/current/async-search.html)\r\n|
[`POST\r\n{index}/_async_search`](https://github.com/elastic/kibana/blob/e0838147bddeee43edbcb83ced8d0346f917047c/src/plugins/console/server/lib/spec_definitions/json/generated/async_search.submit.json#L94)\r\n|
Not specified | ✅ (tested
locally)\r\n[Index\r\nAPI](https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-index_.html)\r\n|
`PUT/POST {index}/_create/{id}` | data stream or index |
✅\r\n[Bulk\r\nAPI](https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-bulk.html)\r\n|
[`POST/PUT\r\n{index}/_bulk`](https://github.com/elastic/kibana/blob/3ac902df8a93d4924996c5cd1584faeeff9be6cb/src/plugins/console/server/lib/spec_definitions/json/generated/bulk.json#L36)\r\n|
data stream, index, or index alias | ✅\r\n[cat
count\r\nAPI](https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-count.html)\r\n|
[`GET\r\n_cat/count/{index}`](https://github.com/elastic/kibana/blob/3ac902df8a93d4924996c5cd1584faeeff9be6cb/src/plugins/console/server/lib/spec_definitions/json/generated/cat.count.json#L27)\r\n|
data streams, indices, and aliases | ✅\r\n[cat
indices\r\nAPI](https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-indices.html)\r\n|
`GET _cat/indices/{index}` | data streams, indices, and aliases |
✅\r\n[cat
recovery\r\nAPI](https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-recovery.html)\r\n|
`GET _cat/recovery/{index}` | data streams, indices, and aliases |
✅\r\n\r\n\r\nNote: As discussed with @elastic/devtools-team, it is safe
to assume\r\nthat endpoints with the `{index}` pattern accept data
streams, apart\r\nfrom indices and aliases. There are still a few edge
cases though, such\r\nas alias APIs, which don't accept data streams.
Temporarily, it's okay\r\nto display data stream suggestions for them,
but we could try fixing\r\nthis in a follow-up PR by utilizing the
override specs and adding a\r\npattern for indices and aliases only.
Issue:\r\nhttps://github.com//issues/198588","sha":"af2834f5c3cb4cf3e576264ed8193e7d0abfab5f"}},{"branch":"8.x","label":"v8.17.0","branchLabelMappingKey":"^v8.17.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Elena Stoeva <[email protected]>
CAWilson94 pushed a commit to CAWilson94/kibana that referenced this pull request Nov 8, 2024
Closes elastic#190137

## Summary

This PR adds Console autocompletion for data streams.

We use the patterns in the spec definitions to determine what
autocomplete entity we should return. For example the `{index}` pattern
in the endpoint means we should suggest indices and aliases. This
pattern comes directly from the schema in the [Elasticsearch
specification
repo](https://github.com/elastic/elasticsearch-specification/blob/main/output/schema/schema.json),
which is used to generate the Console spec definition.

Previously, for the pattern `{index}`, we would only suggest indices and
aliases. However, for most of the endpoints where this pattern is used,
we should suggest indices, aliases, **and data streams** (see the table
below). For example, the [Get Index
API](https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-get-index.html)
accepts indices, aliases, and data streams as the target, while the spec
definition for the `GET /<target>` endpoint uses the `{index}` pattern.

In this PR, we make Console also suggest data streams for the `{index}`
pattern.

List with some endpoints that use the `{index}` pattern:

Es API | Endpoint (with link to specs) | Expected target by Es
(according to docs) | Data stream compatible?
--- | --- | --- | --- 
[Get index
API](https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-get-index.html)
| [`GET
/<target>`](https://github.com/elastic/kibana/blob/e0838147bddeee43edbcb83ced8d0346f917047c/src/plugins/console/server/lib/spec_definitions/json/generated/indices.get.json#L35)
| data streams, indices, and aliases | ✅
[Async
Search](https://www.elastic.co/guide/en/elasticsearch/reference/current/async-search.html)
| [`POST
{index}/_async_search`](https://github.com/elastic/kibana/blob/e0838147bddeee43edbcb83ced8d0346f917047c/src/plugins/console/server/lib/spec_definitions/json/generated/async_search.submit.json#L94)
| Not specified | ✅ (tested locally)
[Index
API](https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-index_.html)
| `PUT/POST {index}/_create/{id}` | data stream or index | ✅
[Bulk
API](https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-bulk.html)
| [`POST/PUT
{index}/_bulk`](https://github.com/elastic/kibana/blob/3ac902df8a93d4924996c5cd1584faeeff9be6cb/src/plugins/console/server/lib/spec_definitions/json/generated/bulk.json#L36)
| data stream, index, or index alias | ✅
[cat count
API](https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-count.html)
| [`GET
_cat/count/{index}`](https://github.com/elastic/kibana/blob/3ac902df8a93d4924996c5cd1584faeeff9be6cb/src/plugins/console/server/lib/spec_definitions/json/generated/cat.count.json#L27)
| data streams, indices, and aliases | ✅
[cat indices
API](https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-indices.html)
| `GET _cat/indices/{index}` | data streams, indices, and aliases | ✅
[cat recovery
API](https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-recovery.html)
| `GET _cat/recovery/{index}` | data streams, indices, and aliases | ✅


Note: As discussed with @elastic/devtools-team, it is safe to assume
that endpoints with the `{index}` pattern accept data streams, apart
from indices and aliases. There are still a few edge cases though, such
as alias APIs, which don't accept data streams. Temporarily, it's okay
to display data stream suggestions for them, but we could try fixing
this in a follow-up PR by utilizing the override specs and adding a
pattern for indices and aliases only. Issue:
elastic#198588
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:prev-minor Backport to (8.x) the previous minor version (i.e. one version back from main) Feature:Console Dev Tools Console Feature release_note:skip Skip the PR/issue when compiling release notes Team:Kibana Management Dev Tools, Index Management, Upgrade Assistant, ILM, Ingest Node Pipelines, and more v8.17.0 v9.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Dev console autocomplete doesn't support datastreams
4 participants