mirror of
https://github.com/elastic/kibana.git
synced 2025-06-28 11:05:39 -04:00
[Data Usage] Enabled plugin for Serverless and added feature flag to manage availability (#201465)
This PR enables data_usage plugin for Serverless environment for all 3 solutions. To manage feature availability added feature flag, which is turning Data Usage off by default.
This commit is contained in:
parent
3c2c891a14
commit
5342f327ee
13 changed files with 150 additions and 20 deletions
|
@ -229,3 +229,8 @@ monitoring.ui.enabled: false
|
||||||
xpack.securitySolution.enableUiSettingsValidations: true
|
xpack.securitySolution.enableUiSettingsValidations: true
|
||||||
data.enableUiSettingsValidations: true
|
data.enableUiSettingsValidations: true
|
||||||
discover.enableUiSettingsValidations: true
|
discover.enableUiSettingsValidations: true
|
||||||
|
|
||||||
|
## Data Usage in stack management
|
||||||
|
xpack.dataUsage.enabled: true
|
||||||
|
# This feature is disabled in Serverless until fully tested within a Serverless environment
|
||||||
|
xpack.dataUsage.enableExperimental: ['dataUsageDisabled']
|
||||||
|
|
66
x-pack/plugins/data_usage/common/experimental_features.ts
Normal file
66
x-pack/plugins/data_usage/common/experimental_features.ts
Normal file
|
@ -0,0 +1,66 @@
|
||||||
|
/*
|
||||||
|
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||||
|
* or more contributor license agreements. Licensed under the Elastic License
|
||||||
|
* 2.0; you may not use this file except in compliance with the Elastic License
|
||||||
|
* 2.0.
|
||||||
|
*/
|
||||||
|
|
||||||
|
export type ServerlessExperimentalFeatures = Record<
|
||||||
|
keyof typeof allowedExperimentalValues,
|
||||||
|
boolean
|
||||||
|
>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A list of allowed values that can be used in `xpack.dataUsage.enableExperimental`.
|
||||||
|
* This object is then used to validate and parse the value entered.
|
||||||
|
*/
|
||||||
|
export const allowedExperimentalValues = Object.freeze({
|
||||||
|
/**
|
||||||
|
* <Add a description of the feature here>
|
||||||
|
*
|
||||||
|
* [This is a fake feature key to showcase how to add a new serverless-specific experimental flag.
|
||||||
|
* It also prevents `allowedExperimentalValues` from being empty. It should be removed once a real feature is added.]
|
||||||
|
*/
|
||||||
|
dataUsageDisabled: false,
|
||||||
|
});
|
||||||
|
|
||||||
|
type ServerlessExperimentalConfigKeys = Array<keyof ServerlessExperimentalFeatures>;
|
||||||
|
type Mutable<T> = { -readonly [P in keyof T]: T[P] };
|
||||||
|
|
||||||
|
const allowedKeys = Object.keys(
|
||||||
|
allowedExperimentalValues
|
||||||
|
) as Readonly<ServerlessExperimentalConfigKeys>;
|
||||||
|
|
||||||
|
export type ExperimentalFeatures = ServerlessExperimentalFeatures;
|
||||||
|
/**
|
||||||
|
* Parses the string value used in `xpack.dataUsage.enableExperimental` kibana configuration,
|
||||||
|
* which should be a string of values delimited by a comma (`,`)
|
||||||
|
* The generic experimental features are merged with the serverless values to ensure they are available
|
||||||
|
*
|
||||||
|
* @param configValue
|
||||||
|
* @throws DataUsagenvalidExperimentalValue
|
||||||
|
*/
|
||||||
|
export const parseExperimentalConfigValue = (
|
||||||
|
configValue: string[]
|
||||||
|
): { features: ExperimentalFeatures; invalid: string[] } => {
|
||||||
|
const enabledFeatures: Mutable<Partial<ExperimentalFeatures>> = {};
|
||||||
|
const invalidKeys: string[] = [];
|
||||||
|
|
||||||
|
for (const value of configValue) {
|
||||||
|
if (!allowedKeys.includes(value as keyof ServerlessExperimentalFeatures)) {
|
||||||
|
invalidKeys.push(value);
|
||||||
|
} else {
|
||||||
|
enabledFeatures[value as keyof ServerlessExperimentalFeatures] = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
features: {
|
||||||
|
...allowedExperimentalValues,
|
||||||
|
...enabledFeatures,
|
||||||
|
},
|
||||||
|
invalid: invalidKeys,
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
export const getExperimentalAllowedValues = (): string[] => [...allowedKeys];
|
|
@ -11,7 +11,6 @@ import type {
|
||||||
DataUsagePublicStart,
|
DataUsagePublicStart,
|
||||||
DataUsageSetupDependencies,
|
DataUsageSetupDependencies,
|
||||||
DataUsageStartDependencies,
|
DataUsageStartDependencies,
|
||||||
ConfigSchema,
|
|
||||||
} from './types';
|
} from './types';
|
||||||
import { DataUsagePlugin } from './plugin';
|
import { DataUsagePlugin } from './plugin';
|
||||||
|
|
||||||
|
@ -22,4 +21,5 @@ export const plugin: PluginInitializer<
|
||||||
DataUsagePublicStart,
|
DataUsagePublicStart,
|
||||||
DataUsageSetupDependencies,
|
DataUsageSetupDependencies,
|
||||||
DataUsageStartDependencies
|
DataUsageStartDependencies
|
||||||
> = (pluginInitializerContext: PluginInitializerContext<ConfigSchema>) => new DataUsagePlugin();
|
> = (pluginInitializerContext: PluginInitializerContext) =>
|
||||||
|
new DataUsagePlugin(pluginInitializerContext);
|
||||||
|
|
|
@ -5,17 +5,21 @@
|
||||||
* 2.0.
|
* 2.0.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { CoreSetup, CoreStart, Plugin } from '@kbn/core/public';
|
import { CoreSetup, CoreStart, Plugin, PluginInitializerContext } from '@kbn/core/public';
|
||||||
import { ManagementAppMountParams } from '@kbn/management-plugin/public';
|
import { ManagementAppMountParams } from '@kbn/management-plugin/public';
|
||||||
import {
|
import {
|
||||||
DataUsagePublicSetup,
|
DataUsagePublicSetup,
|
||||||
DataUsagePublicStart,
|
DataUsagePublicStart,
|
||||||
DataUsageStartDependencies,
|
DataUsageStartDependencies,
|
||||||
DataUsageSetupDependencies,
|
DataUsageSetupDependencies,
|
||||||
|
DataUsagePublicConfigType,
|
||||||
} from './types';
|
} from './types';
|
||||||
import { PLUGIN_ID } from '../common';
|
import { PLUGIN_ID } from '../common';
|
||||||
import { PLUGIN_NAME } from './translations';
|
import { PLUGIN_NAME } from './translations';
|
||||||
|
import {
|
||||||
|
ExperimentalFeatures,
|
||||||
|
parseExperimentalConfigValue,
|
||||||
|
} from '../common/experimental_features';
|
||||||
export class DataUsagePlugin
|
export class DataUsagePlugin
|
||||||
implements
|
implements
|
||||||
Plugin<
|
Plugin<
|
||||||
|
@ -25,11 +29,27 @@ export class DataUsagePlugin
|
||||||
DataUsageStartDependencies
|
DataUsageStartDependencies
|
||||||
>
|
>
|
||||||
{
|
{
|
||||||
|
private config: DataUsagePublicConfigType;
|
||||||
|
private experimentalFeatures: ExperimentalFeatures;
|
||||||
|
|
||||||
|
constructor(private readonly initializerContext: PluginInitializerContext) {
|
||||||
|
this.config = this.initializerContext.config.get<DataUsagePublicConfigType>();
|
||||||
|
this.experimentalFeatures = {} as ExperimentalFeatures;
|
||||||
|
}
|
||||||
|
|
||||||
public setup(
|
public setup(
|
||||||
core: CoreSetup<DataUsageStartDependencies, DataUsagePublicStart>,
|
core: CoreSetup<DataUsageStartDependencies, DataUsagePublicStart>,
|
||||||
plugins: DataUsageSetupDependencies
|
plugins: DataUsageSetupDependencies
|
||||||
): DataUsagePublicSetup {
|
): DataUsagePublicSetup {
|
||||||
const { management } = plugins;
|
const { management } = plugins;
|
||||||
|
|
||||||
|
this.experimentalFeatures = parseExperimentalConfigValue(
|
||||||
|
this.config.enableExperimental
|
||||||
|
).features;
|
||||||
|
|
||||||
|
const experimentalFeatures = this.experimentalFeatures;
|
||||||
|
|
||||||
|
if (!experimentalFeatures.dataUsageDisabled) {
|
||||||
management.sections.section.data.registerApp({
|
management.sections.section.data.registerApp({
|
||||||
id: PLUGIN_ID,
|
id: PLUGIN_ID,
|
||||||
title: PLUGIN_NAME,
|
title: PLUGIN_NAME,
|
||||||
|
@ -44,11 +64,11 @@ export class DataUsagePlugin
|
||||||
return renderApp(coreStart, pluginsStartDeps, pluginStart, params);
|
return renderApp(coreStart, pluginsStartDeps, pluginStart, params);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
}
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
public start(_core: CoreStart): DataUsagePublicStart {
|
public start(_core: CoreStart, plugins: DataUsageStartDependencies): DataUsagePublicStart {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
* 2.0.
|
* 2.0.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import { schema, TypeOf } from '@kbn/config-schema';
|
||||||
import { ManagementSetup, ManagementStart } from '@kbn/management-plugin/public';
|
import { ManagementSetup, ManagementStart } from '@kbn/management-plugin/public';
|
||||||
import { SharePluginSetup, SharePluginStart } from '@kbn/share-plugin/public';
|
import { SharePluginSetup, SharePluginStart } from '@kbn/share-plugin/public';
|
||||||
|
|
||||||
|
@ -23,5 +24,21 @@ export interface DataUsageStartDependencies {
|
||||||
management: ManagementStart;
|
management: ManagementStart;
|
||||||
share: SharePluginStart;
|
share: SharePluginStart;
|
||||||
}
|
}
|
||||||
// eslint-disable-next-line @typescript-eslint/no-empty-interface
|
|
||||||
export interface ConfigSchema {}
|
const schemaObject = schema.object({
|
||||||
|
/**
|
||||||
|
* For internal use. A list of string values (comma delimited) that will enable experimental
|
||||||
|
* type of functionality that is not yet released. Valid values for this settings need to
|
||||||
|
* be defined in:
|
||||||
|
* `x-pack/plugins/dataUsage/common/experimental_features.ts`
|
||||||
|
* under the `allowedExperimentalValues` object
|
||||||
|
*
|
||||||
|
* @example
|
||||||
|
* xpack.dataUsage.enableExperimental: ['someFeature']
|
||||||
|
*/
|
||||||
|
enableExperimental: schema.arrayOf(schema.string(), {
|
||||||
|
defaultValue: () => [],
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
|
||||||
|
export type DataUsagePublicConfigType = TypeOf<typeof schemaObject>;
|
||||||
|
|
|
@ -26,6 +26,19 @@ export const configSchema = schema.object({
|
||||||
),
|
),
|
||||||
})
|
})
|
||||||
),
|
),
|
||||||
|
/**
|
||||||
|
* For internal use. A list of string values (comma delimited) that will enable experimental
|
||||||
|
* type of functionality that is not yet released. Valid values for this settings need to
|
||||||
|
* be defined in:
|
||||||
|
* `x-pack/plugins/dataUsage/common/experimental_features.ts`
|
||||||
|
* under the `allowedExperimentalValues` object
|
||||||
|
*
|
||||||
|
* @example
|
||||||
|
* xpack.dataUsage.enableExperimental: ['someFeature']
|
||||||
|
*/
|
||||||
|
enableExperimental: schema.arrayOf(schema.string(), {
|
||||||
|
defaultValue: () => [],
|
||||||
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
export type DataUsageConfigType = TypeOf<typeof configSchema>;
|
export type DataUsageConfigType = TypeOf<typeof configSchema>;
|
||||||
|
|
|
@ -25,6 +25,9 @@ export type { DataUsageServerSetup, DataUsageServerStart };
|
||||||
|
|
||||||
export const config: PluginConfigDescriptor<DataUsageConfigType> = {
|
export const config: PluginConfigDescriptor<DataUsageConfigType> = {
|
||||||
schema: configSchema,
|
schema: configSchema,
|
||||||
|
exposeToBrowser: {
|
||||||
|
enableExperimental: true,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
export const plugin: PluginInitializer<
|
export const plugin: PluginInitializer<
|
||||||
|
|
|
@ -27,6 +27,7 @@ export default createTestConfig({
|
||||||
// useful for testing (also enabled in MKI QA)
|
// useful for testing (also enabled in MKI QA)
|
||||||
'--coreApp.allowDynamicConfigOverrides=true',
|
'--coreApp.allowDynamicConfigOverrides=true',
|
||||||
'--xpack.dataUsage.enabled=true',
|
'--xpack.dataUsage.enabled=true',
|
||||||
|
'--xpack.dataUsage.enableExperimental=[]',
|
||||||
// dataUsage.autoops* config is set in kibana controller
|
// dataUsage.autoops* config is set in kibana controller
|
||||||
'--xpack.dataUsage.autoops.enabled=true',
|
'--xpack.dataUsage.autoops.enabled=true',
|
||||||
'--xpack.dataUsage.autoops.api.url=http://localhost:9000',
|
'--xpack.dataUsage.autoops.api.url=http://localhost:9000',
|
||||||
|
|
|
@ -23,6 +23,7 @@ export default createTestConfig({
|
||||||
// useful for testing (also enabled in MKI QA)
|
// useful for testing (also enabled in MKI QA)
|
||||||
'--coreApp.allowDynamicConfigOverrides=true',
|
'--coreApp.allowDynamicConfigOverrides=true',
|
||||||
'--xpack.dataUsage.enabled=true',
|
'--xpack.dataUsage.enabled=true',
|
||||||
|
'--xpack.dataUsage.enableExperimental=[]',
|
||||||
// dataUsage.autoops* config is set in kibana controller
|
// dataUsage.autoops* config is set in kibana controller
|
||||||
'--xpack.dataUsage.autoops.enabled=true',
|
'--xpack.dataUsage.autoops.enabled=true',
|
||||||
'--xpack.dataUsage.autoops.api.url=http://localhost:9000',
|
'--xpack.dataUsage.autoops.api.url=http://localhost:9000',
|
||||||
|
|
|
@ -27,6 +27,7 @@ export default createTestConfig({
|
||||||
`--xpack.securitySolutionServerless.cloudSecurityUsageReportingTaskInterval=5s`,
|
`--xpack.securitySolutionServerless.cloudSecurityUsageReportingTaskInterval=5s`,
|
||||||
`--xpack.securitySolutionServerless.usageApi.url=http://localhost:8081`,
|
`--xpack.securitySolutionServerless.usageApi.url=http://localhost:8081`,
|
||||||
'--xpack.dataUsage.enabled=true',
|
'--xpack.dataUsage.enabled=true',
|
||||||
|
'--xpack.dataUsage.enableExperimental=[]',
|
||||||
// dataUsage.autoops* config is set in kibana controller
|
// dataUsage.autoops* config is set in kibana controller
|
||||||
'--xpack.dataUsage.autoops.enabled=true',
|
'--xpack.dataUsage.autoops.enabled=true',
|
||||||
'--xpack.dataUsage.autoops.api.url=http://localhost:9000',
|
'--xpack.dataUsage.autoops.api.url=http://localhost:9000',
|
||||||
|
|
|
@ -20,6 +20,7 @@ export default createTestConfig({
|
||||||
esServerArgs: ['xpack.ml.dfa.enabled=false'],
|
esServerArgs: ['xpack.ml.dfa.enabled=false'],
|
||||||
kbnServerArgs: [
|
kbnServerArgs: [
|
||||||
'--xpack.dataUsage.enabled=true',
|
'--xpack.dataUsage.enabled=true',
|
||||||
|
'--xpack.dataUsage.enableExperimental=[]',
|
||||||
// dataUsage.autoops* config is set in kibana controller
|
// dataUsage.autoops* config is set in kibana controller
|
||||||
'--xpack.dataUsage.autoops.enabled=true',
|
'--xpack.dataUsage.autoops.enabled=true',
|
||||||
'--xpack.dataUsage.autoops.api.url=http://localhost:9000',
|
'--xpack.dataUsage.autoops.api.url=http://localhost:9000',
|
||||||
|
|
|
@ -23,6 +23,7 @@ export default createTestConfig({
|
||||||
`--xpack.cloud.serverless.project_name=ES3_FTR_TESTS`,
|
`--xpack.cloud.serverless.project_name=ES3_FTR_TESTS`,
|
||||||
`--xpack.cloud.deployment_url=/projects/elasticsearch/fakeprojectid`,
|
`--xpack.cloud.deployment_url=/projects/elasticsearch/fakeprojectid`,
|
||||||
'--xpack.dataUsage.enabled=true',
|
'--xpack.dataUsage.enabled=true',
|
||||||
|
'--xpack.dataUsage.enableExperimental=[]',
|
||||||
// dataUsage.autoops* config is set in kibana controller
|
// dataUsage.autoops* config is set in kibana controller
|
||||||
'--xpack.dataUsage.autoops.enabled=true',
|
'--xpack.dataUsage.autoops.enabled=true',
|
||||||
'--xpack.dataUsage.autoops.api.url=http://localhost:9000',
|
'--xpack.dataUsage.autoops.api.url=http://localhost:9000',
|
||||||
|
|
|
@ -20,6 +20,7 @@ export default createTestConfig({
|
||||||
esServerArgs: ['xpack.ml.nlp.enabled=true'],
|
esServerArgs: ['xpack.ml.nlp.enabled=true'],
|
||||||
kbnServerArgs: [
|
kbnServerArgs: [
|
||||||
'--xpack.dataUsage.enabled=true',
|
'--xpack.dataUsage.enabled=true',
|
||||||
|
'--xpack.dataUsage.enableExperimental=[]',
|
||||||
// dataUsage.autoops* config is set in kibana controller
|
// dataUsage.autoops* config is set in kibana controller
|
||||||
'--xpack.dataUsage.autoops.enabled=true',
|
'--xpack.dataUsage.autoops.enabled=true',
|
||||||
'--xpack.dataUsage.autoops.api.url=http://localhost:9000',
|
'--xpack.dataUsage.autoops.api.url=http://localhost:9000',
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue