diff --git a/x-pack/plugins/event_log/server/es/context.test.ts b/x-pack/plugins/event_log/server/es/context.test.ts index f30b71c99a043..5f26399618e38 100644 --- a/x-pack/plugins/event_log/server/es/context.test.ts +++ b/x-pack/plugins/event_log/server/es/context.test.ts @@ -25,6 +25,7 @@ describe('createEsContext', () => { logger, clusterClientPromise: Promise.resolve(clusterClient), indexNameRoot: 'test0', + kibanaVersion: '1.2.3', }); expect(context.initialized).toBeFalsy(); @@ -38,6 +39,7 @@ describe('createEsContext', () => { logger, clusterClientPromise: Promise.resolve(clusterClient), indexNameRoot: 'test-index', + kibanaVersion: '1.2.3', }); const esNames = context.esNames; @@ -57,6 +59,7 @@ describe('createEsContext', () => { logger, clusterClientPromise: Promise.resolve(clusterClient), indexNameRoot: 'test1', + kibanaVersion: '1.2.3', }); clusterClient.callAsInternalUser.mockResolvedValue(false); @@ -74,6 +77,7 @@ describe('createEsContext', () => { logger, clusterClientPromise: Promise.resolve(clusterClient), indexNameRoot: 'test2', + kibanaVersion: '1.2.3', }); clusterClient.callAsInternalUser.mockResolvedValue(true); context.initialize(); @@ -98,6 +102,7 @@ describe('createEsContext', () => { logger, clusterClientPromise: Promise.resolve(clusterClient), indexNameRoot: 'test2', + kibanaVersion: '1.2.3', }); context.initialize(); const success = await context.waitTillReady(); diff --git a/x-pack/plugins/event_log/server/es/context.ts b/x-pack/plugins/event_log/server/es/context.ts index d7f67620e7968..c1777d6979c5c 100644 --- a/x-pack/plugins/event_log/server/es/context.ts +++ b/x-pack/plugins/event_log/server/es/context.ts @@ -36,6 +36,7 @@ export interface EsContextCtorParams { logger: Logger; clusterClientPromise: Promise; indexNameRoot: string; + kibanaVersion: string; } class EsContextImpl implements EsContext { @@ -47,7 +48,7 @@ class EsContextImpl implements EsContext { constructor(params: EsContextCtorParams) { this.logger = params.logger; - this.esNames = getEsNames(params.indexNameRoot); + this.esNames = getEsNames(params.indexNameRoot, params.kibanaVersion); this.readySignal = createReadySignal(); this.initialized = false; this.esAdapter = new ClusterClientAdapter({ diff --git a/x-pack/plugins/event_log/server/es/documents.test.ts b/x-pack/plugins/event_log/server/es/documents.test.ts index 2feb6e3b84f91..df0689ba0b63c 100644 --- a/x-pack/plugins/event_log/server/es/documents.test.ts +++ b/x-pack/plugins/event_log/server/es/documents.test.ts @@ -18,7 +18,8 @@ describe('getIlmPolicy()', () => { }); describe('getIndexTemplate()', () => { - const esNames = getEsNames('XYZ'); + const kibanaVersion = '1.2.3'; + const esNames = getEsNames('XYZ', kibanaVersion); test('returns the correct details of the index template', () => { const indexTemplate = getIndexTemplate(esNames); diff --git a/x-pack/plugins/event_log/server/es/names.test.ts b/x-pack/plugins/event_log/server/es/names.test.ts index bc6a4c9a52fac..b77ab30c754b7 100644 --- a/x-pack/plugins/event_log/server/es/names.test.ts +++ b/x-pack/plugins/event_log/server/es/names.test.ts @@ -13,20 +13,22 @@ jest.mock('../lib/../../../../package.json', () => ({ describe('getEsNames()', () => { test('works as expected', () => { const base = 'XYZ'; - const version = '1.2.3'; - const esNames = getEsNames(base); + const kibanaVersion = '1.2.3'; + const esNames = getEsNames(base, kibanaVersion); expect(esNames.base).toEqual(base); - expect(esNames.alias).toEqual(`${base}-event-log-${version}`); + expect(esNames.alias).toEqual(`${base}-event-log-${kibanaVersion}`); expect(esNames.ilmPolicy).toEqual(`${base}-event-log-policy`); expect(esNames.indexPattern).toEqual(`${base}-event-log-*`); - expect(esNames.indexPatternWithVersion).toEqual(`${base}-event-log-${version}-*`); - expect(esNames.initialIndex).toEqual(`${base}-event-log-${version}-000001`); - expect(esNames.indexTemplate).toEqual(`${base}-event-log-${version}-template`); + expect(esNames.indexPatternWithVersion).toEqual(`${base}-event-log-${kibanaVersion}-*`); + expect(esNames.initialIndex).toEqual(`${base}-event-log-${kibanaVersion}-000001`); + expect(esNames.indexTemplate).toEqual(`${base}-event-log-${kibanaVersion}-template`); }); test('ilm policy name does not contain dot prefix', () => { const base = '.XYZ'; - const esNames = getEsNames(base); + const kibanaVersion = '1.2.3'; + + const esNames = getEsNames(base, kibanaVersion); expect(esNames.ilmPolicy).toEqual('XYZ-event-log-policy'); }); }); diff --git a/x-pack/plugins/event_log/server/es/names.ts b/x-pack/plugins/event_log/server/es/names.ts index 8cd56a89d3fbe..363b67814efe7 100644 --- a/x-pack/plugins/event_log/server/es/names.ts +++ b/x-pack/plugins/event_log/server/es/names.ts @@ -4,10 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import xPackage from '../../../../package.json'; - const EVENT_LOG_NAME_SUFFIX = `-event-log`; -const EVENT_LOG_VERSION_SUFFIX = `-${xPackage.version}`; export interface EsNames { base: string; @@ -19,7 +16,8 @@ export interface EsNames { indexTemplate: string; } -export function getEsNames(baseName: string): EsNames { +export function getEsNames(baseName: string, kibanaVersion: string): EsNames { + const EVENT_LOG_VERSION_SUFFIX = `-${kibanaVersion.toLocaleLowerCase()}`; const eventLogName = `${baseName}${EVENT_LOG_NAME_SUFFIX}`; const eventLogNameWithVersion = `${eventLogName}${EVENT_LOG_VERSION_SUFFIX}`; const eventLogPolicyName = `${ diff --git a/x-pack/plugins/event_log/server/plugin.ts b/x-pack/plugins/event_log/server/plugin.ts index 6471db7d5dd69..03125f3005c3d 100644 --- a/x-pack/plugins/event_log/server/plugin.ts +++ b/x-pack/plugins/event_log/server/plugin.ts @@ -55,12 +55,14 @@ export class Plugin implements CorePlugin; private eventLogClientService?: EventLogClientService; private savedObjectProviderRegistry: SavedObjectProviderRegistry; + private kibanaVersion: PluginInitializerContext['env']['packageInfo']['version']; constructor(private readonly context: PluginInitializerContext) { this.systemLogger = this.context.logger.get(); this.config$ = this.context.config.create(); this.globalConfig$ = this.context.config.legacy.globalConfig$; this.savedObjectProviderRegistry = new SavedObjectProviderRegistry(); + this.kibanaVersion = this.context.env.packageInfo.version; } async setup(core: CoreSetup): Promise { @@ -78,6 +80,7 @@ export class Plugin implements CorePlugin elasticsearch.legacy.client), + kibanaVersion: this.kibanaVersion, }); this.eventLogService = new EventLogService({ diff --git a/x-pack/plugins/event_log/tsconfig.json b/x-pack/plugins/event_log/tsconfig.json new file mode 100644 index 0000000000000..9b7cde10da3d6 --- /dev/null +++ b/x-pack/plugins/event_log/tsconfig.json @@ -0,0 +1,22 @@ +{ + "extends": "../../../tsconfig.base.json", + "compilerOptions": { + "composite": true, + "outDir": "./target/types", + "emitDeclarationOnly": true, + "declaration": true, + "declarationMap": true + }, + "include": [ + "server/**/*", + "scripts/**/*", + "generated/*", + // have to declare *.json explicitly due to https://github.com/microsoft/TypeScript/issues/25636 + "generated/*.json", + "common/*" + ], + "references": [ + { "path": "../../../src/core/tsconfig.json" }, + { "path": "../spaces/tsconfig.json" } + ] +} diff --git a/x-pack/test/tsconfig.json b/x-pack/test/tsconfig.json index eac9d92884028..d977730181e89 100644 --- a/x-pack/test/tsconfig.json +++ b/x-pack/test/tsconfig.json @@ -42,6 +42,7 @@ { "path": "../plugins/global_search_providers/tsconfig.json" }, { "path": "../plugins/features/tsconfig.json" }, { "path": "../plugins/embeddable_enhanced/tsconfig.json" }, + { "path": "../plugins/event_log/tsconfig.json"}, { "path": "../plugins/licensing/tsconfig.json" }, { "path": "../plugins/task_manager/tsconfig.json" }, { "path": "../plugins/telemetry_collection_xpack/tsconfig.json" }, diff --git a/x-pack/tsconfig.json b/x-pack/tsconfig.json index 01d9bcf9537ec..56444ed80bc90 100644 --- a/x-pack/tsconfig.json +++ b/x-pack/tsconfig.json @@ -13,6 +13,7 @@ "plugins/graph/**/*", "plugins/features/**/*", "plugins/embeddable_enhanced/**/*", + "plugins/event_log/**/*", "plugins/licensing/**/*", "plugins/searchprofiler/**/*", "plugins/security_solution/cypress/**/*", @@ -73,6 +74,7 @@ { "path": "./plugins/features/tsconfig.json" }, { "path": "./plugins/graph/tsconfig.json" }, { "path": "./plugins/embeddable_enhanced/tsconfig.json" }, + { "path": "./plugins/event_log/tsconfig.json"}, { "path": "./plugins/licensing/tsconfig.json" }, { "path": "./plugins/searchprofiler/tsconfig.json" }, { "path": "./plugins/task_manager/tsconfig.json" }, diff --git a/x-pack/tsconfig.refs.json b/x-pack/tsconfig.refs.json index 4352d2993002a..a0a9eda0aaf23 100644 --- a/x-pack/tsconfig.refs.json +++ b/x-pack/tsconfig.refs.json @@ -8,6 +8,7 @@ { "path": "./plugins/data_enhanced/tsconfig.json" }, { "path": "./plugins/global_search/tsconfig.json" }, { "path": "./plugins/global_search_providers/tsconfig.json" }, + { "path": "./plugins/event_log/tsconfig.json"}, { "path": "./plugins/features/tsconfig.json" }, { "path": "./plugins/graph/tsconfig.json" }, { "path": "./plugins/embeddable_enhanced/tsconfig.json" },