diff --git a/x-pack/plugins/infra/common/source_configuration/defaults.ts b/x-pack/plugins/infra/common/source_configuration/defaults.ts index a18cec903b60b..ac3724c80d70a 100644 --- a/x-pack/plugins/infra/common/source_configuration/defaults.ts +++ b/x-pack/plugins/infra/common/source_configuration/defaults.ts @@ -16,9 +16,6 @@ export const defaultSourceConfiguration: InfraSourceConfiguration = { type: 'index_name', indexName: LOGS_INDEX_PATTERN, }, - fields: { - message: ['message', '@message'], - }, inventoryDefaultView: '0', metricsExplorerDefaultView: '0', logColumns: [ diff --git a/x-pack/plugins/infra/common/source_configuration/source_configuration.ts b/x-pack/plugins/infra/common/source_configuration/source_configuration.ts index 8881b5fab5f5f..b23c9478e3335 100644 --- a/x-pack/plugins/infra/common/source_configuration/source_configuration.ts +++ b/x-pack/plugins/infra/common/source_configuration/source_configuration.ts @@ -17,29 +17,8 @@ /* eslint-disable @typescript-eslint/no-empty-interface */ -import { omit } from 'lodash'; import * as rt from 'io-ts'; -/** - * Source configuration config file properties. - * These are properties that can appear in the kibana.yml file. - * This is a legacy method of providing properties, and will be deprecated in the future (v 8.0.0). - */ - -export const sourceConfigurationConfigFilePropertiesRT = rt.type({ - sources: rt.type({ - default: rt.partial({ - fields: rt.partial({ - message: rt.array(rt.string), - }), - }), - }), -}); - -export type SourceConfigurationConfigFileProperties = rt.TypeOf< - typeof sourceConfigurationConfigFilePropertiesRT ->; - /** * Log columns */ @@ -104,18 +83,6 @@ export type LogIndexNameReference = rt.TypeOf; export const logIndexReferenceRT = rt.union([logIndexPatternReferenceRT, logIndexNameReferenceRT]); export type LogIndexReference = rt.TypeOf; -/** - * Fields - */ - -const SourceConfigurationFieldsRT = rt.type({ - message: rt.array(rt.string), -}); - -/** - * Properties that represent a full source configuration, which is the result of merging static values with - * saved values. - */ export const SourceConfigurationRT = rt.type({ name: rt.string, description: rt.string, @@ -123,7 +90,6 @@ export const SourceConfigurationRT = rt.type({ logIndices: logIndexReferenceRT, inventoryDefaultView: rt.string, metricsExplorerDefaultView: rt.string, - fields: SourceConfigurationFieldsRT, logColumns: rt.array(SourceConfigurationColumnRuntimeType), anomalyThreshold: rt.number, }); @@ -131,20 +97,8 @@ export const SourceConfigurationRT = rt.type({ /** * Stored source configuration as read from and written to saved objects */ -const SavedSourceConfigurationFieldsRuntimeType = rt.partial( - omit(SourceConfigurationFieldsRT.props, ['message']) -); -export type InfraSavedSourceConfigurationFields = rt.TypeOf< - typeof SavedSourceConfigurationFieldsRuntimeType ->; - -export const SavedSourceConfigurationRuntimeType = rt.intersection([ - rt.partial(omit(SourceConfigurationRT.props, ['fields'])), - rt.partial({ - fields: SavedSourceConfigurationFieldsRuntimeType, - }), -]); +export const SavedSourceConfigurationRuntimeType = rt.partial(SourceConfigurationRT.props); export interface InfraSavedSourceConfiguration extends rt.TypeOf {} @@ -154,10 +108,8 @@ export interface InfraSavedSourceConfiguration * hardcoded defaults. */ -const StaticSourceConfigurationFieldsRuntimeType = rt.partial(SourceConfigurationFieldsRT.props); export const StaticSourceConfigurationRuntimeType = rt.partial({ ...SourceConfigurationRT.props, - fields: StaticSourceConfigurationFieldsRuntimeType, }); export interface InfraStaticSourceConfiguration @@ -167,11 +119,8 @@ export interface InfraStaticSourceConfiguration * Full source configuration type after all cleanup has been done at the edges */ -export type InfraSourceConfigurationFields = rt.TypeOf; - export const SourceConfigurationRuntimeType = rt.type({ ...SourceConfigurationRT.props, - fields: SourceConfigurationFieldsRT, logColumns: rt.array(SourceConfigurationColumnRuntimeType), }); diff --git a/x-pack/plugins/infra/server/deprecations.test.ts b/x-pack/plugins/infra/server/deprecations.test.ts deleted file mode 100644 index 318f1e50d6662..0000000000000 --- a/x-pack/plugins/infra/server/deprecations.test.ts +++ /dev/null @@ -1,86 +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 - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. - */ - -import { getInfraDeprecationsFactory } from './deprecations'; - -describe('Infra plugin deprecations', () => { - describe('Source configuration deprecations', () => { - test('returns no deprecations when all fields are set to the default values', async () => { - const sources = { - getAllSourceConfigurations: () => [ - { - configuration: { - name: 'Default', - fields: { - timestamp: '@timestamp', - tiebreaker: '_doc', - container: 'container.id', - host: 'host.name', - pod: 'kubernetes.pod.uid', - }, - }, - }, - { - configuration: { - name: 'Alternate', - fields: { - timestamp: '@timestamp', - tiebreaker: '_doc', - container: 'container.id', - host: 'host.name', - pod: 'kubernetes.pod.uid', - }, - }, - }, - ], - }; - const getDeprecations = getInfraDeprecationsFactory(sources as any); - const deprecations = await getDeprecations({} as any); - expect(deprecations.length).toBe(0); - }); - }); - test('returns expected deprecations when some fields are not set to default values in one or more source configurations', async () => { - const sources = { - getAllSourceConfigurations: () => [ - { - configuration: { - name: 'Default', - fields: { - timestamp: 'not-@timestamp', - tiebreaker: '_doc', - container: 'not-container.id', - host: 'host.name', - pod: 'not-kubernetes.pod.uid', - }, - }, - }, - { - configuration: { - name: 'Alternate', - fields: { - timestamp: 'not-@timestamp', - tiebreaker: 'not-_doc', - container: 'container.id', - host: 'not-host.name', - pod: 'kubernetes.pod.uid', - }, - }, - }, - ], - }; - const getDeprecations = getInfraDeprecationsFactory(sources as any); - const deprecations = await getDeprecations({} as any); - expect(deprecations.length).toBe(5); - expect( - deprecations.map((d) => - d.title.replace(/Source configuration field "(.*)" is deprecated./, '$1') - ) - ).toEqual( - expect.arrayContaining(['timestamp', 'tiebreaker', 'container ID', 'host name', 'pod ID']) - ); - }); -}); diff --git a/x-pack/plugins/infra/server/deprecations.ts b/x-pack/plugins/infra/server/deprecations.ts deleted file mode 100644 index 93d93f32ff5c0..0000000000000 --- a/x-pack/plugins/infra/server/deprecations.ts +++ /dev/null @@ -1,218 +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 - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. - */ - -import { i18n } from '@kbn/i18n'; -import { get } from 'lodash'; -import { - ConfigDeprecationProvider, - ConfigDeprecation, - DeprecationsDetails, - GetDeprecationsContext, -} from '@kbn/core/server'; -import { - TIMESTAMP_FIELD, - TIEBREAKER_FIELD, - CONTAINER_FIELD, - HOST_FIELD, - POD_FIELD, -} from '../common/constants'; -import { InfraSources } from './lib/sources'; - -const deprecatedFieldMessage = (fieldName: string, defaultValue: string, configNames: string[]) => - i18n.translate('xpack.infra.deprecations.deprecatedFieldDescription', { - defaultMessage: - 'Configuring the "{fieldName}" field has been deprecated and will be removed in 8.0.0. This plugin is designed to work with ECS, and expects this field to have a value of `{defaultValue}`. It has a different value configured in Source {configCount, plural, one {Configuration} other {Configurations}}: {configNames}', - values: { - fieldName, - defaultValue, - configNames: configNames.join(', '), - configCount: configNames.length, - }, - }); - -const DEFAULT_VALUES = { - timestamp: TIMESTAMP_FIELD, - tiebreaker: TIEBREAKER_FIELD, - container: CONTAINER_FIELD, - host: HOST_FIELD, - pod: POD_FIELD, -}; - -const FIELD_DEPRECATION_FACTORIES: Record DeprecationsDetails> = - { - timestamp: (configNames) => ({ - level: 'critical', - title: i18n.translate('xpack.infra.deprecations.timestampFieldTitle', { - defaultMessage: 'Source configuration field "timestamp" is deprecated.', - }), - message: deprecatedFieldMessage( - i18n.translate('xpack.infra.deprecations.timestampFieldName', { - defaultMessage: 'timestamp', - }), - DEFAULT_VALUES.timestamp, - configNames - ), - correctiveActions: { - manualSteps: [ - i18n.translate('xpack.infra.deprecations.timestampAdjustIndexing', { - defaultMessage: 'Adjust your indexing to use "{field}" as a timestamp.', - values: { field: '@timestamp' }, - }), - ], - }, - }), - tiebreaker: (configNames) => ({ - level: 'critical', - title: i18n.translate('xpack.infra.deprecations.tiebreakerFieldTitle', { - defaultMessage: 'Source configuration field "tiebreaker" is deprecated.', - }), - message: deprecatedFieldMessage( - i18n.translate('xpack.infra.deprecations.tiebreakerFieldName', { - defaultMessage: 'tiebreaker', - }), - DEFAULT_VALUES.tiebreaker, - configNames - ), - correctiveActions: { - manualSteps: [ - i18n.translate('xpack.infra.deprecations.tiebreakerAdjustIndexing', { - defaultMessage: 'Adjust your indexing to use "{field}" as a tiebreaker.', - values: { field: '_doc' }, - }), - ], - }, - }), - host: (configNames) => ({ - level: 'critical', - title: i18n.translate('xpack.infra.deprecations.hostnameFieldTitle', { - defaultMessage: 'Source configuration field "host name" is deprecated.', - }), - message: deprecatedFieldMessage( - i18n.translate('xpack.infra.deprecations.hostnameFieldName', { - defaultMessage: 'host name', - }), - DEFAULT_VALUES.host, - configNames - ), - correctiveActions: { - manualSteps: [ - i18n.translate('xpack.infra.deprecations.hostAdjustIndexing', { - defaultMessage: 'Adjust your indexing to identify hosts using "{field}"', - values: { field: 'host.name' }, - }), - ], - }, - }), - pod: (configNames) => ({ - level: 'critical', - title: i18n.translate('xpack.infra.deprecations.podIdFieldTitle', { - defaultMessage: 'Source configuration field "pod ID" is deprecated.', - }), - message: deprecatedFieldMessage( - i18n.translate('xpack.infra.deprecations.podIdFieldName', { defaultMessage: 'pod ID' }), - DEFAULT_VALUES.pod, - configNames - ), - correctiveActions: { - manualSteps: [ - i18n.translate('xpack.infra.deprecations.podAdjustIndexing', { - defaultMessage: 'Adjust your indexing to identify Kubernetes pods using "{field}"', - values: { field: 'kubernetes.pod.uid' }, - }), - ], - }, - }), - container: (configNames) => ({ - level: 'critical', - title: i18n.translate('xpack.infra.deprecations.containerIdFieldTitle', { - defaultMessage: 'Source configuration field "container ID" is deprecated.', - }), - message: deprecatedFieldMessage( - i18n.translate('xpack.infra.deprecations.containerIdFieldName', { - defaultMessage: 'container ID', - }), - DEFAULT_VALUES.container, - configNames - ), - correctiveActions: { - manualSteps: [ - i18n.translate('xpack.infra.deprecations.containerAdjustIndexing', { - defaultMessage: 'Adjust your indexing to identify Docker containers using "{field}"', - values: { field: 'container.id' }, - }), - ], - }, - }), - }; - -export const configDeprecations: ConfigDeprecationProvider = ({ deprecate }) => [ - ...Object.keys(FIELD_DEPRECATION_FACTORIES).map( - (key): ConfigDeprecation => - (completeConfig, rootPath, addDeprecation) => { - const configuredValue = get(completeConfig, `xpack.infra.sources.default.fields.${key}`); - if (typeof configuredValue === 'undefined') { - return completeConfig; - } - addDeprecation({ - title: i18n.translate('xpack.infra.deprecations.deprecatedFieldConfigTitle', { - defaultMessage: '"{fieldKey}" is deprecated.', - values: { - fieldKey: key, - }, - }), - message: i18n.translate('xpack.infra.deprecations.deprecatedFieldConfigDescription', { - defaultMessage: - 'Configuring "xpack.infra.sources.default.fields.{fieldKey}" has been deprecated and will be removed in 8.0.0.', - values: { - fieldKey: key, - }, - }), - level: 'warning', - correctiveActions: { - manualSteps: [ - i18n.translate('xpack.infra.deprecations.removeConfigField', { - defaultMessage: - 'Remove "xpack.infra.sources.default.fields.{fieldKey}" from your Kibana configuration.', - values: { fieldKey: key }, - }), - ], - }, - } as Parameters[0]); - - return completeConfig; - } - ), -]; - -export const getInfraDeprecationsFactory = - (sources: InfraSources) => - async ({ savedObjectsClient }: GetDeprecationsContext) => { - const deprecatedFieldsToSourceConfigMap: Map = new Map(); - const sourceConfigurations = await sources.getAllSourceConfigurations(savedObjectsClient); - - for (const { configuration } of sourceConfigurations) { - const { name, fields } = configuration; - for (const [key, defaultValue] of Object.entries(DEFAULT_VALUES)) { - const configuredValue = Reflect.get(fields, key); - if (configuredValue !== undefined && configuredValue !== defaultValue) { - const affectedConfigNames = deprecatedFieldsToSourceConfigMap.get(key) ?? []; - affectedConfigNames.push(name); - deprecatedFieldsToSourceConfigMap.set(key, affectedConfigNames); - } - } - } - - const deprecations: DeprecationsDetails[] = []; - if (deprecatedFieldsToSourceConfigMap.size > 0) { - for (const [fieldName, affectedConfigNames] of deprecatedFieldsToSourceConfigMap.entries()) { - const deprecationFactory = Reflect.get(FIELD_DEPRECATION_FACTORIES, fieldName); - deprecations.push(deprecationFactory(affectedConfigNames)); - } - } - - return deprecations; - }; diff --git a/x-pack/plugins/infra/server/lib/sources/migrations/create_test_source_configuration.ts b/x-pack/plugins/infra/server/lib/sources/migrations/create_test_source_configuration.ts index bdef0bf02390a..307287dfc4c62 100644 --- a/x-pack/plugins/infra/server/lib/sources/migrations/create_test_source_configuration.ts +++ b/x-pack/plugins/infra/server/lib/sources/migrations/create_test_source_configuration.ts @@ -16,9 +16,6 @@ export const createTestSourceConfiguration = ( attributes: { name: 'TEST CONFIGURATION', description: '', - fields: { - message: ['TEST MESSAGE FIELD'], - }, inventoryDefaultView: '0', metricsExplorerDefaultView: '0', logColumns: [ diff --git a/x-pack/plugins/infra/server/lib/sources/mocks.ts b/x-pack/plugins/infra/server/lib/sources/mocks.ts index 5184d4a4ef334..14d1134d060a4 100644 --- a/x-pack/plugins/infra/server/lib/sources/mocks.ts +++ b/x-pack/plugins/infra/server/lib/sources/mocks.ts @@ -15,7 +15,4 @@ export const createInfraSourcesMock = (): jest.Mocked => ({ createSourceConfiguration: jest.fn(), deleteSourceConfiguration: jest.fn(), updateSourceConfiguration: jest.fn(), - getAllSourceConfigurations: jest.fn(), - getInternalSourceConfiguration: jest.fn(), - defineInternalSourceConfiguration: jest.fn(), }); diff --git a/x-pack/plugins/infra/server/lib/sources/saved_object_references.test.ts b/x-pack/plugins/infra/server/lib/sources/saved_object_references.test.ts index fb550390e25be..4ca2f51cf9385 100644 --- a/x-pack/plugins/infra/server/lib/sources/saved_object_references.test.ts +++ b/x-pack/plugins/infra/server/lib/sources/saved_object_references.test.ts @@ -100,9 +100,6 @@ describe('resolveSavedObjectReferences function', () => { const sourceConfigurationWithIndexPatternReference: InfraSourceConfiguration = { name: 'NAME', description: 'DESCRIPTION', - fields: { - message: ['MESSAGE_FIELD'], - }, logColumns: [], logIndices: { type: 'index_pattern', diff --git a/x-pack/plugins/infra/server/lib/sources/sources.test.ts b/x-pack/plugins/infra/server/lib/sources/sources.test.ts index 5888ea3a6969e..27f232eed3c99 100644 --- a/x-pack/plugins/infra/server/lib/sources/sources.test.ts +++ b/x-pack/plugins/infra/server/lib/sources/sources.test.ts @@ -15,7 +15,7 @@ describe('the InfraSources lib', () => { describe('getSourceConfiguration method', () => { test('returns a source configuration if it exists', async () => { const sourcesLib = new InfraSources({ - config: createMockStaticConfiguration({}), + config: createMockStaticConfiguration(), metricsClient: createMockMetricsDataClient('METRIC_ALIAS'), }); @@ -50,42 +50,9 @@ describe('the InfraSources lib', () => { }); }); - test('adds missing attributes from the static configuration to a source configuration', async () => { - const sourcesLib = new InfraSources({ - config: createMockStaticConfiguration({ - default: { - metricAlias: 'METRIC_ALIAS', - logIndices: { type: 'index_pattern', indexPatternId: 'LOG_ALIAS' }, - }, - }), - metricsClient: createMockMetricsDataClient('METRIC_ALIAS'), - }); - - const request: any = createRequestContext({ - id: 'TEST_ID', - version: 'foo', - type: infraSourceConfigurationSavedObjectName, - updated_at: '2000-01-01T00:00:00.000Z', - attributes: {}, - references: [], - }); - - expect( - await sourcesLib.getSourceConfiguration(request.core.savedObjects.client, 'TEST_ID') - ).toMatchObject({ - id: 'TEST_ID', - version: 'foo', - updatedAt: 946684800000, - configuration: { - metricAlias: 'METRIC_ALIAS', - logIndices: { type: 'index_pattern', indexPatternId: 'LOG_ALIAS' }, - }, - }); - }); - test('adds missing attributes from the default configuration to a source configuration', async () => { const sourcesLib = new InfraSources({ - config: createMockStaticConfiguration({}), + config: createMockStaticConfiguration(), metricsClient: createMockMetricsDataClient(), }); @@ -113,7 +80,7 @@ describe('the InfraSources lib', () => { }); }); -const createMockStaticConfiguration = (sources: any): InfraConfig => ({ +const createMockStaticConfiguration = (): InfraConfig => ({ alerting: { inventory_threshold: { group_by_page_size: 10000, @@ -135,7 +102,6 @@ const createMockStaticConfiguration = (sources: any): InfraConfig => ({ logThresholdAlertRuleEnabled: true, alertsAndRulesDropdownEnabled: true, }, - sources, enabled: true, }); diff --git a/x-pack/plugins/infra/server/lib/sources/sources.ts b/x-pack/plugins/infra/server/lib/sources/sources.ts index 64f7900d57279..e89157d40bc87 100644 --- a/x-pack/plugins/infra/server/lib/sources/sources.ts +++ b/x-pack/plugins/infra/server/lib/sources/sources.ts @@ -6,7 +6,7 @@ */ import { fold, map } from 'fp-ts/lib/Either'; -import { constant, identity } from 'fp-ts/lib/function'; +import { identity } from 'fp-ts/lib/function'; import { pipe } from 'fp-ts/lib/pipeable'; import { failure } from 'io-ts/lib/PathReporter'; import { inRange } from 'lodash'; @@ -21,13 +21,11 @@ import { InfraSource, InfraSourceConfiguration, InfraStaticSourceConfiguration, - SourceConfigurationConfigFileProperties, - sourceConfigurationConfigFilePropertiesRT, } from '../../../common/source_configuration/source_configuration'; import { SourceConfigurationSavedObjectRT } from '.'; import { InfraConfig } from '../..'; import { defaultSourceConfiguration } from './defaults'; -import { AnomalyThresholdRangeError, NotFoundError } from './errors'; +import { AnomalyThresholdRangeError } from './errors'; import { extractSavedObjectReferences, resolveSavedObjectReferences, @@ -43,7 +41,6 @@ interface Libs { export type IInfraSources = Pick; export class InfraSources { - private internalSourceConfigurations: Map = new Map(); private readonly libs: Libs; constructor(libs: Libs) { @@ -54,29 +51,14 @@ export class InfraSources { savedObjectsClient: SavedObjectsClientContract, sourceId: string ): Promise { - const staticDefaultSourceConfiguration = await this.getStaticDefaultSourceConfiguration(); - const savedSourceConfiguration = await this.getInternalSourceConfiguration(sourceId) - .then((internalSourceConfiguration) => ({ - id: sourceId, - version: undefined, - updatedAt: undefined, - origin: 'internal' as 'internal', - configuration: mergeSourceConfiguration( - staticDefaultSourceConfiguration, - internalSourceConfiguration - ), + const savedSourceConfiguration = await this.getSavedSourceConfiguration( + savedObjectsClient, + sourceId + ) + .then((result) => ({ + ...result, + configuration: mergeSourceConfiguration(defaultSourceConfiguration, result.configuration), })) - .catch((err) => - err instanceof NotFoundError - ? this.getSavedSourceConfiguration(savedObjectsClient, sourceId).then((result) => ({ - ...result, - configuration: mergeSourceConfiguration( - staticDefaultSourceConfiguration, - result.configuration - ), - })) - : Promise.reject(err) - ) .catch((err) => SavedObjectsErrorHelpers.isNotFoundError(err) ? Promise.resolve({ @@ -84,7 +66,7 @@ export class InfraSources { version: undefined, updatedAt: undefined, origin: 'fallback' as 'fallback', - configuration: staticDefaultSourceConfiguration, + configuration: defaultSourceConfiguration, }) : Promise.reject(err) ); @@ -107,36 +89,16 @@ export class InfraSources { return sourceConfiguration; } - public async getAllSourceConfigurations(savedObjectsClient: SavedObjectsClientContract) { - const staticDefaultSourceConfiguration = await this.getStaticDefaultSourceConfiguration(); - - const savedSourceConfigurations = await this.getAllSavedSourceConfigurations( - savedObjectsClient - ); - - return savedSourceConfigurations.map((savedSourceConfiguration) => ({ - ...savedSourceConfiguration, - configuration: mergeSourceConfiguration( - staticDefaultSourceConfiguration, - savedSourceConfiguration.configuration - ), - })); - } - public async createSourceConfiguration( savedObjectsClient: SavedObjectsClientContract, sourceId: string, source: InfraSavedSourceConfiguration ) { - const staticDefaultSourceConfiguration = await this.getStaticDefaultSourceConfiguration(); const { anomalyThreshold } = source; if (anomalyThreshold && !inRange(anomalyThreshold, 0, 101)) throw new AnomalyThresholdRangeError('Anomaly threshold must be 1-100'); - const newSourceConfiguration = mergeSourceConfiguration( - staticDefaultSourceConfiguration, - source - ); + const newSourceConfiguration = mergeSourceConfiguration(defaultSourceConfiguration, source); const { attributes, references } = extractSavedObjectReferences(newSourceConfiguration); const createdSourceConfiguration = convertSavedObjectToSavedSourceConfiguration( @@ -154,7 +116,7 @@ export class InfraSources { return { ...createdSourceConfiguration, configuration: mergeSourceConfiguration( - staticDefaultSourceConfiguration, + defaultSourceConfiguration, createdSourceConfiguration.configuration ), }; @@ -172,7 +134,6 @@ export class InfraSources { sourceId: string, sourceProperties: InfraSavedSourceConfiguration ) { - const staticDefaultSourceConfiguration = await this.getStaticDefaultSourceConfiguration(); const { anomalyThreshold } = sourceProperties; if (anomalyThreshold && !inRange(anomalyThreshold, 0, 101)) @@ -210,42 +171,12 @@ export class InfraSources { return { ...updatedSourceConfiguration, configuration: mergeSourceConfiguration( - staticDefaultSourceConfiguration, + defaultSourceConfiguration, updatedSourceConfiguration.configuration ), }; } - public async defineInternalSourceConfiguration( - sourceId: string, - sourceProperties: InfraStaticSourceConfiguration - ) { - this.internalSourceConfigurations.set(sourceId, sourceProperties); - } - - public async getInternalSourceConfiguration(sourceId: string) { - const internalSourceConfiguration = this.internalSourceConfigurations.get(sourceId); - - if (!internalSourceConfiguration) { - throw new NotFoundError( - `Failed to load internal source configuration: no configuration "${sourceId}" found.` - ); - } - - return internalSourceConfiguration; - } - - private async getStaticDefaultSourceConfiguration() { - const staticSourceConfiguration: SourceConfigurationConfigFileProperties['sources']['default'] = - pipe( - sourceConfigurationConfigFilePropertiesRT.decode(this.libs.config), - map(({ sources: { default: defaultConfiguration } }) => defaultConfiguration), - fold(constant({}), identity) - ); - - return mergeSourceConfiguration(defaultSourceConfiguration, staticSourceConfiguration); - } - private async getSavedSourceConfiguration( savedObjectsClient: SavedObjectsClientContract, sourceId: string @@ -257,14 +188,6 @@ export class InfraSources { return convertSavedObjectToSavedSourceConfiguration(savedObject); } - - private async getAllSavedSourceConfigurations(savedObjectsClient: SavedObjectsClientContract) { - const savedObjects = await savedObjectsClient.find({ - type: infraSourceConfigurationSavedObjectName, - }); - - return savedObjects.saved_objects.map(convertSavedObjectToSavedSourceConfiguration); - } } export const mergeSourceConfiguration = ( @@ -275,10 +198,6 @@ export const mergeSourceConfiguration = ( (previousSourceConfiguration, currentSourceConfiguration) => ({ ...previousSourceConfiguration, ...currentSourceConfiguration, - fields: { - ...previousSourceConfiguration.fields, - ...currentSourceConfiguration.fields, - }, }), first ); diff --git a/x-pack/plugins/infra/server/lib/sources/types.ts b/x-pack/plugins/infra/server/lib/sources/types.ts index 7c2448dc48018..22cc5108c35c9 100644 --- a/x-pack/plugins/infra/server/lib/sources/types.ts +++ b/x-pack/plugins/infra/server/lib/sources/types.ts @@ -73,7 +73,6 @@ export const SourceConfigurationSavedObjectAttributesRT = rt.type({ logIndices: logIndexSavedObjectReferenceRT, inventoryDefaultView: rt.string, metricsExplorerDefaultView: rt.string, - fields: rt.record(rt.string, rt.unknown), logColumns: rt.array(SourceConfigurationSavedObjectColumnRT), anomalyThreshold: rt.number, }); diff --git a/x-pack/plugins/infra/server/mocks.ts b/x-pack/plugins/infra/server/mocks.ts index 51845ffed003f..4749ba6e1a3b6 100644 --- a/x-pack/plugins/infra/server/mocks.ts +++ b/x-pack/plugins/infra/server/mocks.ts @@ -17,7 +17,6 @@ import { InfraPluginSetup, InfraPluginStart } from './types'; const createInfraSetupMock = () => { const infraSetupMock: jest.Mocked = { - defineInternalSourceConfiguration: jest.fn(), inventoryViews: createInventoryViewsServiceSetupMock(), metricsExplorerViews: createMetricsExplorerViewsServiceSetupMock(), }; diff --git a/x-pack/plugins/infra/server/plugin.ts b/x-pack/plugins/infra/server/plugin.ts index 6aaef8da00bce..6a2734b399199 100644 --- a/x-pack/plugins/infra/server/plugin.ts +++ b/x-pack/plugins/infra/server/plugin.ts @@ -21,7 +21,6 @@ import { DEFAULT_SPACE_ID } from '@kbn/spaces-plugin/common'; import { GetMetricIndicesOptions } from '@kbn/metrics-data-access-plugin/server'; import { LOGS_FEATURE_ID, METRICS_FEATURE_ID } from '../common/constants'; import { publicConfigKeys } from '../common/plugin_config_types'; -import { configDeprecations, getInfraDeprecationsFactory } from './deprecations'; import { LOGS_FEATURE, METRICS_FEATURE } from './features'; import { initInfraServer } from './infra_server'; import { FrameworkFieldsAdapter } from './lib/adapters/fields/framework_fields_adapter'; @@ -115,7 +114,6 @@ export const config: PluginConfigDescriptor = { }), }), }), - deprecations: configDeprecations, exposeToBrowser: publicConfigKeys, }; @@ -275,13 +273,7 @@ export class InfraServerPlugin // Telemetry UsageCollector.registerUsageCollector(plugins.usageCollection); - // register deprecated source configuration fields - core.deprecations.registerDeprecations({ - getDeprecations: getInfraDeprecationsFactory(sources), - }); - return { - defineInternalSourceConfiguration: sources.defineInternalSourceConfiguration.bind(sources), inventoryViews, metricsExplorerViews, } as InfraPluginSetup; diff --git a/x-pack/plugins/infra/server/routes/snapshot/lib/transform_request_to_metrics_api_request.test.ts b/x-pack/plugins/infra/server/routes/snapshot/lib/transform_request_to_metrics_api_request.test.ts index c019fcbfb909e..cea45fc94bd07 100644 --- a/x-pack/plugins/infra/server/routes/snapshot/lib/transform_request_to_metrics_api_request.test.ts +++ b/x-pack/plugins/infra/server/routes/snapshot/lib/transform_request_to_metrics_api_request.test.ts @@ -46,9 +46,6 @@ const source: InfraSource = { type: 'index_pattern', indexPatternId: 'kibana_index_pattern', }, - fields: { - message: ['message', '@message'], - }, inventoryDefaultView: '0', metricsExplorerDefaultView: '0', logColumns: [ diff --git a/x-pack/plugins/infra/server/services/inventory_views/inventory_views_client.test.ts b/x-pack/plugins/infra/server/services/inventory_views/inventory_views_client.test.ts index 7ec614dbbfe22..89c5b17d3c402 100644 --- a/x-pack/plugins/infra/server/services/inventory_views/inventory_views_client.test.ts +++ b/x-pack/plugins/infra/server/services/inventory_views/inventory_views_client.test.ts @@ -202,9 +202,6 @@ const basicTestSourceConfiguration: InfraSource = { indexPatternId: 'INDEX_PATTERN_ID', }, logColumns: [], - fields: { - message: [], - }, metricAlias: 'METRIC_ALIAS', inventoryDefaultView: '0', metricsExplorerDefaultView: 'METRICS_EXPLORER_DEFAULT_VIEW', diff --git a/x-pack/plugins/infra/server/services/metrics_explorer_views/metrics_explorer_views_client.test.ts b/x-pack/plugins/infra/server/services/metrics_explorer_views/metrics_explorer_views_client.test.ts index 791b7366f086c..6b8de7a724f16 100644 --- a/x-pack/plugins/infra/server/services/metrics_explorer_views/metrics_explorer_views_client.test.ts +++ b/x-pack/plugins/infra/server/services/metrics_explorer_views/metrics_explorer_views_client.test.ts @@ -209,9 +209,6 @@ const basicTestSourceConfiguration: InfraSource = { indexPatternId: 'INDEX_PATTERN_ID', }, logColumns: [], - fields: { - message: [], - }, metricAlias: 'METRIC_ALIAS', inventoryDefaultView: '0', metricsExplorerDefaultView: '0', diff --git a/x-pack/plugins/infra/server/types.ts b/x-pack/plugins/infra/server/types.ts index 8fc3576027d64..c7fde8c4c0bd3 100644 --- a/x-pack/plugins/infra/server/types.ts +++ b/x-pack/plugins/infra/server/types.ts @@ -8,7 +8,6 @@ import type { CoreSetup, CustomRequestHandlerContext } from '@kbn/core/server'; import type { SearchRequestHandlerContext } from '@kbn/data-plugin/server'; import type { MlPluginSetup } from '@kbn/ml-plugin/server'; -import type { InfraStaticSourceConfiguration } from '../common/source_configuration/source_configuration'; import { InfraServerPluginStartDeps } from './lib/adapters/framework'; import { InventoryViewsServiceSetup, InventoryViewsServiceStart } from './services/inventory_views'; import { @@ -22,10 +21,6 @@ export type InfraPluginCoreSetup = CoreSetup void; inventoryViews: InventoryViewsServiceSetup; metricsExplorerViews?: MetricsExplorerViewsServiceSetup; } diff --git a/x-pack/plugins/infra/server/utils/map_source_to_log_view.test.ts b/x-pack/plugins/infra/server/utils/map_source_to_log_view.test.ts index 38db985a28280..168a208f15e60 100644 --- a/x-pack/plugins/infra/server/utils/map_source_to_log_view.test.ts +++ b/x-pack/plugins/infra/server/utils/map_source_to_log_view.test.ts @@ -48,9 +48,6 @@ const basicTestSourceConfiguration: InfraSource = { indexPatternId: 'INDEX_PATTERN_ID', }, logColumns: [], - fields: { - message: [], - }, metricAlias: 'METRIC_ALIAS', inventoryDefaultView: 'INVENTORY_DEFAULT_VIEW', metricsExplorerDefaultView: 'METRICS_EXPLORER_DEFAULT_VIEW', diff --git a/x-pack/plugins/translations/translations/fr-FR.json b/x-pack/plugins/translations/translations/fr-FR.json index 0ad934c20ca2d..079b375a2454e 100644 --- a/x-pack/plugins/translations/translations/fr-FR.json +++ b/x-pack/plugins/translations/translations/fr-FR.json @@ -18334,15 +18334,6 @@ "xpack.infra.analysisSetup.indicesSelectionIndexNotFound": "Aucun index ne correspond au modèle {index}", "xpack.infra.analysisSetup.indicesSelectionNoTimestampField": "Il manque un champ {field} obligatoire dans au moins un index correspondant à {index}.", "xpack.infra.analysisSetup.indicesSelectionTimestampNotValid": "Au moins un index correspondant à {index} comprend un champ appelé {field} sans le type correct.", - "xpack.infra.deprecations.containerAdjustIndexing": "Ajustez votre indexation pour identifier les conteneurs Docker utilisant \"{field}\"", - "xpack.infra.deprecations.deprecatedFieldConfigDescription": "La configuration de \"xpack.infra.sources.default.fields.{fieldKey}\" a été déclassée et sera retirée dans la version 8.0.0.", - "xpack.infra.deprecations.deprecatedFieldConfigTitle": "\"{fieldKey}\" est déclassé.", - "xpack.infra.deprecations.deprecatedFieldDescription": "La configuration du champ \"{fieldName}\" a été déclassée et sera retirée dans la version 8.0.0. Ce plug-in est conçu pour fonctionner avec ECS et attend la valeur \"{defaultValue}\" pour ce champ. Celui-ci présente une valeur différente dans la configuration source {configCount, plural, one {Configuration} many {Configurations} other {Configurations}} : {configNames}", - "xpack.infra.deprecations.hostAdjustIndexing": "Ajustez votre indexation pour identifier les hôtes utilisant \"{field}\"", - "xpack.infra.deprecations.podAdjustIndexing": "Ajustez votre indexation pour identifier les pods Kubernetes utilisant \"{field}\"", - "xpack.infra.deprecations.removeConfigField": "Retirez \"xpack.infra.sources.default.fields.{fieldKey}\" de votre configuration Kibana.", - "xpack.infra.deprecations.tiebreakerAdjustIndexing": "Ajustez votre indexation pour utiliser \"{field}\" comme moyen de départager.", - "xpack.infra.deprecations.timestampAdjustIndexing": "Ajustez votre indexation pour utiliser \"{field}\" comme horodatage.", "xpack.infra.homePage.toolbar.showingLastOneMinuteDataText": "Dernières {duration} de données pour l'heure sélectionnée", "xpack.infra.hostsViewPage.errorOnCreateOrLoadDataview": "Une erreur s’est produite lors de la création d’une vue de données : {metricAlias}. Essayez de recharger la page.", "xpack.infra.hostsViewPage.kpi.subtitle.average.limit": "Moyenne (de {limit} hôtes)", @@ -18494,16 +18485,6 @@ "xpack.infra.chartSection.notEnoughDataPointsToRenderTitle": "Données insuffisantes", "xpack.infra.common.tabBetaBadgeLabel": "Bêta", "xpack.infra.configureSourceActionLabel": "Modifier la configuration de la source", - "xpack.infra.deprecations.containerIdFieldName": "ID de conteneur", - "xpack.infra.deprecations.containerIdFieldTitle": "Le champ de configuration source \"ID de conteneur\" est déclassé.", - "xpack.infra.deprecations.hostnameFieldName": "nom d'hôte", - "xpack.infra.deprecations.hostnameFieldTitle": "Le champ de configuration source \"nom d’hôte\" est déclassé.", - "xpack.infra.deprecations.podIdFieldName": "ID de pod", - "xpack.infra.deprecations.podIdFieldTitle": "Le champ de configuration source \"ID de pod\" est déclassé.", - "xpack.infra.deprecations.tiebreakerFieldName": "Départage", - "xpack.infra.deprecations.tiebreakerFieldTitle": "Le champ de configuration source \"départage\" est déclassé.", - "xpack.infra.deprecations.timestampFieldName": "timestamp", - "xpack.infra.deprecations.timestampFieldTitle": "Le champ de configuration source \"horodatage\" est déclassé.", "xpack.infra.durationUnits.days.plural": "jours", "xpack.infra.durationUnits.days.singular": "jour", "xpack.infra.durationUnits.hours.plural": "heures", diff --git a/x-pack/plugins/translations/translations/ja-JP.json b/x-pack/plugins/translations/translations/ja-JP.json index 00107f55b3268..2f7f25303be7f 100644 --- a/x-pack/plugins/translations/translations/ja-JP.json +++ b/x-pack/plugins/translations/translations/ja-JP.json @@ -18348,15 +18348,6 @@ "xpack.infra.analysisSetup.indicesSelectionIndexNotFound": "インデックスがパターン{index}と一致しません", "xpack.infra.analysisSetup.indicesSelectionNoTimestampField": "{index}と一致する1つ以上のインデックスに、必須フィールド{field}がありません。", "xpack.infra.analysisSetup.indicesSelectionTimestampNotValid": "{index}と一致する1つ以上のインデックスに、正しい型がない{field}フィールドがあります。", - "xpack.infra.deprecations.containerAdjustIndexing": "インデックスを調整し、\"{field}\"を使用してDockerコンテナーを特定", - "xpack.infra.deprecations.deprecatedFieldConfigDescription": "「xpack.infra.sources.default.fields.{fieldKey}」の構成は廃止予定であり、8.0.0で削除されます。", - "xpack.infra.deprecations.deprecatedFieldConfigTitle": "\"{fieldKey}\"は廃止予定です。", - "xpack.infra.deprecations.deprecatedFieldDescription": "\"{fieldName}\"フィールドの構成は廃止予定です。8.0.0で削除されます。このプラグインはECSと連動するように設計され、このフィールドには`{defaultValue}`の値が入ることが想定されています。ソース{configCount, plural, other {構成}}で設定されている値が異なります:{configNames}", - "xpack.infra.deprecations.hostAdjustIndexing": "インデックスを調整し、\"{field}\"を使用してホストを特定", - "xpack.infra.deprecations.podAdjustIndexing": "インデックスを調整し、\"{field}\"を使用してKubernetesポッドを特定", - "xpack.infra.deprecations.removeConfigField": "「xpack.infra.sources.default.fields.{fieldKey}」をKibana構成から削除します。", - "xpack.infra.deprecations.tiebreakerAdjustIndexing": "インデックスを調整し、\"{field}\"をタイブレーカーとして使用します。", - "xpack.infra.deprecations.timestampAdjustIndexing": "インデックスを調整し、\"{field}\"をタイムスタンプとして使用します。", "xpack.infra.homePage.toolbar.showingLastOneMinuteDataText": "指定期間のデータの最後の{duration}", "xpack.infra.hostsViewPage.errorOnCreateOrLoadDataview": "データビューの作成中にエラーが発生しました:{metricAlias}。ページを再読み込みしてください。", "xpack.infra.hostsViewPage.kpi.subtitle.average.limit": "({limit}ホストの)平均", @@ -18508,16 +18499,6 @@ "xpack.infra.chartSection.notEnoughDataPointsToRenderTitle": "データが不十分です", "xpack.infra.common.tabBetaBadgeLabel": "ベータ", "xpack.infra.configureSourceActionLabel": "ソース構成を変更", - "xpack.infra.deprecations.containerIdFieldName": "コンテナーID", - "xpack.infra.deprecations.containerIdFieldTitle": "ソース構成フィールド[コンテナーID]は廃止予定です。", - "xpack.infra.deprecations.hostnameFieldName": "ホスト名", - "xpack.infra.deprecations.hostnameFieldTitle": "ソース構成フィールド[ホスト名]は廃止予定です。", - "xpack.infra.deprecations.podIdFieldName": "ポッド ID", - "xpack.infra.deprecations.podIdFieldTitle": "ソース構成フィールド[ポッドID]は廃止予定です。", - "xpack.infra.deprecations.tiebreakerFieldName": "タイブレーカー", - "xpack.infra.deprecations.tiebreakerFieldTitle": "ソース構成フィールド[タイブレーカー]は廃止予定です。", - "xpack.infra.deprecations.timestampFieldName": "タイムスタンプ", - "xpack.infra.deprecations.timestampFieldTitle": "ソース構成フィールド[タイムスタンプ]は廃止予定です。", "xpack.infra.durationUnits.days.plural": "日", "xpack.infra.durationUnits.days.singular": "日", "xpack.infra.durationUnits.hours.plural": "時間", diff --git a/x-pack/plugins/translations/translations/zh-CN.json b/x-pack/plugins/translations/translations/zh-CN.json index 4a70556a8a4d1..b6a661dc22716 100644 --- a/x-pack/plugins/translations/translations/zh-CN.json +++ b/x-pack/plugins/translations/translations/zh-CN.json @@ -18348,15 +18348,6 @@ "xpack.infra.analysisSetup.indicesSelectionIndexNotFound": "没有索引匹配模式 {index}", "xpack.infra.analysisSetup.indicesSelectionNoTimestampField": "匹配 {index} 的索引至少有一个缺少必需字段 {field}。", "xpack.infra.analysisSetup.indicesSelectionTimestampNotValid": "匹配 {index} 的索引至少有一个具有称作 {field} 且类型不正确的字段。", - "xpack.infra.deprecations.containerAdjustIndexing": "调整索引以使用“{field}”标识 Docker 容器", - "xpack.infra.deprecations.deprecatedFieldConfigDescription": "配置“xpack.infra.sources.default.fields.{fieldKey}”已过时,将在 8.0.0 中移除。", - "xpack.infra.deprecations.deprecatedFieldConfigTitle": "“{fieldKey}”已过时。", - "xpack.infra.deprecations.deprecatedFieldDescription": "配置“{fieldName}”字段已过时,将在 8.0.0 中移除。此插件专用于 ECS,预计该字段的值为 `{defaultValue}`。其在以下源{configCount, plural, other {配置}}中配置了不同的值:{configNames}", - "xpack.infra.deprecations.hostAdjustIndexing": "调整索引以使用“{field}”标识主机", - "xpack.infra.deprecations.podAdjustIndexing": "调整索引以使用“{field}”标识 Kubernetes pod", - "xpack.infra.deprecations.removeConfigField": "从 Kibana 配置中移除“xpack.infra.sources.default.fields.{fieldKey}”。", - "xpack.infra.deprecations.tiebreakerAdjustIndexing": "调整索引以将“{field}”用作决胜属性。", - "xpack.infra.deprecations.timestampAdjustIndexing": "调整索引以将“{field}”用作时间戳。", "xpack.infra.homePage.toolbar.showingLastOneMinuteDataText": "选定时间过去 {duration}的数据", "xpack.infra.hostsViewPage.errorOnCreateOrLoadDataview": "尝试创建以下数据视图时出错:{metricAlias}。尝试重新加载该页面。", "xpack.infra.hostsViewPage.kpi.subtitle.average.limit": "平均值(属于 {limit} 台主机)", @@ -18508,16 +18499,6 @@ "xpack.infra.chartSection.notEnoughDataPointsToRenderTitle": "没有足够的数据", "xpack.infra.common.tabBetaBadgeLabel": "公测版", "xpack.infra.configureSourceActionLabel": "更改源配置", - "xpack.infra.deprecations.containerIdFieldName": "容器 ID", - "xpack.infra.deprecations.containerIdFieldTitle": "源配置字段“容器 ID”已过时。", - "xpack.infra.deprecations.hostnameFieldName": "主机名", - "xpack.infra.deprecations.hostnameFieldTitle": "源配置字段“主机名”已过时。", - "xpack.infra.deprecations.podIdFieldName": "Pod ID", - "xpack.infra.deprecations.podIdFieldTitle": "源配置字段“Pod ID”已过时。", - "xpack.infra.deprecations.tiebreakerFieldName": "决胜属性", - "xpack.infra.deprecations.tiebreakerFieldTitle": "源配置字段“决胜属性”已过时。", - "xpack.infra.deprecations.timestampFieldName": "时间戳", - "xpack.infra.deprecations.timestampFieldTitle": "源配置字段“时间戳”已过时。", "xpack.infra.durationUnits.days.plural": "天", "xpack.infra.durationUnits.days.singular": "天", "xpack.infra.durationUnits.hours.plural": "小时", diff --git a/x-pack/test/api_integration/apis/metrics_ui/inventory_threshold_alert.ts b/x-pack/test/api_integration/apis/metrics_ui/inventory_threshold_alert.ts index 692672b29c09c..f76dd0e63fd87 100644 --- a/x-pack/test/api_integration/apis/metrics_ui/inventory_threshold_alert.ts +++ b/x-pack/test/api_integration/apis/metrics_ui/inventory_threshold_alert.ts @@ -43,9 +43,6 @@ export default function ({ getService }: FtrProviderContext) { inventoryDefaultView: 'default', metricsExplorerDefaultView: 'default', anomalyThreshold: 70, - fields: { - message: ['message'], - }, logColumns: [ { timestampColumn: { diff --git a/x-pack/test/api_integration/apis/metrics_ui/metric_threshold_alert.ts b/x-pack/test/api_integration/apis/metrics_ui/metric_threshold_alert.ts index fc91d64e534bc..18d46a45ded9e 100644 --- a/x-pack/test/api_integration/apis/metrics_ui/metric_threshold_alert.ts +++ b/x-pack/test/api_integration/apis/metrics_ui/metric_threshold_alert.ts @@ -56,9 +56,6 @@ export default function ({ getService }: FtrProviderContext) { inventoryDefaultView: 'default', metricsExplorerDefaultView: 'default', anomalyThreshold: 70, - fields: { - message: ['message'], - }, logColumns: [ { timestampColumn: {