[ML] Adding error reporting to new job wizard charts (#43857)
This commit is contained in:
parent
0772e19346
commit
dce041c70b
20
x-pack/legacy/plugins/ml/public/components/messagebar/messagebar_service.d.ts
vendored
Normal file
20
x-pack/legacy/plugins/ml/public/components/messagebar/messagebar_service.d.ts
vendored
Normal file
|
@ -0,0 +1,20 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License;
|
||||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
|
||||
declare interface MlMessageBarService {
|
||||
getMessages(): any[];
|
||||
addMessage(msg: any): void;
|
||||
removeMessage(index: number): void;
|
||||
clear(): void;
|
||||
info(text: any): void;
|
||||
warning(text: any): void;
|
||||
error(text: any, resp?: any): void;
|
||||
notify: {
|
||||
error(text: any, resp?: any): void;
|
||||
};
|
||||
}
|
||||
|
||||
export const mlMessageBarService: MlMessageBarService;
|
|
@ -13,7 +13,7 @@ import {
|
|||
DataFrameTransformEndpointRequest,
|
||||
DataFrameTransformEndpointResult,
|
||||
} from '../../components/transform_list/common';
|
||||
// @ts-ignore no declaration file
|
||||
|
||||
import { mlMessageBarService } from '../../../../../../public/components/messagebar/messagebar_service';
|
||||
|
||||
export const deleteTransforms = async (dataFrames: DataFrameTransformListRow[]) => {
|
||||
|
|
|
@ -15,7 +15,7 @@ import {
|
|||
DataFrameTransformEndpointRequest,
|
||||
DataFrameTransformEndpointResult,
|
||||
} from '../../components/transform_list/common';
|
||||
// @ts-ignore no declaration file
|
||||
|
||||
import { mlMessageBarService } from '../../../../../../public/components/messagebar/messagebar_service';
|
||||
|
||||
export const startTransforms = async (dataFrames: DataFrameTransformListRow[]) => {
|
||||
|
|
|
@ -15,7 +15,7 @@ import {
|
|||
DataFrameTransformEndpointRequest,
|
||||
DataFrameTransformEndpointResult,
|
||||
} from '../../components/transform_list/common';
|
||||
// @ts-ignore no declaration file
|
||||
|
||||
import { mlMessageBarService } from '../../../../../../public/components/messagebar/messagebar_service';
|
||||
|
||||
export const stopTransforms = async (dataFrames: DataFrameTransformListRow[]) => {
|
||||
|
|
|
@ -6,13 +6,12 @@
|
|||
|
||||
import { useContext, useState } from 'react';
|
||||
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import { toastNotifications } from 'ui/notify';
|
||||
import { JobCreatorContext } from '../../../job_creator_context';
|
||||
import { EVENT_RATE_FIELD_ID } from '../../../../../../../../common/types/fields';
|
||||
import { isMultiMetricJobCreator, isPopulationJobCreator } from '../../../../../common/job_creator';
|
||||
import { ml } from '../../../../../../../services/ml_api_service';
|
||||
import { useKibanaContext } from '../../../../../../../contexts/kibana';
|
||||
import { mlMessageBarService } from '../../../../../../../components/messagebar/messagebar_service';
|
||||
|
||||
export enum ESTIMATE_STATUS {
|
||||
NOT_RUNNING,
|
||||
|
@ -47,20 +46,7 @@ export function useEstimateBucketSpan() {
|
|||
const { name, error, message } = await ml.estimateBucketSpan(data);
|
||||
setStatus(ESTIMATE_STATUS.NOT_RUNNING);
|
||||
if (error === true) {
|
||||
let text = '';
|
||||
if (message !== undefined) {
|
||||
if (typeof message === 'object') {
|
||||
text = message.msg || JSON.stringify(message);
|
||||
} else {
|
||||
text = message;
|
||||
}
|
||||
}
|
||||
toastNotifications.addDanger({
|
||||
title: i18n.translate('xpack.ml.newJob.wizard.pickFieldsStep.bucketSpanEstimatorError', {
|
||||
defaultMessage: `Bucket span estimation error`,
|
||||
}),
|
||||
text,
|
||||
});
|
||||
mlMessageBarService.notify.error(message);
|
||||
} else {
|
||||
jobCreator.bucketSpan = name;
|
||||
jobCreatorUpdate();
|
||||
|
|
|
@ -16,6 +16,7 @@ import { AggFieldPair } from '../../../../../../../../common/types/fields';
|
|||
import { defaultChartSettings, ChartSettings } from '../../../charts/common/settings';
|
||||
import { MetricSelector } from './metric_selector';
|
||||
import { ChartGrid } from './chart_grid';
|
||||
import { mlMessageBarService } from '../../../../../../../components/messagebar/messagebar_service';
|
||||
|
||||
interface Props {
|
||||
isActive: boolean;
|
||||
|
@ -118,7 +119,9 @@ export const MultiMetricDetectors: FC<Props> = ({ isActive, setIsValid }) => {
|
|||
chartLoader
|
||||
.loadFieldExampleValues(splitField)
|
||||
.then(setFieldValues)
|
||||
.catch(() => {});
|
||||
.catch(error => {
|
||||
mlMessageBarService.notify.error(error);
|
||||
});
|
||||
} else {
|
||||
setFieldValues([]);
|
||||
}
|
||||
|
@ -154,16 +157,20 @@ export const MultiMetricDetectors: FC<Props> = ({ isActive, setIsValid }) => {
|
|||
|
||||
if (aggFieldPairList.length > 0) {
|
||||
setLoadingData(true);
|
||||
const resp: LineChartData = await chartLoader.loadLineCharts(
|
||||
jobCreator.start,
|
||||
jobCreator.end,
|
||||
aggFieldPairList,
|
||||
jobCreator.splitField,
|
||||
fieldValues.length > 0 ? fieldValues[0] : null,
|
||||
cs.intervalMs
|
||||
);
|
||||
|
||||
setLineChartsData(resp);
|
||||
try {
|
||||
const resp: LineChartData = await chartLoader.loadLineCharts(
|
||||
jobCreator.start,
|
||||
jobCreator.end,
|
||||
aggFieldPairList,
|
||||
jobCreator.splitField,
|
||||
fieldValues.length > 0 ? fieldValues[0] : null,
|
||||
cs.intervalMs
|
||||
);
|
||||
setLineChartsData(resp);
|
||||
} catch (error) {
|
||||
mlMessageBarService.notify.error(error);
|
||||
setLineChartsData([]);
|
||||
}
|
||||
setLoadingData(false);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,6 +8,8 @@
|
|||
|
||||
import _ from 'lodash';
|
||||
|
||||
import { mlLog } from '../../client/log';
|
||||
|
||||
import { INTERVALS } from './intervals';
|
||||
import { singleSeriesCheckerFactory } from './single_series_checker';
|
||||
import { polledDataCheckerFactory } from './polled_data_checker';
|
||||
|
@ -115,7 +117,7 @@ export function estimateBucketSpanFactory(callWithRequest, elasticsearchPlugin,
|
|||
run() {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (this.checkers.length === 0) {
|
||||
console.log('BucketSpanEstimator: run has stopped because no checks were created');
|
||||
mlLog.warn('BucketSpanEstimator: run has stopped because no checks were created');
|
||||
reject('BucketSpanEstimator: run has stopped because no checks were created');
|
||||
}
|
||||
|
||||
|
@ -136,7 +138,7 @@ export function estimateBucketSpanFactory(callWithRequest, elasticsearchPlugin,
|
|||
resolve(median);
|
||||
} else {
|
||||
// no results found
|
||||
console.log('BucketSpanEstimator: run has stopped because no checks returned a valid interval');
|
||||
mlLog.warn('BucketSpanEstimator: run has stopped because no checks returned a valid interval');
|
||||
reject('BucketSpanEstimator: run has stopped because no checks returned a valid interval');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,6 +13,8 @@
|
|||
* Bucket spans: 5m, 10m, 30m, 1h, 3h
|
||||
*/
|
||||
|
||||
|
||||
import { mlLog } from '../../client/log';
|
||||
import { INTERVALS, LONG_INTERVALS } from './intervals';
|
||||
|
||||
export function singleSeriesCheckerFactory(callWithRequest) {
|
||||
|
@ -59,7 +61,7 @@ export function singleSeriesCheckerFactory(callWithRequest) {
|
|||
start();
|
||||
})
|
||||
.catch((resp) => {
|
||||
console.log('SingleSeriesChecker: Could not load metric reference data', this);
|
||||
mlLog.warn('SingleSeriesChecker: Could not load metric reference data');
|
||||
reject(resp);
|
||||
});
|
||||
}
|
||||
|
@ -145,7 +147,7 @@ export function singleSeriesCheckerFactory(callWithRequest) {
|
|||
}
|
||||
}
|
||||
} else {
|
||||
console.log('SingleSeriesChecker: runTest stopped because fullBuckets is empty', this);
|
||||
mlLog.warn('SingleSeriesChecker: runTest stopped because fullBuckets is empty');
|
||||
reject('runTest stopped because fullBuckets is empty');
|
||||
}
|
||||
})
|
||||
|
|
Loading…
Reference in a new issue