mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
[ML] Add kibana setting for file data visualizer max file size (#64427)
* [ML] Add kibana setting for file data visualizers max file size * adding failsafe for setting * fixing id * [DOCS] Updates Data Visualizer setting Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com> Co-authored-by: lcawl <lcawley@elastic.co>
This commit is contained in:
parent
2b3fadebf9
commit
f9c81a30cb
14 changed files with 61 additions and 74 deletions
|
@ -142,7 +142,14 @@ This setting does not have an effect when loading a saved search.
|
|||
Highlighting slows requests when
|
||||
working on big documents.
|
||||
|
||||
[float]
|
||||
[[kibana-ml-settings]]
|
||||
==== Machine learning
|
||||
|
||||
[horizontal]
|
||||
`ml:fileDataVisualizerMaxFileSize`:: Sets the file size limit when importing
|
||||
data in the {data-viz}. The default value is `100MB`. The highest supported
|
||||
value for this setting is `1GB`.
|
||||
|
||||
|
||||
[float]
|
||||
|
|
|
@ -19,10 +19,4 @@ instance. If `xpack.ml.enabled` is set to `true` in `elasticsearch.yml`, however
|
|||
you can still use the {ml} APIs. To disable {ml} entirely, see the
|
||||
{ref}/ml-settings.html[{es} {ml} settings].
|
||||
|
||||
[[data-visualizer-settings]]
|
||||
==== {data-viz} settings
|
||||
|
||||
`xpack.ml.file_data_visualizer.max_file_size`::
|
||||
Sets the file size limit when importing data in the {data-viz}. The default
|
||||
value is `100MB`. The highest supported value for this setting is `1GB`.
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ image::user/ml/images/ml-data-visualizer-sample.jpg[{data-viz} for sample flight
|
|||
experimental[] You can also upload a CSV, NDJSON, or log file. The *{data-viz}*
|
||||
identifies the file format and field mappings. You can then optionally import
|
||||
that data into an {es} index. To change the default file size limit, see
|
||||
<<data-visualizer-settings>>.
|
||||
<<kibana-ml-settings>>.
|
||||
|
||||
You need the following permissions to use the {data-viz} with file upload:
|
||||
|
||||
|
|
7
x-pack/plugins/ml/common/constants/settings.ts
Normal file
7
x-pack/plugins/ml/common/constants/settings.ts
Normal file
|
@ -0,0 +1,7 @@
|
|||
/*
|
||||
* 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 const FILE_DATA_VISUALIZER_MAX_FILE_SIZE = 'ml:fileDataVisualizerMaxFileSize';
|
|
@ -1,16 +0,0 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
import { schema, TypeOf } from '@kbn/config-schema';
|
||||
import { MAX_FILE_SIZE } from '../constants/file_datavisualizer';
|
||||
|
||||
export const configSchema = schema.object({
|
||||
file_data_visualizer: schema.object({
|
||||
max_file_size: schema.string({ defaultValue: MAX_FILE_SIZE }),
|
||||
}),
|
||||
});
|
||||
|
||||
export type MlConfigType = TypeOf<typeof configSchema>;
|
|
@ -15,14 +15,10 @@ import { KibanaContextProvider } from '../../../../../src/plugins/kibana_react/p
|
|||
import { setDependencyCache, clearCache } from './util/dependency_cache';
|
||||
import { setLicenseCache } from './license';
|
||||
import { MlSetupDependencies, MlStartDependencies } from '../plugin';
|
||||
import { MlConfigType } from '../../common/types/ml_config';
|
||||
|
||||
import { MlRouter } from './routing';
|
||||
|
||||
type MlDependencies = MlSetupDependencies &
|
||||
MlStartDependencies & {
|
||||
mlConfig: MlConfigType;
|
||||
};
|
||||
type MlDependencies = MlSetupDependencies & MlStartDependencies;
|
||||
|
||||
interface AppProps {
|
||||
coreStart: CoreStart;
|
||||
|
@ -78,7 +74,6 @@ export const renderApp = (
|
|||
http: coreStart.http,
|
||||
security: deps.security,
|
||||
urlGenerators: deps.share.urlGenerators,
|
||||
mlConfig: deps.mlConfig,
|
||||
});
|
||||
|
||||
const mlLicense = setLicenseCache(deps.licensing);
|
||||
|
|
|
@ -9,11 +9,13 @@ import numeral from '@elastic/numeral';
|
|||
import { ml } from '../../../../services/ml_api_service';
|
||||
import { AnalysisResult, InputOverrides } from '../../../../../../common/types/file_datavisualizer';
|
||||
import {
|
||||
MAX_FILE_SIZE,
|
||||
MAX_FILE_SIZE_BYTES,
|
||||
ABSOLUTE_MAX_FILE_SIZE_BYTES,
|
||||
FILE_SIZE_DISPLAY_FORMAT,
|
||||
} from '../../../../../../common/constants/file_datavisualizer';
|
||||
import { getMlConfig } from '../../../../util/dependency_cache';
|
||||
import { getUiSettings } from '../../../../util/dependency_cache';
|
||||
import { FILE_DATA_VISUALIZER_MAX_FILE_SIZE } from '../../../../../../common/constants/settings';
|
||||
|
||||
const DEFAULT_LINES_TO_SAMPLE = 1000;
|
||||
const UPLOAD_SIZE_MB = 5;
|
||||
|
@ -62,13 +64,13 @@ export function readFile(file: File) {
|
|||
}
|
||||
|
||||
export function getMaxBytes() {
|
||||
const maxFileSize = getMlConfig().file_data_visualizer.max_file_size;
|
||||
const maxFileSize = getUiSettings().get(FILE_DATA_VISUALIZER_MAX_FILE_SIZE, MAX_FILE_SIZE);
|
||||
// @ts-ignore
|
||||
const maxBytes = numeral(maxFileSize.toUpperCase()).value();
|
||||
if (maxBytes < MAX_FILE_SIZE_BYTES) {
|
||||
return MAX_FILE_SIZE_BYTES;
|
||||
}
|
||||
return maxBytes < ABSOLUTE_MAX_FILE_SIZE_BYTES ? maxBytes : ABSOLUTE_MAX_FILE_SIZE_BYTES;
|
||||
return maxBytes <= ABSOLUTE_MAX_FILE_SIZE_BYTES ? maxBytes : ABSOLUTE_MAX_FILE_SIZE_BYTES;
|
||||
}
|
||||
|
||||
export function getMaxBytesFormatted() {
|
||||
|
|
|
@ -23,7 +23,6 @@ import {
|
|||
} from 'kibana/public';
|
||||
import { SharePluginStart } from 'src/plugins/share/public';
|
||||
import { SecurityPluginSetup } from '../../../../security/public';
|
||||
import { MlConfigType } from '../../../common/types/ml_config';
|
||||
|
||||
export interface DependencyCache {
|
||||
timefilter: DataPublicPluginSetup['query']['timefilter'] | null;
|
||||
|
@ -43,7 +42,6 @@ export interface DependencyCache {
|
|||
security: SecurityPluginSetup | undefined | null;
|
||||
i18n: I18nStart | null;
|
||||
urlGenerators: SharePluginStart['urlGenerators'] | null;
|
||||
mlConfig: MlConfigType | null;
|
||||
}
|
||||
|
||||
const cache: DependencyCache = {
|
||||
|
@ -64,7 +62,6 @@ const cache: DependencyCache = {
|
|||
security: null,
|
||||
i18n: null,
|
||||
urlGenerators: null,
|
||||
mlConfig: null,
|
||||
};
|
||||
|
||||
export function setDependencyCache(deps: Partial<DependencyCache>) {
|
||||
|
@ -85,7 +82,6 @@ export function setDependencyCache(deps: Partial<DependencyCache>) {
|
|||
cache.security = deps.security || null;
|
||||
cache.i18n = deps.i18n || null;
|
||||
cache.urlGenerators = deps.urlGenerators || null;
|
||||
cache.mlConfig = deps.mlConfig || null;
|
||||
}
|
||||
|
||||
export function getTimefilter() {
|
||||
|
@ -206,13 +202,6 @@ export function getGetUrlGenerator() {
|
|||
return cache.urlGenerators.getUrlGenerator;
|
||||
}
|
||||
|
||||
export function getMlConfig() {
|
||||
if (cache.mlConfig === null) {
|
||||
throw new Error("mlConfig hasn't been initialized");
|
||||
}
|
||||
return cache.mlConfig;
|
||||
}
|
||||
|
||||
export function clearCache() {
|
||||
console.log('clearing dependency cache'); // eslint-disable-line no-console
|
||||
Object.keys(cache).forEach(k => {
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
|
||||
import { PluginInitializer, PluginInitializerContext } from 'kibana/public';
|
||||
import { PluginInitializer } from 'kibana/public';
|
||||
import './index.scss';
|
||||
import {
|
||||
MlPlugin,
|
||||
|
@ -19,6 +19,6 @@ export const plugin: PluginInitializer<
|
|||
MlPluginStart,
|
||||
MlSetupDependencies,
|
||||
MlStartDependencies
|
||||
> = (context: PluginInitializerContext) => new MlPlugin(context);
|
||||
> = () => new MlPlugin();
|
||||
|
||||
export { MlPluginSetup, MlPluginStart };
|
||||
|
|
|
@ -5,13 +5,7 @@
|
|||
*/
|
||||
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import {
|
||||
Plugin,
|
||||
CoreStart,
|
||||
CoreSetup,
|
||||
AppMountParameters,
|
||||
PluginInitializerContext,
|
||||
} from 'kibana/public';
|
||||
import { Plugin, CoreStart, CoreSetup, AppMountParameters } from 'kibana/public';
|
||||
import { ManagementSetup } from 'src/plugins/management/public';
|
||||
import { SharePluginStart } from 'src/plugins/share/public';
|
||||
import { UsageCollectionSetup } from 'src/plugins/usage_collection/server';
|
||||
|
@ -25,7 +19,6 @@ import { LicenseManagementUIPluginSetup } from '../../license_management/public'
|
|||
import { setDependencyCache } from './application/util/dependency_cache';
|
||||
import { PLUGIN_ID, PLUGIN_ICON } from '../common/constants/app';
|
||||
import { registerFeature } from './register_feature';
|
||||
import { MlConfigType } from '../common/types/ml_config';
|
||||
|
||||
export interface MlStartDependencies {
|
||||
data: DataPublicPluginStart;
|
||||
|
@ -41,10 +34,7 @@ export interface MlSetupDependencies {
|
|||
}
|
||||
|
||||
export class MlPlugin implements Plugin<MlPluginSetup, MlPluginStart> {
|
||||
constructor(private readonly initializerContext: PluginInitializerContext) {}
|
||||
|
||||
setup(core: CoreSetup<MlStartDependencies, MlPluginStart>, pluginsSetup: MlSetupDependencies) {
|
||||
const mlConfig = this.initializerContext.config.get<MlConfigType>();
|
||||
core.application.register({
|
||||
id: PLUGIN_ID,
|
||||
title: i18n.translate('xpack.ml.plugin.title', {
|
||||
|
@ -67,7 +57,6 @@ export class MlPlugin implements Plugin<MlPluginSetup, MlPluginStart> {
|
|||
usageCollection: pluginsSetup.usageCollection,
|
||||
licenseManagement: pluginsSetup.licenseManagement,
|
||||
home: pluginsSetup.home,
|
||||
mlConfig,
|
||||
},
|
||||
{
|
||||
element: params.element,
|
||||
|
|
|
@ -1,15 +0,0 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
import { PluginConfigDescriptor } from 'kibana/server';
|
||||
import { MlConfigType, configSchema } from '../common/types/ml_config';
|
||||
|
||||
export const config: PluginConfigDescriptor<MlConfigType> = {
|
||||
exposeToBrowser: {
|
||||
file_data_visualizer: true,
|
||||
},
|
||||
schema: configSchema,
|
||||
};
|
|
@ -9,5 +9,3 @@ import { MlServerPlugin } from './plugin';
|
|||
export { MlPluginSetup, MlPluginStart } from './plugin';
|
||||
|
||||
export const plugin = (ctx: PluginInitializerContext) => new MlServerPlugin(ctx);
|
||||
|
||||
export { config } from './config';
|
||||
|
|
34
x-pack/plugins/ml/server/lib/register_settings.ts
Normal file
34
x-pack/plugins/ml/server/lib/register_settings.ts
Normal file
|
@ -0,0 +1,34 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
import { CoreSetup } from 'kibana/server';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import { schema } from '@kbn/config-schema';
|
||||
import { FILE_DATA_VISUALIZER_MAX_FILE_SIZE } from '../../common/constants/settings';
|
||||
import { MAX_FILE_SIZE } from '../../common/constants/file_datavisualizer';
|
||||
|
||||
export function registerKibanaSettings(coreSetup: CoreSetup) {
|
||||
coreSetup.uiSettings.register({
|
||||
[FILE_DATA_VISUALIZER_MAX_FILE_SIZE]: {
|
||||
name: i18n.translate('xpack.ml.maxFileSizeSettingsName', {
|
||||
defaultMessage: 'File Data Visualizer maximum file upload size',
|
||||
}),
|
||||
value: MAX_FILE_SIZE,
|
||||
description: i18n.translate('xpack.ml.maxFileSizeSettingsDescription', {
|
||||
defaultMessage:
|
||||
'Sets the file size limit when importing data in the File Data Visualizer. The highest supported value for this setting is 1GB.',
|
||||
}),
|
||||
category: ['Machine Learning'],
|
||||
schema: schema.string(),
|
||||
validation: {
|
||||
regexString: '\\d+[mMgG][bB]',
|
||||
message: i18n.translate('xpack.ml.maxFileSizeSettingsError', {
|
||||
defaultMessage: 'Should be a valid data size. e.g. 200MB, 1GB',
|
||||
}),
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
|
@ -47,6 +47,7 @@ import { MlServerLicense } from './lib/license';
|
|||
import { createSharedServices, SharedServices } from './shared_services';
|
||||
import { userMlCapabilities, adminMlCapabilities } from '../common/types/capabilities';
|
||||
import { setupCapabilitiesSwitcher } from './lib/capabilities';
|
||||
import { registerKibanaSettings } from './lib/register_settings';
|
||||
|
||||
declare module 'kibana/server' {
|
||||
interface RequestHandlerContext {
|
||||
|
@ -122,6 +123,8 @@ export class MlServerPlugin implements Plugin<MlPluginSetup, MlPluginStart, Plug
|
|||
},
|
||||
});
|
||||
|
||||
registerKibanaSettings(coreSetup);
|
||||
|
||||
this.mlLicense.setup(plugins.licensing.license$, [
|
||||
(mlLicense: MlLicense) => initSampleDataSets(mlLicense, plugins),
|
||||
]);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue