[ML] Fix new job wizard with multiple indices (#64567)
Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
This commit is contained in:
parent
dfb4c331a0
commit
b5fb78bfce
2
x-pack/plugins/ml/common/util/job_utils.d.ts
vendored
2
x-pack/plugins/ml/common/util/job_utils.d.ts
vendored
|
@ -52,3 +52,5 @@ export function getLatestDataOrBucketTimestamp(
|
|||
): number;
|
||||
|
||||
export function prefixDatafeedId(datafeedId: string, prefix: string): string;
|
||||
|
||||
export function splitIndexPatternNames(indexPatternName: string): string[];
|
||||
|
|
|
@ -588,3 +588,9 @@ export function processCreatedBy(customSettings) {
|
|||
delete customSettings.created_by;
|
||||
}
|
||||
}
|
||||
|
||||
export function splitIndexPatternNames(indexPatternName) {
|
||||
return indexPatternName.includes(',')
|
||||
? indexPatternName.split(',').map(i => i.trim())
|
||||
: [indexPatternName];
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
import { IndexPatternTitle } from '../../../../../../../common/types/kibana';
|
||||
import { Field, Aggregation, EVENT_RATE_FIELD_ID } from '../../../../../../../common/types/fields';
|
||||
import { Job, Datafeed, Detector } from '../../../../../../../common/types/anomaly_detection_jobs';
|
||||
import { splitIndexPatternNames } from '../../../../../../../common/util/job_utils';
|
||||
|
||||
export function createEmptyJob(): Job {
|
||||
return {
|
||||
|
@ -28,7 +29,7 @@ export function createEmptyDatafeed(indexPatternTitle: IndexPatternTitle): Dataf
|
|||
return {
|
||||
datafeed_id: '',
|
||||
job_id: '',
|
||||
indices: [indexPatternTitle],
|
||||
indices: splitIndexPatternNames(indexPatternTitle),
|
||||
query: {},
|
||||
};
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@ function getWizardUrlFromCloningJob(job: CombinedJob) {
|
|||
break;
|
||||
}
|
||||
|
||||
const indexPatternId = getIndexPatternIdFromName(job.datafeed_config.indices[0]);
|
||||
const indexPatternId = getIndexPatternIdFromName(job.datafeed_config.indices.join());
|
||||
|
||||
return `jobs/new_job/${page}?index=${indexPatternId}&_g=()`;
|
||||
}
|
||||
|
|
|
@ -29,7 +29,11 @@ import {
|
|||
JobSpecificOverride,
|
||||
isGeneralJobOverride,
|
||||
} from '../../../common/types/modules';
|
||||
import { getLatestDataOrBucketTimestamp, prefixDatafeedId } from '../../../common/util/job_utils';
|
||||
import {
|
||||
getLatestDataOrBucketTimestamp,
|
||||
prefixDatafeedId,
|
||||
splitIndexPatternNames,
|
||||
} from '../../../common/util/job_utils';
|
||||
import { mlLog } from '../../client/log';
|
||||
import { calculateModelMemoryLimitProvider } from '../calculate_model_memory_limit';
|
||||
import { fieldsServiceProvider } from '../fields_service';
|
||||
|
@ -828,9 +832,7 @@ export class DataRecognizer {
|
|||
updateDatafeedIndices(moduleConfig: Module) {
|
||||
// if the supplied index pattern contains a comma, split into multiple indices and
|
||||
// add each one to the datafeed
|
||||
const indexPatternNames = this.indexPatternName.includes(',')
|
||||
? this.indexPatternName.split(',').map(i => i.trim())
|
||||
: [this.indexPatternName];
|
||||
const indexPatternNames = splitIndexPatternNames(this.indexPatternName);
|
||||
|
||||
moduleConfig.datafeeds.forEach(df => {
|
||||
const newIndices: string[] = [];
|
||||
|
|
Loading…
Reference in a new issue