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] Fix for errors when loading data views which are missing index #147916

Conversation

jgowdyelastic
Copy link
Member

@jgowdyelastic jgowdyelastic commented Dec 21, 2022

Fixes #147886 by manually checking whether the index behind a data view actually exists before fetching it. This fixes the issue with the data view service which displays a toast for every data view which it cannot load the fields for.

This fix has the potential to increase the amount of requests to es by quite a large amount.

For example, if a user has 100 data views, 80 of which have existing indices.
1 request is made to load all data view ids and titles
100 requests are made to fetch the fields for each index. 80 succeed.
80 requests are then made to fetch each data view.

In 8.0 this behaviour has been changed. We no longer request all of the data views up front on page load.

@peteharverson peteharverson changed the title [ML] Fix for errors when loading data veiws which are missing index [ML] Fix for errors when loading data views which are missing index Dec 21, 2022
@@ -18,7 +18,25 @@ let indexPatternsContract: DataViewsContract | null = null;
export async function loadIndexPatterns(indexPatterns: DataViewsContract) {
indexPatternsContract = indexPatterns;
const dataViewsContract = getDataViews();
indexPatternCache = await dataViewsContract.find('*', 10000);
const idsAndTitles = await dataViewsContract.getIdsWithTitle();
Copy link
Member Author

@jgowdyelastic jgowdyelastic Dec 21, 2022

Choose a reason for hiding this comment

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

We now load all of the ids and titles of the data views and attempt to get the fields for them to work out if the index really exists.
Once we have this filtered list of ids for data views which do exist, we can load the actual data views.

It might be better to use an exists check rather than getFieldsForIndexPattern but that will add additional dependencies to this function.

@jgowdyelastic jgowdyelastic marked this pull request as ready for review January 9, 2023 13:03
@jgowdyelastic jgowdyelastic marked this pull request as draft January 9, 2023 13:03
@elasticmachine
Copy link
Contributor

Pinging @elastic/ml-ui (:ml)

const idsAndTitles = await dataViewsContract.getIdsWithTitle();

const dataViewsThatExist = (
await Promise.allSettled(
Copy link
Contributor

Choose a reason for hiding this comment

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

The first time I visit the Data Frame Analytics page, I still see the error toasts - one for each index pattern for which the index doesn't exist.

image

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed in 5086eff

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 latest changes and both Anomaly Detection and Data Frame Analytics pages LGTM

@kibana-ci
Copy link
Collaborator

💚 Build Succeeded

Metrics [docs]

Async chunks

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

id before after diff
ml 3.4MB 3.4MB +209.0B

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

cc @jgowdyelastic

Copy link
Contributor

@alvarezmelissa87 alvarezmelissa87 left a comment

Choose a reason for hiding this comment

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

LGTM ⚡

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants