From 404bba221265030cedccdf6056b36e7f3b246be9 Mon Sep 17 00:00:00 2001 From: Dima Arnautov Date: Wed, 13 May 2020 14:33:58 +0200 Subject: [PATCH] [ML] use MlJobAggregation --- x-pack/plugins/ml/common/constants/aggregation_types.ts | 2 ++ x-pack/plugins/ml/common/util/job_utils.ts | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/x-pack/plugins/ml/common/constants/aggregation_types.ts b/x-pack/plugins/ml/common/constants/aggregation_types.ts index 2926b3cb3d82a..2862d2eb84f7a 100644 --- a/x-pack/plugins/ml/common/constants/aggregation_types.ts +++ b/x-pack/plugins/ml/common/constants/aggregation_types.ts @@ -4,6 +4,8 @@ * you may not use this file except in compliance with the Elastic License. */ +export type MlJobAggregation = keyof Record; + export enum ML_JOB_AGGREGATION { // count COUNT = 'count', diff --git a/x-pack/plugins/ml/common/util/job_utils.ts b/x-pack/plugins/ml/common/util/job_utils.ts index 9b36975290496..74674769ad278 100644 --- a/x-pack/plugins/ml/common/util/job_utils.ts +++ b/x-pack/plugins/ml/common/util/job_utils.ts @@ -17,6 +17,7 @@ import { CombinedJob, CustomSettings, Datafeed, JobId, Job } from '../types/anom import { EntityField } from './anomaly_utils'; import { MlServerLimits } from '../types/ml_server_info'; import { JobValidationMessage, JobValidationMessageId } from '../constants/messages'; +import { MlJobAggregation } from '../constants/aggregation_types'; export interface ValidationResults { valid: boolean; @@ -208,7 +209,7 @@ export function isJobVersionGte(job: CombinedJob, version: string): boolean { // for querying metric data. Returns null if there is no suitable ES aggregation. // Note that the 'function' field in a record contains what the user entered e.g. 'high_count', // whereas the 'function_description' field holds an ML-built display hint for function e.g. 'count'. -export function mlFunctionToESAggregation(functionName: string): string | null { +export function mlFunctionToESAggregation(functionName: MlJobAggregation | string): string | null { if ( functionName === 'mean' || functionName === 'high_mean' ||