diff --git a/config/kibana.yml b/config/kibana.yml index 0780841ca057e..6b47f18363203 100644 --- a/config/kibana.yml +++ b/config/kibana.yml @@ -1,3 +1,5 @@ +xpack.uptime.indexPattern: alt-heartbeat-* + # Kibana is served by a back end server. This setting specifies the port to use. #server.port: 5601 diff --git a/x-pack/legacy/plugins/uptime/index.ts b/x-pack/legacy/plugins/uptime/index.ts index c8de623cb0a13..c176979515501 100644 --- a/x-pack/legacy/plugins/uptime/index.ts +++ b/x-pack/legacy/plugins/uptime/index.ts @@ -5,6 +5,7 @@ */ import { i18n } from '@kbn/i18n'; +import { Server } from 'hapi'; import { resolve } from 'path'; import { PluginInitializerContext } from 'src/core/server'; import { PLUGIN } from './common/constants'; @@ -16,6 +17,13 @@ export const uptime = (kibana: any) => id: PLUGIN.ID, publicDir: resolve(__dirname, 'public'), require: ['kibana', 'elasticsearch', 'xpack_main'], + config(Joi: any) { + return Joi.object({ + enabled: Joi.boolean().default(true), + }) + .unknown() + .default(); + }, uiExports: { app: { description: i18n.translate('xpack.uptime.pluginDescription', { @@ -32,6 +40,12 @@ export const uptime = (kibana: any) => url: '/app/uptime#/', }, home: ['plugins/uptime/register_feature'], + injectDefaultVars(server: Server) { + const config = server.config(); + return { + uptimeIndexPattern: config.get('xpack.uptime.indexPattern'), + }; + }, }, init(server: KibanaServer) { const initializerContext = {} as PluginInitializerContext; diff --git a/x-pack/plugins/uptime/kibana.json b/x-pack/plugins/uptime/kibana.json new file mode 100644 index 0000000000000..3c99a8571400e --- /dev/null +++ b/x-pack/plugins/uptime/kibana.json @@ -0,0 +1,6 @@ +{ + "id": "uptime", + "version": "8.0.0", + "server": true, + "configPath": ["xpack", "uptime"] +} diff --git a/x-pack/plugins/uptime/server/index.ts b/x-pack/plugins/uptime/server/index.ts new file mode 100644 index 0000000000000..3c2e362c383f1 --- /dev/null +++ b/x-pack/plugins/uptime/server/index.ts @@ -0,0 +1,21 @@ +/* + * 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 { schema, TypeOf } from '@kbn/config-schema'; +import { PluginInitializerContext } from 'src/core/server'; +import { UptimePlugin } from './plugin'; + +export const config = { + schema: schema.object({ + enabled: schema.maybe(schema.boolean()), + indexPattern: schema.maybe(schema.string()), + }), +}; + +export const plugin = (initContext: PluginInitializerContext) => new UptimePlugin(initContext); + +export type UptimeConfig = TypeOf; +export { UptimeSetup } from './plugin'; diff --git a/x-pack/plugins/uptime/server/plugin.ts b/x-pack/plugins/uptime/server/plugin.ts new file mode 100644 index 0000000000000..ec1dd8ba33003 --- /dev/null +++ b/x-pack/plugins/uptime/server/plugin.ts @@ -0,0 +1,36 @@ +/* + * 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 { Plugin, PluginInitializerContext } from 'src/core/server'; + +export class UptimePlugin implements Plugin { + private readonly initContext: PluginInitializerContext; + + constructor(initContext: PluginInitializerContext) { + this.initContext = initContext; + } + + public setup() { + console.log("X") + console.log("SET IT UP") + console.log("X") + return { + __legacy: { + config: this.initContext.config, + }, + }; + } + + public start() {} + public stop() {} +} + +export interface UptimeSetup { + /** @deprecated */ + __legacy: { + config: PluginInitializerContext['config']; + }; +}