Skip to content
Closed
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions config/kibana.yml
Original file line number Diff line number Diff line change
@@ -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

Expand Down
14 changes: 14 additions & 0 deletions x-pack/legacy/plugins/uptime/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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),
})
Comment on lines +21 to +23
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You will need to add the indexPattern property in the legacy configuration for now, as both plugins share the same NS

.unknown()
.default();
},
uiExports: {
app: {
description: i18n.translate('xpack.uptime.pluginDescription', {
Expand All @@ -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;
Expand Down
6 changes: 6 additions & 0 deletions x-pack/plugins/uptime/kibana.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"id": "uptime",
"version": "8.0.0",
"server": true,
"configPath": ["xpack", "uptime"]
}
21 changes: 21 additions & 0 deletions x-pack/plugins/uptime/server/index.ts
Original file line number Diff line number Diff line change
@@ -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()),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

schema.string({ defaultValue: 'alt-heartbeat-*' }) and remove from config

}),
};

export const plugin = (initContext: PluginInitializerContext) => new UptimePlugin(initContext);

export type UptimeConfig = TypeOf<typeof config.schema>;
export { UptimeSetup } from './plugin';
36 changes: 36 additions & 0 deletions x-pack/plugins/uptime/server/plugin.ts
Original file line number Diff line number Diff line change
@@ -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<UptimeSetup> {
private readonly initContext: PluginInitializerContext;

constructor(initContext: PluginInitializerContext) {
this.initContext = initContext;
}

public setup() {
console.log("X")
console.log("SET IT UP")
console.log("X")
Comment on lines +17 to +19
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(remove and) Use PluginInitializerContext.logger if you need to log from NP

return {
__legacy: {
config: this.initContext.config,
},
};
}

public start() {}
public stop() {}
}

export interface UptimeSetup {
/** @deprecated */
__legacy: {
config: PluginInitializerContext['config'];
};
}