diff --git a/x-pack/legacy/plugins/ml/public/application/datavisualizer/index_based/data_loader/data_loader.ts b/x-pack/legacy/plugins/ml/public/application/datavisualizer/index_based/data_loader/data_loader.ts index 931d767f1f1cd1..b0d8fa3d4fa885 100644 --- a/x-pack/legacy/plugins/ml/public/application/datavisualizer/index_based/data_loader/data_loader.ts +++ b/x-pack/legacy/plugins/ml/public/application/datavisualizer/index_based/data_loader/data_loader.ts @@ -76,7 +76,7 @@ export class DataLoader { fields: FieldRequestConfig[], interval?: string ): Promise { - const stats = await ml.getVisualizerFieldStats({ + const stats = await ml.getVisualizerFieldStats({ indexPatternTitle: this._indexPatternTitle, query, timeFieldName: this._indexPattern.timeFieldName, diff --git a/x-pack/legacy/plugins/ml/public/application/jobs/new_job/common/chart_loader/chart_loader.ts b/x-pack/legacy/plugins/ml/public/application/jobs/new_job/common/chart_loader/chart_loader.ts index fb2f2099bcc0a0..5e92ab67fcc794 100644 --- a/x-pack/legacy/plugins/ml/public/application/jobs/new_job/common/chart_loader/chart_loader.ts +++ b/x-pack/legacy/plugins/ml/public/application/jobs/new_job/common/chart_loader/chart_loader.ts @@ -24,10 +24,10 @@ export type LineChartData = Record; const eq = (newArgs: any[], lastArgs: any[]) => isEqual(newArgs, lastArgs); -const newJobLineChart = memoizeOne(ml.jobs.newJobLineChart, eq); -const newJobPopulationsChart = memoizeOne(ml.jobs.newJobPopulationsChart, eq); -const getEventRateData = memoizeOne(mlResultsService.getEventRateData, eq); -const getCategoryFields = memoizeOne(getCategoryFieldsOrig, eq); +const newJobLineChart = memoizeOne(ml.jobs.newJobLineChart, eq); +const newJobPopulationsChart = memoizeOne(ml.jobs.newJobPopulationsChart, eq); +const getEventRateData = memoizeOne(mlResultsService.getEventRateData, eq); +const getCategoryFields = memoizeOne(getCategoryFieldsOrig, eq); export class ChartLoader { private _indexPatternTitle: IndexPatternTitle = ''; diff --git a/x-pack/legacy/plugins/ml/public/application/jobs/new_job/recognize/page.tsx b/x-pack/legacy/plugins/ml/public/application/jobs/new_job/recognize/page.tsx index ddaaeaa8566be8..50c35ec426acb0 100644 --- a/x-pack/legacy/plugins/ml/public/application/jobs/new_job/recognize/page.tsx +++ b/x-pack/legacy/plugins/ml/public/application/jobs/new_job/recognize/page.tsx @@ -26,12 +26,10 @@ import { ml } from '../../../services/ml_api_service'; import { useMlContext } from '../../../contexts/ml'; import { DatafeedResponse, - DataRecognizerConfigResponse, JobOverride, JobResponse, KibanaObject, KibanaObjectResponse, - Module, ModuleJob, } from '../../../../../common/types/modules'; import { mlJobService } from '../../../services/job_service'; @@ -106,7 +104,7 @@ export const Page: FC = ({ moduleId, existingGroupIds }) => { */ const loadModule = async () => { try { - const response = await ml.getDataRecognizerModule({ moduleId }); + const response = await ml.getDataRecognizerModule({ moduleId }); setJobs(response.jobs); const kibanaObjectsResult = await checkForSavedObjects(response.kibana as KibanaObjects); @@ -165,7 +163,7 @@ export const Page: FC = ({ moduleId, existingGroupIds }) => { let jobOverridesPayload: JobOverride[] | null = Object.values(jobOverrides); jobOverridesPayload = jobOverridesPayload.length > 0 ? jobOverridesPayload : null; - const response = await ml.setupDataRecognizerConfig({ + const response = await ml.setupDataRecognizerConfig({ moduleId, prefix: resultJobPrefix, query: tempQuery, diff --git a/x-pack/legacy/plugins/ml/public/application/overview/components/anomaly_detection_panel/anomaly_detection_panel.tsx b/x-pack/legacy/plugins/ml/public/application/overview/components/anomaly_detection_panel/anomaly_detection_panel.tsx index 44356aa169f689..5f5c3f7c28670a 100644 --- a/x-pack/legacy/plugins/ml/public/application/overview/components/anomaly_detection_panel/anomaly_detection_panel.tsx +++ b/x-pack/legacy/plugins/ml/public/application/overview/components/anomaly_detection_panel/anomaly_detection_panel.tsx @@ -102,11 +102,7 @@ export const AnomalyDetectionPanel: FC = ({ jobCreationDisabled }) => { const latestTimestamp = group.latest_timestamp; const startMoment = moment(latestTimestamp); const twentyFourHoursAgo = startMoment.subtract(24, 'hours').valueOf(); - return ml.results.getMaxAnomalyScore( - group.jobIds, - twentyFourHoursAgo, - latestTimestamp - ); + return ml.results.getMaxAnomalyScore(group.jobIds, twentyFourHoursAgo, latestTimestamp); }); const results = await Promise.all(promises); diff --git a/x-pack/legacy/plugins/ml/public/application/services/ml_api_service/index.ts b/x-pack/legacy/plugins/ml/public/application/services/ml_api_service/index.ts index 2c7ff0a0325a84..a2310c591671df 100644 --- a/x-pack/legacy/plugins/ml/public/application/services/ml_api_service/index.ts +++ b/x-pack/legacy/plugins/ml/public/application/services/ml_api_service/index.ts @@ -25,6 +25,7 @@ import { } from '../../../../common/types/anomaly_detection_jobs'; import { ES_AGGREGATION } from '../../../../common/constants/aggregation_types'; import { FieldRequestConfig } from '../../datavisualizer/index_based/common'; +import { DataRecognizerConfigResponse, Module } from '../../../../common/types/modules'; export interface MlInfoResponse { defaults: MlServerDefaults; @@ -339,8 +340,8 @@ export const ml = { }); }, - getDataRecognizerModule({ moduleId }: { moduleId: string }): Promise { - return http({ + getDataRecognizerModule({ moduleId }: { moduleId: string }) { + return http({ path: `${basePath()}/modules/get_module/${moduleId}`, method: 'GET', }); @@ -353,7 +354,7 @@ export const ml = { }); }, - setupDataRecognizerConfig({ + setupDataRecognizerConfig({ moduleId, prefix, groups, @@ -375,7 +376,7 @@ export const ml = { start?: number; end?: number; jobOverrides?: Array>; - }): Promise { + }) { const body = JSON.stringify({ prefix, groups, @@ -388,14 +389,14 @@ export const ml = { jobOverrides, }); - return http({ + return http({ path: `${basePath()}/modules/setup/${moduleId}`, method: 'POST', body, }); }, - getVisualizerFieldStats({ + getVisualizerFieldStats({ indexPatternTitle, query, timeFieldName, @@ -415,7 +416,7 @@ export const ml = { interval?: string; fields?: FieldRequestConfig[]; maxExamples?: number; - }): Promise { + }) { const body = JSON.stringify({ query, timeFieldName, @@ -427,7 +428,7 @@ export const ml = { maxExamples, }); - return http({ + return http({ path: `${basePath()}/data_visualizer/get_field_stats/${indexPatternTitle}`, method: 'POST', body, diff --git a/x-pack/legacy/plugins/ml/public/application/services/ml_api_service/jobs.ts b/x-pack/legacy/plugins/ml/public/application/services/ml_api_service/jobs.ts index a1833aa8279ed8..4010d6a467f5b6 100644 --- a/x-pack/legacy/plugins/ml/public/application/services/ml_api_service/jobs.ts +++ b/x-pack/legacy/plugins/ml/public/application/services/ml_api_service/jobs.ts @@ -140,7 +140,7 @@ export const jobs = { }); }, - newJobLineChart( + newJobLineChart( indexPatternTitle: string, timeField: string, start: number, @@ -150,7 +150,7 @@ export const jobs = { aggFieldNamePairs: AggFieldNamePair[], splitFieldName: string | null, splitFieldValue: string | null - ): Promise { + ) { const body = JSON.stringify({ indexPatternTitle, timeField, @@ -162,14 +162,14 @@ export const jobs = { splitFieldName, splitFieldValue, }); - return http({ + return http({ path: `${basePath()}/jobs/new_job_line_chart`, method: 'POST', body, }); }, - newJobPopulationsChart( + newJobPopulationsChart( indexPatternTitle: string, timeField: string, start: number, @@ -178,7 +178,7 @@ export const jobs = { query: any, aggFieldNamePairs: AggFieldNamePair[], splitFieldName: string - ): Promise { + ) { const body = JSON.stringify({ indexPatternTitle, timeField, @@ -189,7 +189,7 @@ export const jobs = { aggFieldNamePairs, splitFieldName, }); - return http({ + return http({ path: `${basePath()}/jobs/new_job_population_chart`, method: 'POST', body, diff --git a/x-pack/legacy/plugins/ml/public/application/services/ml_api_service/results.ts b/x-pack/legacy/plugins/ml/public/application/services/ml_api_service/results.ts index 059ef118a0adea..830e6fab4163a3 100644 --- a/x-pack/legacy/plugins/ml/public/application/services/ml_api_service/results.ts +++ b/x-pack/legacy/plugins/ml/public/application/services/ml_api_service/results.ts @@ -47,13 +47,13 @@ export const results = { }); }, - getMaxAnomalyScore(jobIds: string[], earliestMs: number, latestMs: number): Promise { + getMaxAnomalyScore(jobIds: string[], earliestMs: number, latestMs: number) { const body = JSON.stringify({ jobIds, earliestMs, latestMs, }); - return http({ + return http({ path: `${basePath()}/results/max_anomaly_score`, method: 'POST', body,