From ebd3be8615e36eec4e6d69f0f42f959fb619c494 Mon Sep 17 00:00:00 2001 From: Alexey Antonov Date: Sat, 4 Apr 2020 11:26:33 +0300 Subject: [PATCH 1/8] [Timeseries] remove unused configuration properties --- src/legacy/core_plugins/vis_type_timeseries/index.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/legacy/core_plugins/vis_type_timeseries/index.ts b/src/legacy/core_plugins/vis_type_timeseries/index.ts index 3ad8ba3a31c17..2768a5b0aa862 100644 --- a/src/legacy/core_plugins/vis_type_timeseries/index.ts +++ b/src/legacy/core_plugins/vis_type_timeseries/index.ts @@ -49,8 +49,6 @@ const metricsPluginInitializer: LegacyPluginInitializer = ({ Plugin }: LegacyPlu config(Joi: any) { return Joi.object({ enabled: Joi.boolean().default(true), - chartResolution: Joi.number().default(150), - minimumBucketSize: Joi.number().default(10), }).default(); }, } as Legacy.PluginSpecOptions); From 78f1719ed37b1a98b01d6f5d4a1779abeb910642 Mon Sep 17 00:00:00 2001 From: Alexey Antonov Date: Mon, 6 Apr 2020 12:37:40 +0300 Subject: [PATCH 2/8] Fix PR comments --- .../vis_type_timeseries/server/config.ts | 31 +++++++++++++++++++ .../vis_type_timeseries/server/index.ts | 23 +++++++++----- .../vis_type_timeseries/server/plugin.ts | 2 +- 3 files changed, 47 insertions(+), 9 deletions(-) create mode 100644 src/plugins/vis_type_timeseries/server/config.ts diff --git a/src/plugins/vis_type_timeseries/server/config.ts b/src/plugins/vis_type_timeseries/server/config.ts new file mode 100644 index 0000000000000..f4668eff8fa04 --- /dev/null +++ b/src/plugins/vis_type_timeseries/server/config.ts @@ -0,0 +1,31 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import { schema, TypeOf } from '@kbn/config-schema'; + +export const config = schema.object({ + enabled: schema.boolean({ defaultValue: true }), + + /** @deprecated **/ + chartResolution: schema.number({ defaultValue: 150 }), + /** @deprecated **/ + minimumBucketSize: schema.number({ defaultValue: 10 }), +}); + +export type VisTypeTimeseriesConfig = TypeOf; diff --git a/src/plugins/vis_type_timeseries/server/index.ts b/src/plugins/vis_type_timeseries/server/index.ts index fa74b6e965971..f460257caf5e3 100644 --- a/src/plugins/vis_type_timeseries/server/index.ts +++ b/src/plugins/vis_type_timeseries/server/index.ts @@ -17,18 +17,25 @@ * under the License. */ -import { schema, TypeOf } from '@kbn/config-schema'; -import { PluginInitializerContext } from 'src/core/server'; +import { PluginInitializerContext, PluginConfigDescriptor } from 'src/core/server'; +import { VisTypeTimeseriesConfig, config as configSchema } from './config'; import { VisTypeTimeseriesPlugin } from './plugin'; + export { VisTypeTimeseriesSetup, Framework } from './plugin'; -export const config = { - schema: schema.object({ - enabled: schema.boolean({ defaultValue: true }), - }), -}; +export const config: PluginConfigDescriptor = { + deprecations: ({ unused, renameFromRoot }) => [ + // In Kibana v7.8 plugin id was renamed from 'metrics' to 'vis_type_timeseries': + renameFromRoot('metrics.enabled', 'vis_type_timeseries.enabled', true), + renameFromRoot('metrics.chartResolution', 'vis_type_timeseries.chartResolution', true), + renameFromRoot('metrics.minimumBucketSize', 'vis_type_timeseries.minimumBucketSize', true), -export type VisTypeTimeseriesConfig = TypeOf; + // Unused properties which should be removed after releasing Kibana v8.0: + unused('chartResolution'), + unused('minimumBucketSize'), + ], + schema: configSchema, +}; export { ValidationTelemetryServiceSetup } from './validation_telemetry'; diff --git a/src/plugins/vis_type_timeseries/server/plugin.ts b/src/plugins/vis_type_timeseries/server/plugin.ts index 6ef6362c6e37b..05257cb79a75c 100644 --- a/src/plugins/vis_type_timeseries/server/plugin.ts +++ b/src/plugins/vis_type_timeseries/server/plugin.ts @@ -29,7 +29,7 @@ import { } from 'src/core/server'; import { Observable } from 'rxjs'; import { Server } from 'hapi'; -import { VisTypeTimeseriesConfig } from '.'; +import { VisTypeTimeseriesConfig } from './config'; import { getVisData, GetVisData, GetVisDataOptions } from './lib/get_vis_data'; import { ValidationTelemetryService } from './validation_telemetry'; import { UsageCollectionSetup } from '../../usage_collection/server'; From 67d4b3c5b3b6155f1476e5a0e5caa574f69af224 Mon Sep 17 00:00:00 2001 From: Alexey Antonov Date: Mon, 6 Apr 2020 16:51:24 +0300 Subject: [PATCH 3/8] update id of vis_type_timeseries plugin --- src/plugins/vis_type_timeseries/kibana.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/vis_type_timeseries/kibana.json b/src/plugins/vis_type_timeseries/kibana.json index d77f4ac92da16..60ccf0b7e7cd5 100644 --- a/src/plugins/vis_type_timeseries/kibana.json +++ b/src/plugins/vis_type_timeseries/kibana.json @@ -1,5 +1,5 @@ { - "id": "metrics", + "id": "visTypeTimeseries", "version": "8.0.0", "kibanaVersion": "kibana", "server": true, From 5c3fb6897938f62b4fb0855eb8ecf1918bb40963 Mon Sep 17 00:00:00 2001 From: Alexey Antonov Date: Mon, 6 Apr 2020 18:43:17 +0300 Subject: [PATCH 4/8] metrics -> vis_type_timeseries --- src/legacy/core_plugins/vis_type_timeseries/index.ts | 2 +- x-pack/legacy/plugins/rollup/index.ts | 4 ++-- x-pack/legacy/plugins/rollup/kibana.json | 2 +- x-pack/legacy/plugins/rollup/server/plugin.ts | 8 ++++---- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/legacy/core_plugins/vis_type_timeseries/index.ts b/src/legacy/core_plugins/vis_type_timeseries/index.ts index 2768a5b0aa862..b33a7b3046137 100644 --- a/src/legacy/core_plugins/vis_type_timeseries/index.ts +++ b/src/legacy/core_plugins/vis_type_timeseries/index.ts @@ -24,7 +24,7 @@ import { LegacyPluginApi, LegacyPluginInitializer } from '../../../../src/legacy const metricsPluginInitializer: LegacyPluginInitializer = ({ Plugin }: LegacyPluginApi) => new Plugin({ - id: 'metrics', + id: 'vis_type_timeseries', require: ['kibana', 'elasticsearch'], publicDir: resolve(__dirname, 'public'), uiExports: { diff --git a/x-pack/legacy/plugins/rollup/index.ts b/x-pack/legacy/plugins/rollup/index.ts index 2c8363cc397f4..621667f3618b2 100644 --- a/x-pack/legacy/plugins/rollup/index.ts +++ b/x-pack/legacy/plugins/rollup/index.ts @@ -40,7 +40,7 @@ export function rollup(kibana: any) { }, init(server: any) { const { core: coreSetup, plugins } = server.newPlatform.setup; - const { usageCollection, metrics, indexManagement } = plugins; + const { usageCollection, visTypeTimeseries, indexManagement } = plugins; const rollupSetup = (plugins.rollup as unknown) as RollupSetup; @@ -53,7 +53,7 @@ export function rollup(kibana: any) { rollupPluginInstance.setup(coreSetup, { usageCollection, - metrics, + visTypeTimeseries, indexManagement, __LEGACY: { plugins: { diff --git a/x-pack/legacy/plugins/rollup/kibana.json b/x-pack/legacy/plugins/rollup/kibana.json index 3781d59d8c0f3..355ea3af6c685 100644 --- a/x-pack/legacy/plugins/rollup/kibana.json +++ b/x-pack/legacy/plugins/rollup/kibana.json @@ -4,7 +4,7 @@ "requiredPlugins": [ "home", "index_management", - "metrics" + "vis_type_timeseries" ], "optionalPlugins": [ "usageCollection" diff --git a/x-pack/legacy/plugins/rollup/server/plugin.ts b/x-pack/legacy/plugins/rollup/server/plugin.ts index 090cb8a47377a..4ca4574837ddb 100644 --- a/x-pack/legacy/plugins/rollup/server/plugin.ts +++ b/x-pack/legacy/plugins/rollup/server/plugin.ts @@ -38,12 +38,12 @@ export class RollupsServerPlugin implements Plugin { { __LEGACY: serverShim, usageCollection, - metrics, + visTypeTimeseries, indexManagement, }: { __LEGACY: ServerShim; usageCollection?: UsageCollectionSetup; - metrics?: VisTypeTimeseriesSetup; + visTypeTimeseries?: VisTypeTimeseriesSetup; indexManagement?: IndexMgmtSetup; } ) { @@ -83,8 +83,8 @@ export class RollupsServerPlugin implements Plugin { indexManagement.indexDataEnricher.add(rollupDataEnricher); } - if (metrics) { - const { addSearchStrategy } = metrics; + if (visTypeTimeseries) { + const { addSearchStrategy } = visTypeTimeseries; registerRollupSearchStrategy(routeDependencies, addSearchStrategy); } } From b74e4e3feb06af35529f24e5ed2ee88b68d590ae Mon Sep 17 00:00:00 2001 From: Alexey Antonov Date: Mon, 6 Apr 2020 22:25:05 +0300 Subject: [PATCH 5/8] fix wrong plugin id --- x-pack/legacy/plugins/rollup/kibana.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x-pack/legacy/plugins/rollup/kibana.json b/x-pack/legacy/plugins/rollup/kibana.json index 355ea3af6c685..80a62159d3588 100644 --- a/x-pack/legacy/plugins/rollup/kibana.json +++ b/x-pack/legacy/plugins/rollup/kibana.json @@ -4,7 +4,7 @@ "requiredPlugins": [ "home", "index_management", - "vis_type_timeseries" + "visTypeTimeseries" ], "optionalPlugins": [ "usageCollection" From e666e93f2c6ca9eee240d16e23b6da091e743a06 Mon Sep 17 00:00:00 2001 From: Alexey Antonov Date: Tue, 7 Apr 2020 09:47:16 +0300 Subject: [PATCH 6/8] update requiredPliugins for infra/kibana.json --- x-pack/plugins/infra/kibana.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x-pack/plugins/infra/kibana.json b/x-pack/plugins/infra/kibana.json index b8796ad7a358e..a15465a0cde66 100644 --- a/x-pack/plugins/infra/kibana.json +++ b/x-pack/plugins/infra/kibana.json @@ -10,7 +10,7 @@ "home", "data", "dataEnhanced", - "metrics", + "visTypeTimeseries", "alerting", "triggers_actions_ui" ], From f1e04d4d0a0ee7087f795f42e2f8609b4cd159f6 Mon Sep 17 00:00:00 2001 From: Alexey Antonov Date: Tue, 7 Apr 2020 13:26:34 +0300 Subject: [PATCH 7/8] change id --- src/legacy/core_plugins/vis_type_timeseries/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/legacy/core_plugins/vis_type_timeseries/index.ts b/src/legacy/core_plugins/vis_type_timeseries/index.ts index 1fc2b1458444e..b4adbb2e8ea06 100644 --- a/src/legacy/core_plugins/vis_type_timeseries/index.ts +++ b/src/legacy/core_plugins/vis_type_timeseries/index.ts @@ -24,7 +24,7 @@ import { LegacyPluginApi, LegacyPluginInitializer } from '../../../../src/legacy const metricsPluginInitializer: LegacyPluginInitializer = ({ Plugin }: LegacyPluginApi) => new Plugin({ - id: 'vis_type_timeseries', + id: 'visTypeTimeseries', require: ['kibana', 'elasticsearch'], publicDir: resolve(__dirname, 'public'), uiExports: { From d57642339c94e484e51fccbf915d973f441c1e37 Mon Sep 17 00:00:00 2001 From: Alexey Antonov Date: Tue, 7 Apr 2020 16:19:41 +0300 Subject: [PATCH 8/8] update plugin id in infra folder --- .../infra/server/lib/adapters/framework/adapter_types.ts | 2 +- .../server/lib/adapters/framework/kibana_framework_adapter.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/x-pack/plugins/infra/server/lib/adapters/framework/adapter_types.ts b/x-pack/plugins/infra/server/lib/adapters/framework/adapter_types.ts index 8ddd3935bcc33..038fd457fb6c7 100644 --- a/x-pack/plugins/infra/server/lib/adapters/framework/adapter_types.ts +++ b/x-pack/plugins/infra/server/lib/adapters/framework/adapter_types.ts @@ -20,7 +20,7 @@ export interface InfraServerPluginDeps { home: HomeServerPluginSetup; spaces: SpacesPluginSetup; usageCollection: UsageCollectionSetup; - metrics: VisTypeTimeseriesSetup; + visTypeTimeseries: VisTypeTimeseriesSetup; features: FeaturesPluginSetup; apm: APMPluginContract; alerting: AlertingPluginContract; diff --git a/x-pack/plugins/infra/server/lib/adapters/framework/kibana_framework_adapter.ts b/x-pack/plugins/infra/server/lib/adapters/framework/kibana_framework_adapter.ts index b73acd6703054..eda1fbfa5f4ce 100644 --- a/x-pack/plugins/infra/server/lib/adapters/framework/kibana_framework_adapter.ts +++ b/x-pack/plugins/infra/server/lib/adapters/framework/kibana_framework_adapter.ts @@ -245,7 +245,7 @@ export class KibanaFramework { timerange: { min: number; max: number }, filters: any[] ): Promise { - const { getVisData } = this.plugins.metrics; + const { getVisData } = this.plugins.visTypeTimeseries; if (typeof getVisData !== 'function') { throw new Error('TSVB is not available'); }