2020-01-28 02:10:34 +01:00
|
|
|
/*
|
|
|
|
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
2021-02-04 03:12:39 +01:00
|
|
|
* 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.
|
2020-01-28 02:10:34 +01:00
|
|
|
*/
|
2020-08-26 22:00:00 +02:00
|
|
|
|
|
|
|
import { i18n } from '@kbn/i18n';
|
2021-06-28 18:48:32 +02:00
|
|
|
import { BehaviorSubject, from } from 'rxjs';
|
|
|
|
import { map } from 'rxjs/operators';
|
|
|
|
import { ConfigSchema } from '.';
|
2020-06-08 09:07:35 +02:00
|
|
|
import {
|
2021-06-28 18:48:32 +02:00
|
|
|
AppDeepLink,
|
2020-06-08 09:07:35 +02:00
|
|
|
AppMountParameters,
|
2021-06-28 18:48:32 +02:00
|
|
|
AppNavLinkStatus,
|
2020-09-17 13:36:58 +02:00
|
|
|
AppUpdater,
|
2020-06-08 09:07:35 +02:00
|
|
|
CoreSetup,
|
2021-04-18 16:40:54 +02:00
|
|
|
CoreStart,
|
2020-06-08 09:07:35 +02:00
|
|
|
DEFAULT_APP_CATEGORIES,
|
|
|
|
Plugin as PluginClass,
|
|
|
|
PluginInitializerContext,
|
|
|
|
} from '../../../../src/core/public';
|
2021-04-18 16:40:54 +02:00
|
|
|
import type {
|
|
|
|
DataPublicPluginSetup,
|
|
|
|
DataPublicPluginStart,
|
|
|
|
} from '../../../../src/plugins/data/public';
|
2021-07-22 10:14:43 +02:00
|
|
|
import type { DiscoverStart } from '../../../../src/plugins/discover/public';
|
2021-04-15 18:25:50 +02:00
|
|
|
import type {
|
|
|
|
HomePublicPluginSetup,
|
|
|
|
HomePublicPluginStart,
|
|
|
|
} from '../../../../src/plugins/home/public';
|
2021-06-28 18:48:32 +02:00
|
|
|
import { CasesUiStart } from '../../cases/public';
|
2021-04-15 18:25:50 +02:00
|
|
|
import type { LensPublicStart } from '../../lens/public';
|
2021-06-28 18:48:32 +02:00
|
|
|
import {
|
|
|
|
TriggersAndActionsUIPublicPluginSetup,
|
|
|
|
TriggersAndActionsUIPublicPluginStart,
|
|
|
|
} from '../../triggers_actions_ui/public';
|
|
|
|
import { observabilityAppId, observabilityFeatureId } from '../common';
|
|
|
|
import { createLazyObservabilityPageTemplate } from './components/shared';
|
2021-04-18 16:40:54 +02:00
|
|
|
import { registerDataHandler } from './data_handler';
|
2021-05-13 17:12:47 +02:00
|
|
|
import { createObservabilityRuleTypeRegistry } from './rules/create_observability_rule_type_registry';
|
2021-06-28 18:48:32 +02:00
|
|
|
import { createCallObservabilityApi } from './services/call_observability_api';
|
|
|
|
import { createNavigationRegistry, NavigationEntry } from './services/navigation_registry';
|
|
|
|
import { updateGlobalNavigation } from './update_global_navigation';
|
2020-01-28 02:10:34 +01:00
|
|
|
|
2021-04-15 18:25:50 +02:00
|
|
|
export type ObservabilityPublicSetup = ReturnType<Plugin['setup']>;
|
2020-06-15 08:46:36 +02:00
|
|
|
|
2021-03-26 14:48:08 +01:00
|
|
|
export interface ObservabilityPublicPluginsSetup {
|
2020-10-06 13:29:15 +02:00
|
|
|
data: DataPublicPluginSetup;
|
2021-05-13 17:12:47 +02:00
|
|
|
triggersActionsUi: TriggersAndActionsUIPublicPluginSetup;
|
2021-03-26 14:48:08 +01:00
|
|
|
home?: HomePublicPluginSetup;
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface ObservabilityPublicPluginsStart {
|
2021-06-11 00:39:27 +02:00
|
|
|
cases: CasesUiStart;
|
2021-03-26 14:48:08 +01:00
|
|
|
home?: HomePublicPluginStart;
|
2021-05-13 17:12:47 +02:00
|
|
|
triggersActionsUi: TriggersAndActionsUIPublicPluginStart;
|
2021-03-26 14:48:08 +01:00
|
|
|
data: DataPublicPluginStart;
|
|
|
|
lens: LensPublicStart;
|
2021-07-22 10:14:43 +02:00
|
|
|
discover: DiscoverStart;
|
2020-08-26 22:00:00 +02:00
|
|
|
}
|
|
|
|
|
2021-05-27 16:58:15 +02:00
|
|
|
export type ObservabilityPublicStart = ReturnType<Plugin['start']>;
|
2020-06-30 19:56:35 +02:00
|
|
|
|
2021-03-26 14:48:08 +01:00
|
|
|
export class Plugin
|
|
|
|
implements
|
|
|
|
PluginClass<
|
|
|
|
ObservabilityPublicSetup,
|
|
|
|
ObservabilityPublicStart,
|
|
|
|
ObservabilityPublicPluginsSetup,
|
|
|
|
ObservabilityPublicPluginsStart
|
|
|
|
> {
|
2020-09-17 13:36:58 +02:00
|
|
|
private readonly appUpdater$ = new BehaviorSubject<AppUpdater>(() => ({}));
|
2021-05-27 16:58:15 +02:00
|
|
|
private readonly navigationRegistry = createNavigationRegistry();
|
2020-09-17 13:36:58 +02:00
|
|
|
|
2021-06-28 18:48:32 +02:00
|
|
|
// Define deep links as constant and hidden. Whether they are shown or hidden
|
|
|
|
// in the global navigation will happen in `updateGlobalNavigation`.
|
|
|
|
private readonly deepLinks: AppDeepLink[] = [
|
|
|
|
{
|
|
|
|
id: 'alerts',
|
|
|
|
title: i18n.translate('xpack.observability.alertsLinkTitle', {
|
|
|
|
defaultMessage: 'Alerts',
|
|
|
|
}),
|
|
|
|
order: 8001,
|
|
|
|
path: '/alerts',
|
|
|
|
navLinkStatus: AppNavLinkStatus.hidden,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 'cases',
|
|
|
|
title: i18n.translate('xpack.observability.casesLinkTitle', {
|
|
|
|
defaultMessage: 'Cases',
|
|
|
|
}),
|
|
|
|
order: 8002,
|
|
|
|
path: '/cases',
|
|
|
|
navLinkStatus: AppNavLinkStatus.hidden,
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
2021-04-20 05:09:51 +02:00
|
|
|
constructor(private readonly initializerContext: PluginInitializerContext<ConfigSchema>) {
|
|
|
|
this.initializerContext = initializerContext;
|
|
|
|
}
|
2020-06-08 09:07:35 +02:00
|
|
|
|
2021-03-26 14:48:08 +01:00
|
|
|
public setup(
|
2021-05-27 16:58:15 +02:00
|
|
|
coreSetup: CoreSetup<ObservabilityPublicPluginsStart, ObservabilityPublicStart>,
|
2021-04-15 18:25:50 +02:00
|
|
|
pluginsSetup: ObservabilityPublicPluginsSetup
|
2021-03-26 14:48:08 +01:00
|
|
|
) {
|
2021-03-23 13:57:56 +01:00
|
|
|
const category = DEFAULT_APP_CATEGORIES.observability;
|
2021-03-25 14:29:51 +01:00
|
|
|
const euiIconType = 'logoObservability';
|
2021-04-20 05:09:51 +02:00
|
|
|
const config = this.initializerContext.config.get();
|
2021-04-15 18:25:50 +02:00
|
|
|
|
|
|
|
createCallObservabilityApi(coreSetup.http);
|
|
|
|
|
2021-05-13 17:12:47 +02:00
|
|
|
const observabilityRuleTypeRegistry = createObservabilityRuleTypeRegistry(
|
2021-07-27 19:03:00 +02:00
|
|
|
pluginsSetup.triggersActionsUi.ruleTypeRegistry
|
2021-05-13 17:12:47 +02:00
|
|
|
);
|
2021-04-15 18:25:50 +02:00
|
|
|
|
2021-03-23 13:57:56 +01:00
|
|
|
const mount = async (params: AppMountParameters<unknown>) => {
|
|
|
|
// Load application bundle
|
|
|
|
const { renderApp } = await import('./application');
|
|
|
|
// Get start services
|
2021-05-27 16:58:15 +02:00
|
|
|
const [coreStart, pluginsStart, { navigation }] = await coreSetup.getStartServices();
|
2021-03-23 13:57:56 +01:00
|
|
|
|
2021-04-15 18:25:50 +02:00
|
|
|
return renderApp({
|
2021-04-20 05:09:51 +02:00
|
|
|
config,
|
2021-04-15 18:25:50 +02:00
|
|
|
core: coreStart,
|
|
|
|
plugins: pluginsStart,
|
|
|
|
appMountParameters: params,
|
2021-05-13 17:12:47 +02:00
|
|
|
observabilityRuleTypeRegistry,
|
2021-05-27 16:58:15 +02:00
|
|
|
ObservabilityPageTemplate: navigation.PageTemplate,
|
2021-04-15 18:25:50 +02:00
|
|
|
});
|
2021-03-23 13:57:56 +01:00
|
|
|
};
|
2021-04-15 18:25:50 +02:00
|
|
|
|
2021-06-28 18:48:32 +02:00
|
|
|
const appUpdater$ = this.appUpdater$;
|
|
|
|
const app = {
|
2020-06-08 09:07:35 +02:00
|
|
|
appRoute: '/app/observability',
|
2021-03-23 13:57:56 +01:00
|
|
|
category,
|
2021-06-28 18:48:32 +02:00
|
|
|
deepLinks: this.deepLinks,
|
2021-03-23 13:57:56 +01:00
|
|
|
euiIconType,
|
2021-06-28 18:48:32 +02:00
|
|
|
id: observabilityAppId,
|
2021-03-23 13:57:56 +01:00
|
|
|
mount,
|
2021-06-28 18:48:32 +02:00
|
|
|
order: 8000,
|
|
|
|
title: i18n.translate('xpack.observability.overviewLinkTitle', {
|
|
|
|
defaultMessage: 'Overview',
|
|
|
|
}),
|
|
|
|
updater$: appUpdater$,
|
|
|
|
};
|
2020-06-08 09:07:35 +02:00
|
|
|
|
2021-06-28 18:48:32 +02:00
|
|
|
coreSetup.application.register(app);
|
2020-06-15 08:46:36 +02:00
|
|
|
|
2021-04-15 18:25:50 +02:00
|
|
|
if (pluginsSetup.home) {
|
|
|
|
pluginsSetup.home.featureCatalogue.registerSolution({
|
2021-06-28 18:48:32 +02:00
|
|
|
id: observabilityFeatureId,
|
2020-08-26 22:00:00 +02:00
|
|
|
title: i18n.translate('xpack.observability.featureCatalogueTitle', {
|
|
|
|
defaultMessage: 'Observability',
|
|
|
|
}),
|
|
|
|
subtitle: i18n.translate('xpack.observability.featureCatalogueSubtitle', {
|
|
|
|
defaultMessage: 'Centralize & monitor',
|
|
|
|
}),
|
2020-10-06 18:13:31 +02:00
|
|
|
description: i18n.translate('xpack.observability.featureCatalogueDescription', {
|
|
|
|
defaultMessage:
|
|
|
|
'Consolidate your logs, metrics, application traces, and system availability with purpose-built UIs.',
|
|
|
|
}),
|
|
|
|
appDescriptions: [
|
2020-08-26 22:00:00 +02:00
|
|
|
i18n.translate('xpack.observability.featureCatalogueDescription1', {
|
|
|
|
defaultMessage: 'Monitor infrastructure metrics.',
|
|
|
|
}),
|
|
|
|
i18n.translate('xpack.observability.featureCatalogueDescription2', {
|
|
|
|
defaultMessage: 'Trace application requests.',
|
|
|
|
}),
|
|
|
|
i18n.translate('xpack.observability.featureCatalogueDescription3', {
|
|
|
|
defaultMessage: 'Measure SLAs and react to issues.',
|
|
|
|
}),
|
|
|
|
],
|
|
|
|
icon: 'logoObservability',
|
2020-10-15 15:46:43 +02:00
|
|
|
path: '/app/observability/',
|
2020-08-26 22:00:00 +02:00
|
|
|
order: 200,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2021-05-27 16:58:15 +02:00
|
|
|
this.navigationRegistry.registerSections(
|
2021-06-28 18:48:32 +02:00
|
|
|
from(appUpdater$).pipe(
|
|
|
|
map((value) => {
|
|
|
|
const deepLinks = value(app)?.deepLinks ?? [];
|
|
|
|
|
|
|
|
const overviewLink = {
|
|
|
|
label: i18n.translate('xpack.observability.overviewLinkTitle', {
|
|
|
|
defaultMessage: 'Overview',
|
|
|
|
}),
|
|
|
|
app: observabilityAppId,
|
|
|
|
path: '/overview',
|
|
|
|
};
|
|
|
|
|
|
|
|
// Reformat the visible links to be NavigationEntry objects instead of
|
|
|
|
// AppDeepLink objects.
|
|
|
|
//
|
|
|
|
// In our case the deep links and sections being registered are the
|
|
|
|
// same, and the logic to hide them based on flags or capabilities is
|
|
|
|
// the same, so we just want to make a new list with the properties
|
|
|
|
// needed by `registerSections`, which are different than the
|
|
|
|
// properties used by the deepLinks.
|
|
|
|
//
|
|
|
|
// See https://github.com/elastic/kibana/issues/103325.
|
|
|
|
const otherLinks: NavigationEntry[] = deepLinks
|
|
|
|
.filter((link) => link.navLinkStatus === AppNavLinkStatus.visible)
|
|
|
|
.map((link) => ({
|
|
|
|
app: observabilityAppId,
|
|
|
|
label: link.title,
|
|
|
|
path: link.path ?? '',
|
|
|
|
}));
|
|
|
|
|
|
|
|
const sections = [
|
|
|
|
{
|
|
|
|
label: '',
|
|
|
|
sortKey: 100,
|
|
|
|
entries: [overviewLink, ...otherLinks],
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
return sections;
|
|
|
|
})
|
|
|
|
)
|
2021-05-27 16:58:15 +02:00
|
|
|
);
|
|
|
|
|
2020-06-15 08:46:36 +02:00
|
|
|
return {
|
|
|
|
dashboard: { register: registerDataHandler },
|
2021-05-13 17:12:47 +02:00
|
|
|
observabilityRuleTypeRegistry,
|
2021-04-20 15:07:09 +02:00
|
|
|
isAlertingExperienceEnabled: () => config.unsafe.alertingExperience.enabled,
|
2021-05-27 16:58:15 +02:00
|
|
|
navigation: {
|
|
|
|
registerSections: this.navigationRegistry.registerSections,
|
|
|
|
},
|
2020-06-15 08:46:36 +02:00
|
|
|
};
|
2020-06-08 09:07:35 +02:00
|
|
|
}
|
2021-06-28 18:48:32 +02:00
|
|
|
|
2020-09-17 13:36:58 +02:00
|
|
|
public start({ application }: CoreStart) {
|
2021-06-28 18:48:32 +02:00
|
|
|
const config = this.initializerContext.config.get();
|
|
|
|
|
|
|
|
updateGlobalNavigation({
|
|
|
|
capabilities: application.capabilities,
|
|
|
|
config,
|
|
|
|
deepLinks: this.deepLinks,
|
|
|
|
updater$: this.appUpdater$,
|
|
|
|
});
|
2021-05-27 16:58:15 +02:00
|
|
|
|
|
|
|
const PageTemplate = createLazyObservabilityPageTemplate({
|
|
|
|
currentAppId$: application.currentAppId$,
|
|
|
|
getUrlForApp: application.getUrlForApp,
|
|
|
|
navigateToApp: application.navigateToApp,
|
|
|
|
navigationSections$: this.navigationRegistry.sections$,
|
|
|
|
});
|
|
|
|
|
|
|
|
return {
|
|
|
|
navigation: {
|
|
|
|
PageTemplate,
|
|
|
|
},
|
|
|
|
};
|
2020-07-14 16:32:28 +02:00
|
|
|
}
|
2020-01-28 02:10:34 +01:00
|
|
|
}
|