forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
201 lines (190 loc) · 7.39 KB
/
index.js
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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import Promise from 'bluebird';
import { mkdirp as mkdirpNode } from 'mkdirp';
import { resolve } from 'path';
import migrations from './migrations';
import manageUuid from './server/lib/manage_uuid';
import { searchApi } from './server/routes/api/search';
import { scrollSearchApi } from './server/routes/api/scroll_search';
import { importApi } from './server/routes/api/import';
import { exportApi } from './server/routes/api/export';
import { homeApi } from './server/routes/api/home';
import { managementApi } from './server/routes/api/management';
import { scriptsApi } from './server/routes/api/scripts';
import { registerSuggestionsApi } from './server/routes/api/suggestions';
import { registerKqlTelemetryApi } from './server/routes/api/kql_telemetry';
import { registerFieldFormats } from './server/field_formats/register';
import { registerTutorials } from './server/tutorials/register';
import * as systemApi from './server/lib/system_api';
import handleEsError from './server/lib/handle_es_error';
import mappings from './mappings.json';
import { getUiSettingDefaults } from './ui_setting_defaults';
import { makeKQLUsageCollector } from './server/lib/kql_usage_collector';
import { injectVars } from './inject_vars';
import { i18n } from '@kbn/i18n';
const mkdirp = Promise.promisify(mkdirpNode);
export default function (kibana) {
const kbnBaseUrl = '/app/kibana';
return new kibana.Plugin({
id: 'kibana',
config: function (Joi) {
return Joi.object({
enabled: Joi.boolean().default(true),
defaultAppId: Joi.string().default('home'),
index: Joi.string().default('.kibana'),
disableWelcomeScreen: Joi.boolean().default(false),
}).default();
},
uiExports: {
hacks: ['plugins/kibana/dev_tools/hacks/hide_empty_tools'],
fieldFormats: ['plugins/kibana/field_formats/register'],
savedObjectTypes: [
'plugins/kibana/visualize/saved_visualizations/saved_visualization_register',
'plugins/kibana/discover/saved_searches/saved_search_register',
'plugins/kibana/dashboard/saved_dashboard/saved_dashboard_register',
],
app: {
id: 'kibana',
title: 'Kibana',
listed: false,
description: i18n.translate('kbn.kibanaDescription', {
defaultMessage: 'the kibana you know and love'
}),
main: 'plugins/kibana/kibana',
},
styleSheetPaths: resolve(__dirname, 'public/index.scss'),
links: [
{
id: 'kibana:discover',
title: i18n.translate('kbn.discoverTitle', {
defaultMessage: 'Discover'
}),
order: -1003,
url: `${kbnBaseUrl}#/discover`,
description: i18n.translate('kbn.discoverDescription', {
defaultMessage: 'interactively explore your data'
}),
icon: 'plugins/kibana/assets/discover.svg',
euiIconType: 'discoverApp',
}, {
id: 'kibana:visualize',
title: i18n.translate('kbn.visualizeTitle', {
defaultMessage: 'Visualize'
}),
order: -1002,
url: `${kbnBaseUrl}#/visualize`,
description: i18n.translate('kbn.visualizeDescription', {
defaultMessage: 'design data visualizations'
}),
icon: 'plugins/kibana/assets/visualize.svg',
euiIconType: 'visualizeApp',
}, {
id: 'kibana:dashboard',
title: i18n.translate('kbn.dashboardTitle', {
defaultMessage: 'Dashboard'
}),
order: -1001,
url: `${kbnBaseUrl}#/dashboards`,
// The subUrlBase is the common substring of all urls for this app. If not given, it defaults to the url
// above. This app has to use a different subUrlBase, in addition to the url above, because "#/dashboard"
// routes to a page that creates a new dashboard. When we introduced a landing page, we needed to change
// the url above in order to preserve the original url for BWC. The subUrlBase helps the Chrome api nav
// to determine what url to use for the app link.
subUrlBase: `${kbnBaseUrl}#/dashboard`,
description: i18n.translate('kbn.dashboardDescription', {
defaultMessage: 'compose visualizations for much win'
}),
icon: 'plugins/kibana/assets/dashboard.svg',
euiIconType: 'dashboardApp',
}, {
id: 'kibana:dev_tools',
title: i18n.translate('kbn.devToolsTitle', {
defaultMessage: 'Dev Tools'
}),
order: 9001,
url: '/app/kibana#/dev_tools',
description: i18n.translate('kbn.devToolsDescription', {
defaultMessage: 'development tools'
}),
icon: 'plugins/kibana/assets/wrench.svg',
euiIconType: 'devToolsApp',
}, {
id: 'kibana:management',
title: i18n.translate('kbn.managementTitle', {
defaultMessage: 'Management'
}),
order: 9003,
url: `${kbnBaseUrl}#/management`,
description: i18n.translate('kbn.managementDescription', {
defaultMessage: 'define index patterns, change config, and more'
}),
icon: 'plugins/kibana/assets/settings.svg',
euiIconType: 'managementApp',
linkToLastSubUrl: false
},
],
savedObjectSchemas: {
'kql-telemetry': {
isNamespaceAgnostic: true,
},
},
injectDefaultVars(server, options) {
return {
kbnIndex: options.index,
kbnBaseUrl
};
},
mappings,
uiSettingDefaults: getUiSettingDefaults(),
migrations,
},
preInit: async function (server) {
try {
// Create the data directory (recursively, if the a parent dir doesn't exist).
// If it already exists, does nothing.
await mkdirp(server.config().get('path.data'));
} catch (err) {
server.log(['error', 'init'], err);
// Stop the server startup with a fatal error
throw err;
}
},
init: function (server) {
// uuid
manageUuid(server);
// routes
searchApi(server);
scriptsApi(server);
scrollSearchApi(server);
importApi(server);
exportApi(server);
homeApi(server);
managementApi(server);
registerSuggestionsApi(server);
registerKqlTelemetryApi(server);
registerFieldFormats(server);
registerTutorials(server);
makeKQLUsageCollector(server);
server.expose('systemApi', systemApi);
server.expose('handleEsError', handleEsError);
server.injectUiAppVars('kibana', () => injectVars(server));
}
});
}