Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions x-pack/plugins/event_log/server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { Observable } from 'rxjs';
import { first } from 'rxjs/operators';
import {
CoreSetup,
Expand All @@ -12,6 +13,7 @@ import {
Plugin as CorePlugin,
PluginInitializerContext,
ClusterClient,
SharedGlobalConfig,
} from 'src/core/server';

import { IEventLogConfig, IEventLogService, IEventLogger, IEventLogConfig$ } from './types';
Expand All @@ -20,9 +22,6 @@ import { createEsContext, EsContext } from './es';

export type PluginClusterClient = Pick<ClusterClient, 'callAsInternalUser' | 'asScoped'>;

// TODO - figure out how to get ${kibana.index} for `.kibana`
const KIBANA_INDEX = '.kibana';

const PROVIDER = 'event_log';
const ACTIONS = {
starting: 'starting',
Expand All @@ -35,21 +34,26 @@ export class Plugin implements CorePlugin<IEventLogService> {
private eventLogService?: IEventLogService;
private esContext?: EsContext;
private eventLogger?: IEventLogger;
private globalConfig$: Observable<SharedGlobalConfig>;

constructor(private readonly context: PluginInitializerContext) {
this.systemLogger = this.context.logger.get();
this.config$ = this.context.config.create<IEventLogConfig>();
this.globalConfig$ = this.context.config.legacy.globalConfig$;
}

async setup(core: CoreSetup): Promise<IEventLogService> {
const globalConfig = await this.globalConfig$.pipe(first()).toPromise();
const kibanaIndex = globalConfig.kibana.index;

this.systemLogger.debug('setting up plugin');

const config = await this.config$.pipe(first()).toPromise();

this.esContext = createEsContext({
logger: this.systemLogger,
// TODO: get index prefix from config.get(kibana.index)
indexNameRoot: KIBANA_INDEX,
indexNameRoot: kibanaIndex,
clusterClient: core.elasticsearch.adminClient,
});

Expand Down