forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
/
kibana.index.ts
115 lines (104 loc) · 3.1 KB
/
kibana.index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
/*
* 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 { i18n } from '@kbn/i18n';
import { Server } from 'hapi';
import JoiNamespace from 'joi';
import { initInfraServer } from './infra_server';
import { compose } from './lib/compose/kibana';
import { UsageCollector } from './usage/usage_collector';
export interface KbnServer extends Server {
usage: any;
}
export const initServerWithKibana = (kbnServer: KbnServer) => {
const libs = compose(kbnServer);
initInfraServer(libs);
// Register a function with server to manage the collection of usage stats
kbnServer.usage.collectorSet.register(UsageCollector.getUsageCollector(kbnServer));
const xpackMainPlugin = kbnServer.plugins.xpack_main;
xpackMainPlugin.registerFeature({
id: 'infrastructure',
name: i18n.translate('xpack.infra.featureRegistry.linkInfrastructureTitle', {
defaultMessage: 'Infrastructure',
}),
icon: 'infraApp',
navLinkId: 'infra:home',
app: ['infra', 'kibana'],
catalogue: ['infraops'],
privileges: {
all: {
savedObject: {
all: ['infrastructure-ui-source'],
read: ['config'],
},
ui: ['show', 'configureSource'],
},
read: {
savedObject: {
all: [],
read: ['config', 'infrastructure-ui-source'],
},
ui: ['show'],
},
},
});
xpackMainPlugin.registerFeature({
id: 'logs',
name: i18n.translate('xpack.infra.featureRegistry.linkLogsTitle', {
defaultMessage: 'Logs',
}),
icon: 'loggingApp',
navLinkId: 'infra:logs',
app: ['infra', 'kibana'],
catalogue: ['infralogging'],
privileges: {
all: {
savedObject: {
all: ['infrastructure-ui-source'],
read: ['config'],
},
ui: ['show', 'configureSource'],
},
read: {
savedObject: {
all: [],
read: ['config', 'infrastructure-ui-source'],
},
ui: ['show'],
},
},
});
};
export const getConfigSchema = (Joi: typeof JoiNamespace) => {
const InfraDefaultSourceConfigSchema = Joi.object({
metricAlias: Joi.string(),
logAlias: Joi.string(),
fields: Joi.object({
container: Joi.string(),
host: Joi.string(),
pod: Joi.string(),
tiebreaker: Joi.string(),
timestamp: Joi.string(),
}),
});
const InfraRootConfigSchema = Joi.object({
enabled: Joi.boolean().default(true),
query: Joi.object({
partitionSize: Joi.number(),
partitionFactor: Joi.number(),
}).default(),
sources: Joi.object()
.keys({
default: InfraDefaultSourceConfigSchema,
})
.default(),
}).default();
return InfraRootConfigSchema;
};
export const getDeprecations = () => [];
// interface DeprecationHelpers {
// rename(oldKey: string, newKey: string): (settings: unknown, log: unknown) => void;
// unused(oldKey: string): (settings: unknown, log: unknown) => void;
// }