-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Monitoring] NP migration: Local angular module #51823
Changes from all commits
ec7e660
ae37275
2c9b966
a19f668
619738e
c9dd620
d12baea
784f18e
1467bef
0a2fa91
69791d4
0b79ecc
392589e
8d33f59
f78e278
08f8421
4bc829c
b31832f
db58c76
3530b99
c5724ac
ed9127c
5aff3ee
f00194a
9e3a033
d32856e
30f3dfc
7ca4b03
a490ea4
3089ed1
27c3b05
5916cff
4342c4c
dac0602
08761c2
9a7e26c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,138 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { resolve } from 'path'; | ||
import KbnServer, { Server } from 'src/legacy/server/kbn_server'; | ||
import { | ||
LegacyPluginApi, | ||
LegacyPluginSpec, | ||
LegacyPluginOptions, | ||
} from 'src/legacy/plugin_discovery/types'; | ||
import { KIBANA_ALERTING_ENABLED } from './common/constants'; | ||
|
||
// @ts-ignore | ||
import { getUiExports } from './ui_exports'; | ||
// @ts-ignore | ||
import { config as configDefaults } from './config'; | ||
// @ts-ignore | ||
import { deprecations } from './deprecations'; | ||
// @ts-ignore | ||
import { Plugin } from './server/plugin'; | ||
// @ts-ignore | ||
import { initInfraSource } from './server/lib/logs/init_infra_source'; | ||
|
||
type InfraPlugin = any; // TODO | ||
type PluginsSetup = any; // TODO | ||
type LegacySetup = any; // TODO | ||
|
||
const deps = ['kibana', 'elasticsearch', 'xpack_main']; | ||
if (KIBANA_ALERTING_ENABLED) { | ||
deps.push(...['alerting', 'actions']); | ||
} | ||
|
||
const validConfigOptions: string[] = [ | ||
'monitoring.ui.enabled', | ||
'monitoring.kibana.collection.enabled', | ||
'monitoring.ui.max_bucket_size', | ||
'monitoring.ui.min_interval_seconds', | ||
'kibana.index', | ||
'monitoring.ui.show_license_expiration', | ||
'monitoring.ui.container.elasticsearch.enabled', | ||
'monitoring.ui.container.logstash.enabled', | ||
'monitoring.tests.cloud_detector.enabled', | ||
'monitoring.kibana.collection.interval', | ||
'monitoring.ui.elasticsearch.hosts', | ||
'monitoring.ui.elasticsearch', | ||
'monitoring.xpack_api_polling_frequency_millis', | ||
'server.uuid', | ||
'server.name', | ||
'server.host', | ||
'server.port', | ||
'monitoring.cluster_alerts.email_notifications.enabled', | ||
'monitoring.cluster_alerts.email_notifications.email_address', | ||
'monitoring.ui.ccs.enabled', | ||
'monitoring.ui.elasticsearch.logFetchCount', | ||
'monitoring.ui.logs.index', | ||
]; | ||
|
||
interface LegacyPluginOptionsWithKbnServer extends LegacyPluginOptions { | ||
kbnServer?: KbnServer; | ||
} | ||
|
||
/** | ||
* Invokes plugin modules to instantiate the Monitoring plugin for Kibana | ||
* @param kibana {Object} Kibana plugin instance | ||
* @return {Object} Monitoring UI Kibana plugin object | ||
*/ | ||
export const monitoring = (kibana: LegacyPluginApi): LegacyPluginSpec => { | ||
return new kibana.Plugin({ | ||
require: deps, | ||
id: 'monitoring', | ||
configPrefix: 'monitoring', | ||
publicDir: resolve(__dirname, 'public'), | ||
config: configDefaults, | ||
uiExports: getUiExports(), | ||
deprecations, | ||
|
||
init(server: Server) { | ||
const serverConfig = server.config(); | ||
const { getOSInfo, plugins, injectUiAppVars } = server as typeof server & { getOSInfo?: any }; | ||
const log = (...args: Parameters<typeof server.log>) => server.log(...args); | ||
const route = (...args: Parameters<typeof server.route>) => server.route(...args); | ||
const expose = (...args: Parameters<typeof server.expose>) => server.expose(...args); | ||
const serverFacade = { | ||
config: () => ({ | ||
get: (key: string) => { | ||
if (validConfigOptions.includes(key)) { | ||
return serverConfig.get(key); | ||
} | ||
throw new Error(`Unknown key '${key}'`); | ||
}, | ||
}), | ||
injectUiAppVars, | ||
log, | ||
logger: server.newPlatform.coreContext.logger, | ||
getOSInfo, | ||
events: { | ||
on: (...args: Parameters<typeof server.events.on>) => server.events.on(...args), | ||
}, | ||
route, | ||
expose, | ||
_hapi: server, | ||
_kbnServer: this.kbnServer, | ||
}; | ||
|
||
const legacyPlugins = plugins as Partial<typeof plugins> & { infra?: InfraPlugin }; | ||
const { xpack_main, elasticsearch, infra, alerting } = legacyPlugins; | ||
const { | ||
core: coreSetup, | ||
plugins: { usageCollection, licensing }, | ||
} = server.newPlatform.setup; | ||
|
||
const pluginsSetup: PluginsSetup = { | ||
usageCollection, | ||
licensing, | ||
}; | ||
|
||
const __LEGACY: LegacySetup = { | ||
...serverFacade, | ||
plugins: { | ||
xpack_main, | ||
elasticsearch, | ||
infra, | ||
alerting, | ||
}, | ||
}; | ||
|
||
new Plugin().setup(coreSetup, pluginsSetup, __LEGACY); | ||
}, | ||
|
||
postInit(server: Server) { | ||
const { infra } = server.plugins as Partial<typeof server.plugins> & { infra?: InfraPlugin }; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. shouldn't you declare dependency on There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you mean through There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. not only, you declare dependencies on other plugins https://github.com/elastic/kibana/pull/51823/files#diff-3450f9bd06407cda6d6d9e26ddeb0e11R31-R35 |
||
initInfraSource(server.config(), infra); | ||
}, | ||
} as Partial<LegacyPluginOptionsWithKbnServer>); | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can already start consuming them from
server.newPlatform.setup.core.http.getServerInfo
andserver.newPlatform.setup.core.uuid.getInstanceUuid
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this will also be in the next phase, when we start using np alternatives and whitelisting config properties
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fair enough