Skip to content

Commit

Permalink
[data views / hasData] Check resolve cluster instead of resolve index…
Browse files Browse the repository at this point in the history
… for improved performance (#191566)

## Summary

The `resolve/cluster` api is MUCH more efficient for determining whether
there are user created indices than the `resolve/index` api. The
`resolve/index` api returns the FULL list of indices which can be very
large.

Unfortunately the `resolve/cluster` api isn't available on serverless so
we rely on the existing `hasESData` behavior when its not available.

Closes #190554

Created elastic/elasticsearch#112307 in hopes
of getting an api thats performant in serverless and classic
environments. Additional detail - `logs-enterprise_search.api-default`
and `logs-enterprise_search.audit-default` should be ignored for the
purposes of user created data.

---

Testing - verify the loading data flows display as appropriate for
discover and data view management. Create and delete indices.

## Release notes

In deployments with thousands of indices and index aliases, browser
calls to `/internal/index-pattern-management/resolve_index` can be very
slow (more than 10s). Its been replaced with
`/internal/data_views/has_es_data` which is much faster (<1s).

---------

Co-authored-by: Davis McPhee <[email protected]>
  • Loading branch information
mattkime and davismcphee authored Sep 4, 2024
1 parent 30b2333 commit 86cfcab
Show file tree
Hide file tree
Showing 5 changed files with 350 additions and 216 deletions.
7 changes: 5 additions & 2 deletions src/plugins/data_views/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,11 @@ export class DataViewsPublicPlugin
{
private readonly hasData = new HasData();
private rollupsEnabled: boolean = false;
private readonly callResolveCluster: boolean;

constructor(private readonly initializerContext: PluginInitializerContext) {}
constructor(private readonly initializerContext: PluginInitializerContext) {
this.callResolveCluster = initializerContext.env.packageInfo.buildFlavor === 'traditional';
}

public setup(
core: CoreSetup<DataViewsPublicStartDependencies, DataViewsPublicPluginStart>,
Expand Down Expand Up @@ -83,7 +86,7 @@ export class DataViewsPublicPlugin
const config = this.initializerContext.config.get<ClientConfigType>();

return new DataViewsServicePublic({
hasData: this.hasData.start(core),
hasData: this.hasData.start(core, this.callResolveCluster),
uiSettings: new UiSettingsPublicToCommon(uiSettings),
savedObjectsClient: new ContentMagementWrapper(contentManagement.client),
apiClient: new DataViewsApiClient(http, async () => {
Expand Down
Loading

0 comments on commit 86cfcab

Please sign in to comment.