Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions x-pack/plugins/ml/common/util/job_utils.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,5 @@ export function getLatestDataOrBucketTimestamp(
): number;

export function prefixDatafeedId(datafeedId: string, prefix: string): string;

export function splitIndexPatternNames(indexPatternName: string): string[];
6 changes: 6 additions & 0 deletions x-pack/plugins/ml/common/util/job_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -28,7 +29,7 @@ export function createEmptyDatafeed(indexPatternTitle: IndexPatternTitle): Dataf
return {
datafeed_id: '',
job_id: '',
indices: [indexPatternTitle],
indices: splitIndexPatternNames(indexPatternTitle),
query: {},
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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=()`;
}
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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[] = [];
Expand Down