diff --git a/x-pack/legacy/plugins/uptime/public/components/monitor_details/ml/__tests__/__snapshots__/ml_job_link.test.tsx.snap b/x-pack/legacy/plugins/uptime/public/components/monitor_details/ml/__tests__/__snapshots__/ml_job_link.test.tsx.snap index 85988af04a939..9957f13fc1334 100644 --- a/x-pack/legacy/plugins/uptime/public/components/monitor_details/ml/__tests__/__snapshots__/ml_job_link.test.tsx.snap +++ b/x-pack/legacy/plugins/uptime/public/components/monitor_details/ml/__tests__/__snapshots__/ml_job_link.test.tsx.snap @@ -3,7 +3,7 @@ exports[`ML JobLink renders without errors 1`] = ` diff --git a/x-pack/legacy/plugins/uptime/public/components/monitor_details/ml/ml_flyout_container.tsx b/x-pack/legacy/plugins/uptime/public/components/monitor_details/ml/ml_flyout_container.tsx index fad12de94fd81..8ebd69a2d503b 100644 --- a/x-pack/legacy/plugins/uptime/public/components/monitor_details/ml/ml_flyout_container.tsx +++ b/x-pack/legacy/plugins/uptime/public/components/monitor_details/ml/ml_flyout_container.tsx @@ -48,13 +48,13 @@ const showMLJobNotification = (

), - toastLifeTimeMs: 5000, + toastLifeTimeMs: 10000, }); } else { - notifications.toasts.warning({ + notifications.toasts.danger({ title:

{labels.JOB_CREATION_FAILED}

, body: message ??

{labels.JOB_CREATION_FAILED_MESSAGE}

, - toastLifeTimeMs: 5000, + toastLifeTimeMs: 10000, }); } }; @@ -108,7 +108,7 @@ export const MachineLearningFlyout: React.FC = ({ onClose }) => { basePath, { to: dateRangeEnd, from: dateRangeStart }, false, - error?.body?.message + error?.message || error?.body?.message ); } setIsCreatingJob(false); diff --git a/x-pack/legacy/plugins/uptime/public/state/api/ml_anomaly.ts b/x-pack/legacy/plugins/uptime/public/state/api/ml_anomaly.ts index 80b97783769b5..1a945512f7cd9 100644 --- a/x-pack/legacy/plugins/uptime/public/state/api/ml_anomaly.ts +++ b/x-pack/legacy/plugins/uptime/public/state/api/ml_anomaly.ts @@ -13,7 +13,7 @@ import { CreateMLJobSuccess, DeleteJobResults, MonitorIdParam } from '../actions import { DataRecognizerConfigResponse } from '../../../../../../plugins/ml/common/types/modules'; import { JobExistResult } from '../../../../../../plugins/ml/common/types/data_recognizer'; -export const getMLJobId = (monitorId: string) => `${monitorId}_${ML_JOB_ID}`; +export const getMLJobId = (monitorId: string) => `${monitorId}_${ML_JOB_ID}`.toLowerCase(); export const getMLCapabilities = async (): Promise => { return await apiService.get(API_URLS.ML_CAPABILITIES); @@ -28,8 +28,11 @@ export const createMLJob = async ({ }: MonitorIdParam): Promise => { const url = API_URLS.ML_SETUP_MODULE + ML_MODULE_ID; + // ML App doesn't support upper case characters in job name + const lowerCaseMonitorId = monitorId.toLowerCase(); + const data = { - prefix: `${monitorId}_`, + prefix: `${lowerCaseMonitorId}_`, useDedicatedIndex: false, startDatafeed: true, start: moment() @@ -41,7 +44,7 @@ export const createMLJob = async ({ filter: [ { term: { - 'monitor.id': monitorId, + 'monitor.id': lowerCaseMonitorId, }, }, ], @@ -50,11 +53,17 @@ export const createMLJob = async ({ }; const response: DataRecognizerConfigResponse = await apiService.post(url, data); - if (response?.jobs?.[0]?.id === getMLJobId(monitorId) && response?.jobs?.[0]?.success) { - return { - count: 1, - jobId: response?.jobs?.[0]?.id, - }; + if (response?.jobs?.[0]?.id === getMLJobId(monitorId)) { + const jobResponse = response.jobs[0]; + if (jobResponse.success) { + return { + count: 1, + jobId: jobResponse.id, + }; + } else { + const { error } = jobResponse; + throw new Error(error?.msg); + } } else { return null; }