mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
[ML] Better handling of recognizer module manifest parsing errors (#29322)
This commit is contained in:
parent
50d7f6229a
commit
ec607e26b9
5 changed files with 28 additions and 5 deletions
|
@ -29,6 +29,7 @@ import { jobServiceRoutes } from './server/routes/job_service';
|
|||
import { jobAuditMessagesRoutes } from './server/routes/job_audit_messages';
|
||||
import { fileDataVisualizerRoutes } from './server/routes/file_data_visualizer';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import { initMlServerLog } from './server/client/log';
|
||||
|
||||
export const ml = (kibana) => {
|
||||
return new kibana.Plugin({
|
||||
|
@ -108,6 +109,8 @@ export const ml = (kibana) => {
|
|||
jobServiceRoutes(server, commonRouteConfig);
|
||||
jobAuditMessagesRoutes(server, commonRouteConfig);
|
||||
fileDataVisualizerRoutes(server, commonRouteConfig);
|
||||
|
||||
initMlServerLog(server);
|
||||
}
|
||||
|
||||
});
|
||||
|
|
|
@ -49,6 +49,9 @@ export class DataRecognizer extends Component {
|
|||
this.setState({
|
||||
results
|
||||
});
|
||||
})
|
||||
.catch((e) => {
|
||||
console.error('Error attempting to recognize index', e);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
11
x-pack/plugins/ml/server/client/log.js
Normal file
11
x-pack/plugins/ml/server/client/log.js
Normal file
|
@ -0,0 +1,11 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
export let mlLog = () => {};
|
||||
|
||||
export function initMlServerLog(server) {
|
||||
mlLog = (level, message) => server.log(['ml', level], message);
|
||||
}
|
|
@ -5,6 +5,7 @@
|
|||
*/
|
||||
|
||||
import { callWithInternalUserFactory } from '../../client/call_with_internal_user_factory';
|
||||
import { mlLog } from '../../client/log';
|
||||
|
||||
import {
|
||||
ML_ANNOTATIONS_INDEX_ALIAS_READ,
|
||||
|
@ -42,7 +43,7 @@ export async function isAnnotationsFeatureAvailable(server) {
|
|||
if (!annotationsWriteAliasExists) return false;
|
||||
|
||||
} catch (err) {
|
||||
server.log(['info', 'ml'], 'Disabling ML annotations feature because the index/alias integrity check failed.');
|
||||
mlLog('info', 'Disabling ML annotations feature because the index/alias integrity check failed.');
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
import fs from 'fs';
|
||||
import Boom from 'boom';
|
||||
import { prefixDatafeedId } from '../../../common/util/job_utils';
|
||||
import { mlLog } from '../../client/log';
|
||||
|
||||
const ML_DIR = 'ml';
|
||||
const KIBANA_DIR = 'kibana';
|
||||
|
@ -63,10 +64,14 @@ export class DataRecognizer {
|
|||
const dirs = await this.listDirs(this.modulesDir);
|
||||
await Promise.all(dirs.map(async (dir) => {
|
||||
const file = await this.readFile(`${this.modulesDir}/${dir}/manifest.json`);
|
||||
configs.push({
|
||||
dirName: dir,
|
||||
json: JSON.parse(file)
|
||||
});
|
||||
try {
|
||||
configs.push({
|
||||
dirName: dir,
|
||||
json: JSON.parse(file)
|
||||
});
|
||||
} catch (error) {
|
||||
mlLog('warning', `Error parsing ${dir}/manifest.json`);
|
||||
}
|
||||
}));
|
||||
|
||||
return configs;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue