diff --git a/x-pack/legacy/plugins/ml/public/application/jobs/new_job/common/job_creator/configs/datafeed.ts b/x-pack/legacy/plugins/ml/public/application/jobs/new_job/common/job_creator/configs/datafeed.ts index 6c7493c5e52d3..c0b9a4872c3c4 100644 --- a/x-pack/legacy/plugins/ml/public/application/jobs/new_job/common/job_creator/configs/datafeed.ts +++ b/x-pack/legacy/plugins/ml/public/application/jobs/new_job/common/job_creator/configs/datafeed.ts @@ -11,6 +11,7 @@ export type DatafeedId = string; export interface Datafeed { datafeed_id: DatafeedId; aggregations?: Aggregation; + aggs?: Aggregation; chunking_config?: ChunkingConfig; frequency?: string; indices: IndexPatternTitle[]; @@ -33,6 +34,7 @@ interface Aggregation { field: string; fixed_interval: string; }; - aggregations: Record; + aggregations?: { [key: string]: any }; + aggs?: { [key: string]: any }; }; } diff --git a/x-pack/legacy/plugins/ml/public/application/jobs/new_job/common/job_creator/job_creator.ts b/x-pack/legacy/plugins/ml/public/application/jobs/new_job/common/job_creator/job_creator.ts index 90c189c9d6197..5b33aa3556980 100644 --- a/x-pack/legacy/plugins/ml/public/application/jobs/new_job/common/job_creator/job_creator.ts +++ b/x-pack/legacy/plugins/ml/public/application/jobs/new_job/common/job_creator/job_creator.ts @@ -623,8 +623,10 @@ export class JobCreator { } this._aggregationFields = []; - if (this._datafeed_config.aggregations?.buckets !== undefined) { - collectAggs(this._datafeed_config.aggregations.buckets, this._aggregationFields); + const buckets = + this._datafeed_config.aggregations?.buckets || this._datafeed_config.aggs?.buckets; + if (buckets !== undefined) { + collectAggs(buckets, this._aggregationFields); } } } diff --git a/x-pack/legacy/plugins/ml/public/application/jobs/new_job/common/job_creator/util/general.ts b/x-pack/legacy/plugins/ml/public/application/jobs/new_job/common/job_creator/util/general.ts index e5b6212a4326e..0764e276d635e 100644 --- a/x-pack/legacy/plugins/ml/public/application/jobs/new_job/common/job_creator/util/general.ts +++ b/x-pack/legacy/plugins/ml/public/application/jobs/new_job/common/job_creator/util/general.ts @@ -325,7 +325,7 @@ export function collectAggs(o: any, aggFields: Field[]) { if (o[i] !== null && typeof o[i] === 'object') { if (i === 'aggregations' || i === 'aggs') { Object.keys(o[i]).forEach(k => { - if (k !== 'aggregations' && i !== 'aggs') { + if (k !== 'aggregations' && k !== 'aggs') { aggFields.push({ id: k, name: k,