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

[ML] Trained Models: Optimize trained models Kibana API #200977

Merged
merged 26 commits into from
Dec 4, 2024

Conversation

darnautov
Copy link
Contributor

@darnautov darnautov commented Nov 20, 2024

Summary

Closes #191939
Closes #175220

Adds various optimizations for the Trained Models page:


  • Creates a new Kibana /trained_models_list endpoint responsible for fetching complete data for the Trained Model UI page, including pipelines, indices and stats.

Before the Trained Models page required 3 endpoints. The new trained_models_list replaces them, reducing the overall latency.

Screenshot 2024-12-02 at 16 18 32
  • Optimized fetching of pipelines, indices and stats, reducing the number of API calls to ES

Several issues with the old endpoint stemmed from the with_indices flag. This flag triggered a method designed for the Model Map feature, which involved fetching a complete list of pipelines, iterating over each model, retrieving index settings multiple times, and obtaining both index content and a full list of transforms.

The new endpoint solves these issues by fetching only the necessary information for the Trained Model page with minimal calls to Elasticsearch.

APM transaction with a new endpoint

image

APM transaction with an old endpoint

Screen.Recording.2024-12-02.at.16.10.51.mov

  • Improves type definitions for different model types

Checklist

@darnautov darnautov self-assigned this Nov 20, 2024
@peteharverson peteharverson changed the title [ML] Trainied models table fixes [ML] Trained models table fixes Nov 21, 2024
@darnautov darnautov changed the title [ML] Trained models table fixes [ML] Trained Models: Optimize trained models Kibana API Nov 28, 2024
@darnautov darnautov added release_note:enhancement :ml Feature:Data Frame Analytics ML data frame analytics features v9.0.0 Feature:3rd Party Models ML 3rd party models Team:ML Team label for ML (also use :ml) backport:version Backport to applied version labels v8.18.0 labels Dec 2, 2024
@darnautov darnautov marked this pull request as ready for review December 2, 2024 14:45
);
});

