Skip to content

Commit c408d3a

Browse files
committed
[ML] Improving trained models list performance (#237072)
Adds some filters to the request to get all index settings to reduce the amount of data fetched and reduce the load on elasticsearch for clusters with many indices. Fixes #235344 (cherry picked from commit 48f63e7)
1 parent fa769ce commit c408d3a

1 file changed

Lines changed: 19 additions & 1 deletion

File tree

x-pack/platform/plugins/shared/ml/server/models/model_management/models_provider.ts

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import {
3535
import type { CloudSetup } from '@kbn/cloud-plugin/server';
3636
import type { ElasticCuratedModelName } from '@kbn/ml-trained-models-utils';
3737
import { isDefined } from '@kbn/ml-is-defined';
38+
import { isPopulatedObject } from '@kbn/ml-is-populated-object';
3839
import { DEFAULT_TRAINED_MODELS_PAGE_SIZE } from '../../../common/constants/trained_models';
3940
import type { MlFeatures } from '../../../common/constants/app';
4041
import type {
@@ -539,7 +540,24 @@ export class ModelsProvider {
539540
let indicesSettings;
540541

541542
try {
542-
indicesSettings = await this._client.asInternalUser.indices.getSettings();
543+
indicesSettings = await this._client.asInternalUser.indices.getSettings({
544+
expand_wildcards: ['open', 'closed'],
545+
filter_path: '**.index.default_pipeline',
546+
master_timeout: '30s',
547+
});
548+
} catch (e) {
549+
// Possible that the user doesn't have permissions to view
550+
if (e.meta?.statusCode !== 403) {
551+
mlLog.error(e);
552+
}
553+
indicesSettings = {};
554+
}
555+
556+
if (isPopulatedObject(indicesSettings) === false) {
557+
return pipelineIdsToDestinationIndices;
558+
}
559+
560+
try {
543561
const hasPrivilegesResponse = await this._client.asCurrentUser.security.hasPrivileges({
544562
index: [
545563
{

0 commit comments

Comments
 (0)