it('returns models without pipeline in case user does not have required permission', async () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Just checking - is this the expected result when opening the map in the expanded row for a non-DFA model as a viewer user. Is there any way we could catch the error and show e.g. a callout in the tab rather than the error toasts?

Screenshot 2024-12-04 at 14 13 13

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This error comes from another endpoint /data_frame/analytics/map/{analyticsId}. I reckon it should be fixed separately.

Copy link
Contributor

Choose a reason for hiding this comment

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

Agreed - this behavior isn't introduced by this PR and happens on main. Can you create a separate issue for it please.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor

@peteharverson peteharverson left a comment

Choose a reason for hiding this comment

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

Tested and LGTM. A great optimization!

Copy link
Member

@jgowdyelastic jgowdyelastic left a comment

Choose a reason for hiding this comment

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

Added nit pick comment, but generally LGTM

Comment on lines 156 to 161
const { endpoints } = await esClient.transport.request<{
endpoints: InferenceAPIConfigResponse[];
}>({
method: 'GET',
path: `/_inference/_all`,
});
Copy link
Member

Choose a reason for hiding this comment

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

I appreciate this is relocated code, but it might be a good opportunity to remove the use of transport.

Suggested change
const { endpoints } = await esClient.transport.request<{
endpoints: InferenceAPIConfigResponse[];
}>({
method: 'GET',
path: `/_inference/_all`,
});
const { endpoints } = await esClient.inference.get({
inference_id: '_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.

Done in 307bb40

@darnautov darnautov enabled auto-merge (squash) December 4, 2024 16:17
@darnautov darnautov merged commit e067fa2 into elastic:main Dec 4, 2024
8 checks passed
@kibanamachine
Copy link
Contributor

Starting backport for target branches: 8.17, 8.x

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

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
ml 2146 2147 +1

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
ml 4.7MB 4.7MB -1.3KB

Page load bundle

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

id before after diff
ml 76.5KB 76.5KB +94.0B
Unknown metric groups

ESLint disabled line counts

id before after diff
ml 569 567 -2

Total ESLint disabled count

id before after diff
ml 572 570 -2

History

cc @darnautov

@kibanamachine
Copy link
Contributor

💔 Backport failed

The pull request could not be backported due to the following error:
Git clone failed with exit code: 128

Manual backport

To create the backport manually run:

node scripts/backport --pr 200977

Questions ?

Please refer to the Backport tool documentation

@darnautov darnautov deleted the ml-191939-fix-trained-models-init branch December 5, 2024 09:45
darnautov added a commit to darnautov/kibana that referenced this pull request Dec 5, 2024
## Summary

Closes elastic#191939
Closes elastic#175220

Adds various optimizations for the Trained Models page:

---

- Creates a new Kibana `/trained_models_list` endpoint responsible for
fetching complete data for the Trained Model UI page, including
pipelines, indices and stats.

Before the Trained Models page required 3 endpoints. The new
`trained_models_list` replaces them, reducing the overall latency.

<img width="715" alt="Screenshot 2024-12-02 at 16 18 32"
src="https://github.com/user-attachments/assets/34bebbdc-ae80-4e08-8512-199c57cb5b54">

---

- Optimized fetching of pipelines, indices and stats, reducing the
number of API calls to ES

Several issues with the old endpoint stemmed from the with_indices flag.
This flag triggered a method designed for the Model Map feature, which
involved fetching a complete list of pipelines, iterating over each
model, retrieving index settings multiple times, and obtaining both
index content and a full list of transforms.

The new endpoint solves these issues by fetching only the necessary
information for the Trained Model page with minimal calls to
Elasticsearch.

#### APM transaction with a new endpoint
<img width="1822" alt="image"
src="https://github.com/user-attachments/assets/55e4a5f0-e571-46a2-b7ad-5b5a6fc44ceb">

#### APM transaction with an old endpoint

https://github.com/user-attachments/assets/c9d62ddb-5e13-4ac1-9cbf-d685fbed7808

---

- Improves type definitions for different model types

### Checklist

- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios

(cherry picked from commit e067fa2)
darnautov added a commit to darnautov/kibana that referenced this pull request Dec 5, 2024
## Summary

Closes elastic#191939
Closes elastic#175220

Adds various optimizations for the Trained Models page:

---

- Creates a new Kibana `/trained_models_list` endpoint responsible for
fetching complete data for the Trained Model UI page, including
pipelines, indices and stats.

Before the Trained Models page required 3 endpoints. The new
`trained_models_list` replaces them, reducing the overall latency.

<img width="715" alt="Screenshot 2024-12-02 at 16 18 32"
src="https://github.com/user-attachments/assets/34bebbdc-ae80-4e08-8512-199c57cb5b54">

---

- Optimized fetching of pipelines, indices and stats, reducing the
number of API calls to ES

Several issues with the old endpoint stemmed from the with_indices flag.
This flag triggered a method designed for the Model Map feature, which
involved fetching a complete list of pipelines, iterating over each
model, retrieving index settings multiple times, and obtaining both
index content and a full list of transforms.

The new endpoint solves these issues by fetching only the necessary
information for the Trained Model page with minimal calls to
Elasticsearch.

#### APM transaction with a new endpoint
<img width="1822" alt="image"
src="https://github.com/user-attachments/assets/55e4a5f0-e571-46a2-b7ad-5b5a6fc44ceb">

#### APM transaction with an old endpoint

https://github.com/user-attachments/assets/c9d62ddb-5e13-4ac1-9cbf-d685fbed7808

---

- Improves type definitions for different model types

### Checklist

- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios

(cherry picked from commit e067fa2)

# Conflicts:
#	x-pack/plugins/ml/server/shared_services/shared_services.ts
@darnautov
Copy link
Contributor Author

💚 All backports created successfully

Status Branch Result
8.x
8.17

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

Questions ?

Please refer to the Backport tool documentation

darnautov added a commit that referenced this pull request Dec 5, 2024
… (#203087)

# Backport

This will backport the following commits from `main` to `8.x`:
- [[ML] Trained Models: Optimize trained models Kibana API
(#200977)](#200977)

<!--- Backport version: 8.9.8 -->

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

<!--BACKPORT [{"author":{"name":"Dima
Arnautov","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-12-04T18:50:18Z","message":"[ML]
Trained Models: Optimize trained models Kibana API (#200977)\n\n##
Summary\r\n\r\nCloses #191939 \r\nCloses
https://github.com/elastic/kibana/issues/175220\r\n\r\nAdds various
optimizations for the Trained Models page:\r\n\r\n---\r\n\r\n- Creates a
new Kibana `/trained_models_list` endpoint responsible for\r\nfetching
complete data for the Trained Model UI page, including\r\npipelines,
indices and stats.\r\n\r\nBefore the Trained Models page required 3
endpoints. The new\r\n`trained_models_list` replaces them, reducing the
overall latency.\r\n\r\n<img width=\"715\" alt=\"Screenshot 2024-12-02
at 16 18
32\"\r\nsrc=\"https://github.com/user-attachments/assets/34bebbdc-ae80-4e08-8512-199c57cb5b54\">\r\n\r\n\r\n---\r\n\r\n-
Optimized fetching of pipelines, indices and stats, reducing
the\r\nnumber of API calls to ES\r\n\r\nSeveral issues with the old
endpoint stemmed from the with_indices flag.\r\nThis flag triggered a
method designed for the Model Map feature, which\r\ninvolved fetching a
complete list of pipelines, iterating over each\r\nmodel, retrieving
index settings multiple times, and obtaining both\r\nindex content and a
full list of transforms.\r\n\r\nThe new endpoint solves these issues by
fetching only the necessary\r\ninformation for the Trained Model page
with minimal calls to\r\nElasticsearch.\r\n\r\n#### APM transaction with
a new endpoint \r\n<img width=\"1822\"
alt=\"image\"\r\nsrc=\"https://github.com/user-attachments/assets/55e4a5f0-e571-46a2-b7ad-5b5a6fc44ceb\">\r\n\r\n####
APM transaction with an old
endpoint\r\n\r\n\r\nhttps://github.com/user-attachments/assets/c9d62ddb-5e13-4ac1-9cbf-d685fbed7808\r\n\r\n---\r\n\r\n-
Improves type definitions for different model types\r\n\r\n###
Checklist\r\n\r\n- [x] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common
scenarios","sha":"e067fa239de670123c4f7d6aaba3d6001796babe","branchLabelMapping":{"^v9.0.0$":"main","^v8.18.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:enhancement",":ml","Feature:Data
Frame Analytics","v9.0.0","Feature:3rd Party
Models","Team:ML","backport:version","v8.17.0","v8.18.0"],"number":200977,"url":"https://github.com/elastic/kibana/pull/200977","mergeCommit":{"message":"[ML]
Trained Models: Optimize trained models Kibana API (#200977)\n\n##
Summary\r\n\r\nCloses #191939 \r\nCloses
https://github.com/elastic/kibana/issues/175220\r\n\r\nAdds various
optimizations for the Trained Models page:\r\n\r\n---\r\n\r\n- Creates a
new Kibana `/trained_models_list` endpoint responsible for\r\nfetching
complete data for the Trained Model UI page, including\r\npipelines,
indices and stats.\r\n\r\nBefore the Trained Models page required 3
endpoints. The new\r\n`trained_models_list` replaces them, reducing the
overall latency.\r\n\r\n<img width=\"715\" alt=\"Screenshot 2024-12-02
at 16 18
32\"\r\nsrc=\"https://github.com/user-attachments/assets/34bebbdc-ae80-4e08-8512-199c57cb5b54\">\r\n\r\n\r\n---\r\n\r\n-
Optimized fetching of pipelines, indices and stats, reducing
the\r\nnumber of API calls to ES\r\n\r\nSeveral issues with the old
endpoint stemmed from the with_indices flag.\r\nThis flag triggered a
method designed for the Model Map feature, which\r\ninvolved fetching a
complete list of pipelines, iterating over each\r\nmodel, retrieving
index settings multiple times, and obtaining both\r\nindex content and a
full list of transforms.\r\n\r\nThe new endpoint solves these issues by
fetching only the necessary\r\ninformation for the Trained Model page
with minimal calls to\r\nElasticsearch.\r\n\r\n#### APM transaction with
a new endpoint \r\n<img width=\"1822\"
alt=\"image\"\r\nsrc=\"https://github.com/user-attachments/assets/55e4a5f0-e571-46a2-b7ad-5b5a6fc44ceb\">\r\n\r\n####
APM transaction with an old
endpoint\r\n\r\n\r\nhttps://github.com/user-attachments/assets/c9d62ddb-5e13-4ac1-9cbf-d685fbed7808\r\n\r\n---\r\n\r\n-
Improves type definitions for different model types\r\n\r\n###
Checklist\r\n\r\n- [x] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common
scenarios","sha":"e067fa239de670123c4f7d6aaba3d6001796babe"}},"sourceBranch":"main","suggestedTargetBranches":["8.17","8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","labelRegex":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/200977","number":200977,"mergeCommit":{"message":"[ML]
Trained Models: Optimize trained models Kibana API (#200977)\n\n##
Summary\r\n\r\nCloses #191939 \r\nCloses
https://github.com/elastic/kibana/issues/175220\r\n\r\nAdds various
optimizations for the Trained Models page:\r\n\r\n---\r\n\r\n- Creates a
new Kibana `/trained_models_list` endpoint responsible for\r\nfetching
complete data for the Trained Model UI page, including\r\npipelines,
indices and stats.\r\n\r\nBefore the Trained Models page required 3
endpoints. The new\r\n`trained_models_list` replaces them, reducing the
overall latency.\r\n\r\n<img width=\"715\" alt=\"Screenshot 2024-12-02
at 16 18
32\"\r\nsrc=\"https://github.com/user-attachments/assets/34bebbdc-ae80-4e08-8512-199c57cb5b54\">\r\n\r\n\r\n---\r\n\r\n-
Optimized fetching of pipelines, indices and stats, reducing
the\r\nnumber of API calls to ES\r\n\r\nSeveral issues with the old
endpoint stemmed from the with_indices flag.\r\nThis flag triggered a
method designed for the Model Map feature, which\r\ninvolved fetching a
complete list of pipelines, iterating over each\r\nmodel, retrieving
index settings multiple times, and obtaining both\r\nindex content and a
full list of transforms.\r\n\r\nThe new endpoint solves these issues by
fetching only the necessary\r\ninformation for the Trained Model page
with minimal calls to\r\nElasticsearch.\r\n\r\n#### APM transaction with
a new endpoint \r\n<img width=\"1822\"
alt=\"image\"\r\nsrc=\"https://github.com/user-attachments/assets/55e4a5f0-e571-46a2-b7ad-5b5a6fc44ceb\">\r\n\r\n####
APM transaction with an old
endpoint\r\n\r\n\r\nhttps://github.com/user-attachments/assets/c9d62ddb-5e13-4ac1-9cbf-d685fbed7808\r\n\r\n---\r\n\r\n-
Improves type definitions for different model types\r\n\r\n###
Checklist\r\n\r\n- [x] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common
scenarios","sha":"e067fa239de670123c4f7d6aaba3d6001796babe"}},{"branch":"8.17","label":"v8.17.0","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.x","label":"v8.18.0","labelRegex":"^v8.18.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->
darnautov added a commit that referenced this pull request Dec 5, 2024
…) (#203088)

# Backport

This will backport the following commits from `main` to `8.17`:
- [[ML] Trained Models: Optimize trained models Kibana API
(#200977)](#200977)

<!--- Backport version: 8.9.8 -->

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

<!--BACKPORT [{"author":{"name":"Dima
Arnautov","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-12-04T18:50:18Z","message":"[ML]
Trained Models: Optimize trained models Kibana API (#200977)\n\n##
Summary\r\n\r\nCloses #191939 \r\nCloses
https://github.com/elastic/kibana/issues/175220\r\n\r\nAdds various
optimizations for the Trained Models page:\r\n\r\n---\r\n\r\n- Creates a
new Kibana `/trained_models_list` endpoint responsible for\r\nfetching
complete data for the Trained Model UI page, including\r\npipelines,
indices and stats.\r\n\r\nBefore the Trained Models page required 3
endpoints. The new\r\n`trained_models_list` replaces them, reducing the
overall latency.\r\n\r\n<img width=\"715\" alt=\"Screenshot 2024-12-02
at 16 18
32\"\r\nsrc=\"https://github.com/user-attachments/assets/34bebbdc-ae80-4e08-8512-199c57cb5b54\">\r\n\r\n\r\n---\r\n\r\n-
Optimized fetching of pipelines, indices and stats, reducing
the\r\nnumber of API calls to ES\r\n\r\nSeveral issues with the old
endpoint stemmed from the with_indices flag.\r\nThis flag triggered a
method designed for the Model Map feature, which\r\ninvolved fetching a
complete list of pipelines, iterating over each\r\nmodel, retrieving
index settings multiple times, and obtaining both\r\nindex content and a
full list of transforms.\r\n\r\nThe new endpoint solves these issues by
fetching only the necessary\r\ninformation for the Trained Model page
with minimal calls to\r\nElasticsearch.\r\n\r\n#### APM transaction with
a new endpoint \r\n<img width=\"1822\"
alt=\"image\"\r\nsrc=\"https://github.com/user-attachments/assets/55e4a5f0-e571-46a2-b7ad-5b5a6fc44ceb\">\r\n\r\n####
APM transaction with an old
endpoint\r\n\r\n\r\nhttps://github.com/user-attachments/assets/c9d62ddb-5e13-4ac1-9cbf-d685fbed7808\r\n\r\n---\r\n\r\n-
Improves type definitions for different model types\r\n\r\n###
Checklist\r\n\r\n- [x] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common
scenarios","sha":"e067fa239de670123c4f7d6aaba3d6001796babe","branchLabelMapping":{"^v9.0.0$":"main","^v8.18.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:enhancement",":ml","Feature:Data
Frame Analytics","v9.0.0","Feature:3rd Party
Models","Team:ML","backport:version","v8.17.0","v8.18.0"],"number":200977,"url":"https://github.com/elastic/kibana/pull/200977","mergeCommit":{"message":"[ML]
Trained Models: Optimize trained models Kibana API (#200977)\n\n##
Summary\r\n\r\nCloses #191939 \r\nCloses
https://github.com/elastic/kibana/issues/175220\r\n\r\nAdds various
optimizations for the Trained Models page:\r\n\r\n---\r\n\r\n- Creates a
new Kibana `/trained_models_list` endpoint responsible for\r\nfetching
complete data for the Trained Model UI page, including\r\npipelines,
indices and stats.\r\n\r\nBefore the Trained Models page required 3
endpoints. The new\r\n`trained_models_list` replaces them, reducing the
overall latency.\r\n\r\n<img width=\"715\" alt=\"Screenshot 2024-12-02
at 16 18
32\"\r\nsrc=\"https://github.com/user-attachments/assets/34bebbdc-ae80-4e08-8512-199c57cb5b54\">\r\n\r\n\r\n---\r\n\r\n-
Optimized fetching of pipelines, indices and stats, reducing
the\r\nnumber of API calls to ES\r\n\r\nSeveral issues with the old
endpoint stemmed from the with_indices flag.\r\nThis flag triggered a
method designed for the Model Map feature, which\r\ninvolved fetching a
complete list of pipelines, iterating over each\r\nmodel, retrieving
index settings multiple times, and obtaining both\r\nindex content and a
full list of transforms.\r\n\r\nThe new endpoint solves these issues by
fetching only the necessary\r\ninformation for the Trained Model page
with minimal calls to\r\nElasticsearch.\r\n\r\n#### APM transaction with
a new endpoint \r\n<img width=\"1822\"
alt=\"image\"\r\nsrc=\"https://github.com/user-attachments/assets/55e4a5f0-e571-46a2-b7ad-5b5a6fc44ceb\">\r\n\r\n####
APM transaction with an old
endpoint\r\n\r\n\r\nhttps://github.com/user-attachments/assets/c9d62ddb-5e13-4ac1-9cbf-d685fbed7808\r\n\r\n---\r\n\r\n-
Improves type definitions for different model types\r\n\r\n###
Checklist\r\n\r\n- [x] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common
scenarios","sha":"e067fa239de670123c4f7d6aaba3d6001796babe"}},"sourceBranch":"main","suggestedTargetBranches":["8.17","8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","labelRegex":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/200977","number":200977,"mergeCommit":{"message":"[ML]
Trained Models: Optimize trained models Kibana API (#200977)\n\n##
Summary\r\n\r\nCloses #191939 \r\nCloses
https://github.com/elastic/kibana/issues/175220\r\n\r\nAdds various
optimizations for the Trained Models page:\r\n\r\n---\r\n\r\n- Creates a
new Kibana `/trained_models_list` endpoint responsible for\r\nfetching
complete data for the Trained Model UI page, including\r\npipelines,
indices and stats.\r\n\r\nBefore the Trained Models page required 3
endpoints. The new\r\n`trained_models_list` replaces them, reducing the
overall latency.\r\n\r\n<img width=\"715\" alt=\"Screenshot 2024-12-02
at 16 18
32\"\r\nsrc=\"https://github.com/user-attachments/assets/34bebbdc-ae80-4e08-8512-199c57cb5b54\">\r\n\r\n\r\n---\r\n\r\n-
Optimized fetching of pipelines, indices and stats, reducing
the\r\nnumber of API calls to ES\r\n\r\nSeveral issues with the old
endpoint stemmed from the with_indices flag.\r\nThis flag triggered a
method designed for the Model Map feature, which\r\ninvolved fetching a
complete list of pipelines, iterating over each\r\nmodel, retrieving
index settings multiple times, and obtaining both\r\nindex content and a
full list of transforms.\r\n\r\nThe new endpoint solves these issues by
fetching only the necessary\r\ninformation for the Trained Model page
with minimal calls to\r\nElasticsearch.\r\n\r\n#### APM transaction with
a new endpoint \r\n<img width=\"1822\"
alt=\"image\"\r\nsrc=\"https://github.com/user-attachments/assets/55e4a5f0-e571-46a2-b7ad-5b5a6fc44ceb\">\r\n\r\n####
APM transaction with an old
endpoint\r\n\r\n\r\nhttps://github.com/user-attachments/assets/c9d62ddb-5e13-4ac1-9cbf-d685fbed7808\r\n\r\n---\r\n\r\n-
Improves type definitions for different model types\r\n\r\n###
Checklist\r\n\r\n- [x] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common
scenarios","sha":"e067fa239de670123c4f7d6aaba3d6001796babe"}},{"branch":"8.17","label":"v8.17.0","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.x","label":"v8.18.0","labelRegex":"^v8.18.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

---------

Co-authored-by: kibanamachine <[email protected]>
SoniaSanzV pushed a commit to SoniaSanzV/kibana that referenced this pull request Dec 9, 2024
## Summary

Closes elastic#191939 
Closes elastic#175220

Adds various optimizations for the Trained Models page:

---

- Creates a new Kibana `/trained_models_list` endpoint responsible for
fetching complete data for the Trained Model UI page, including
pipelines, indices and stats.

Before the Trained Models page required 3 endpoints. The new
`trained_models_list` replaces them, reducing the overall latency.

<img width="715" alt="Screenshot 2024-12-02 at 16 18 32"
src="https://github.com/user-attachments/assets/34bebbdc-ae80-4e08-8512-199c57cb5b54">


---

- Optimized fetching of pipelines, indices and stats, reducing the
number of API calls to ES

Several issues with the old endpoint stemmed from the with_indices flag.
This flag triggered a method designed for the Model Map feature, which
involved fetching a complete list of pipelines, iterating over each
model, retrieving index settings multiple times, and obtaining both
index content and a full list of transforms.

The new endpoint solves these issues by fetching only the necessary
information for the Trained Model page with minimal calls to
Elasticsearch.

#### APM transaction with a new endpoint 
<img width="1822" alt="image"
src="https://github.com/user-attachments/assets/55e4a5f0-e571-46a2-b7ad-5b5a6fc44ceb">

#### APM transaction with an old endpoint


https://github.com/user-attachments/assets/c9d62ddb-5e13-4ac1-9cbf-d685fbed7808

---

- Improves type definitions for different model types

### Checklist

- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
SoniaSanzV pushed a commit to SoniaSanzV/kibana that referenced this pull request Dec 9, 2024
## Summary

Closes elastic#191939 
Closes elastic#175220

Adds various optimizations for the Trained Models page:

---

- Creates a new Kibana `/trained_models_list` endpoint responsible for
fetching complete data for the Trained Model UI page, including
pipelines, indices and stats.

Before the Trained Models page required 3 endpoints. The new
`trained_models_list` replaces them, reducing the overall latency.

<img width="715" alt="Screenshot 2024-12-02 at 16 18 32"
src="https://github.com/user-attachments/assets/34bebbdc-ae80-4e08-8512-199c57cb5b54">


---

- Optimized fetching of pipelines, indices and stats, reducing the
number of API calls to ES

Several issues with the old endpoint stemmed from the with_indices flag.
This flag triggered a method designed for the Model Map feature, which
involved fetching a complete list of pipelines, iterating over each
model, retrieving index settings multiple times, and obtaining both
index content and a full list of transforms.

The new endpoint solves these issues by fetching only the necessary
information for the Trained Model page with minimal calls to
Elasticsearch.

#### APM transaction with a new endpoint 
<img width="1822" alt="image"
src="https://github.com/user-attachments/assets/55e4a5f0-e571-46a2-b7ad-5b5a6fc44ceb">

#### APM transaction with an old endpoint


https://github.com/user-attachments/assets/c9d62ddb-5e13-4ac1-9cbf-d685fbed7808

---

- Improves type definitions for different model types

### Checklist

- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
CAWilson94 pushed a commit to CAWilson94/kibana that referenced this pull request Dec 9, 2024
## Summary

Closes elastic#191939 
Closes elastic#175220

Adds various optimizations for the Trained Models page:

---

- Creates a new Kibana `/trained_models_list` endpoint responsible for
fetching complete data for the Trained Model UI page, including
pipelines, indices and stats.

Before the Trained Models page required 3 endpoints. The new
`trained_models_list` replaces them, reducing the overall latency.

<img width="715" alt="Screenshot 2024-12-02 at 16 18 32"
src="https://github.com/user-attachments/assets/34bebbdc-ae80-4e08-8512-199c57cb5b54">


---

- Optimized fetching of pipelines, indices and stats, reducing the
number of API calls to ES

Several issues with the old endpoint stemmed from the with_indices flag.
This flag triggered a method designed for the Model Map feature, which
involved fetching a complete list of pipelines, iterating over each
model, retrieving index settings multiple times, and obtaining both
index content and a full list of transforms.

The new endpoint solves these issues by fetching only the necessary
information for the Trained Model page with minimal calls to
Elasticsearch.

#### APM transaction with a new endpoint 
<img width="1822" alt="image"
src="https://github.com/user-attachments/assets/55e4a5f0-e571-46a2-b7ad-5b5a6fc44ceb">

#### APM transaction with an old endpoint


https://github.com/user-attachments/assets/c9d62ddb-5e13-4ac1-9cbf-d685fbed7808

---

- Improves type definitions for different model types

### Checklist

- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
Samiul-TheSoccerFan pushed a commit to Samiul-TheSoccerFan/kibana that referenced this pull request Dec 10, 2024
## Summary

Closes elastic#191939 
Closes elastic#175220

Adds various optimizations for the Trained Models page:

---

- Creates a new Kibana `/trained_models_list` endpoint responsible for
fetching complete data for the Trained Model UI page, including
pipelines, indices and stats.

Before the Trained Models page required 3 endpoints. The new
`trained_models_list` replaces them, reducing the overall latency.

<img width="715" alt="Screenshot 2024-12-02 at 16 18 32"
src="https://github.com/user-attachments/assets/34bebbdc-ae80-4e08-8512-199c57cb5b54">


---

- Optimized fetching of pipelines, indices and stats, reducing the
number of API calls to ES

Several issues with the old endpoint stemmed from the with_indices flag.
This flag triggered a method designed for the Model Map feature, which
involved fetching a complete list of pipelines, iterating over each
model, retrieving index settings multiple times, and obtaining both
index content and a full list of transforms.

The new endpoint solves these issues by fetching only the necessary
information for the Trained Model page with minimal calls to
Elasticsearch.

#### APM transaction with a new endpoint 
<img width="1822" alt="image"
src="https://github.com/user-attachments/assets/55e4a5f0-e571-46a2-b7ad-5b5a6fc44ceb">

#### APM transaction with an old endpoint


https://github.com/user-attachments/assets/c9d62ddb-5e13-4ac1-9cbf-d685fbed7808

---

- Improves type definitions for different model types

### Checklist

- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
CAWilson94 pushed a commit to CAWilson94/kibana that referenced this pull request Dec 12, 2024
## Summary

Closes elastic#191939 
Closes elastic#175220

Adds various optimizations for the Trained Models page:

---

- Creates a new Kibana `/trained_models_list` endpoint responsible for
fetching complete data for the Trained Model UI page, including
pipelines, indices and stats.

Before the Trained Models page required 3 endpoints. The new
`trained_models_list` replaces them, reducing the overall latency.

<img width="715" alt="Screenshot 2024-12-02 at 16 18 32"
src="https://github.com/user-attachments/assets/34bebbdc-ae80-4e08-8512-199c57cb5b54">


---

- Optimized fetching of pipelines, indices and stats, reducing the
number of API calls to ES

Several issues with the old endpoint stemmed from the with_indices flag.
This flag triggered a method designed for the Model Map feature, which
involved fetching a complete list of pipelines, iterating over each
model, retrieving index settings multiple times, and obtaining both
index content and a full list of transforms.

The new endpoint solves these issues by fetching only the necessary
information for the Trained Model page with minimal calls to
Elasticsearch.

#### APM transaction with a new endpoint 
<img width="1822" alt="image"
src="https://github.com/user-attachments/assets/55e4a5f0-e571-46a2-b7ad-5b5a6fc44ceb">

#### APM transaction with an old endpoint


https://github.com/user-attachments/assets/c9d62ddb-5e13-4ac1-9cbf-d685fbed7808

---

- Improves type definitions for different model types

### Checklist

- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:version Backport to applied version labels Feature:Data Frame Analytics ML data frame analytics features Feature:3rd Party Models ML 3rd party models :ml release_note:enhancement Team:ML Team label for ML (also use :ml) v8.17.0 v8.18.0 v9.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[ML] Optimize Kibana /trained_models endpoint [ML] Optimize Trained Models list fetching
6 participants