mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
Remove xpack usage module (#21099)
This commit is contained in:
parent
3bc65f142c
commit
5caf9f2baa
1 changed files with 0 additions and 54 deletions
|
@ -1,54 +0,0 @@
|
|||
/*
|
||||
* 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 { wrap as wrapError } from 'boom';
|
||||
|
||||
const getClusterUuid = async callCluster => {
|
||||
const { cluster_uuid: uuid } = await callCluster('info', { filterPath: 'cluster_uuid', });
|
||||
return uuid;
|
||||
};
|
||||
|
||||
/*
|
||||
* @return {Object} data from usage stats collectors registered with Monitoring CollectorSet
|
||||
* @throws {Error} if the Monitoring CollectorSet is not ready
|
||||
*/
|
||||
const getUsage = async (callCluster, server) => {
|
||||
const { collectorSet } = server.usage;
|
||||
const usage = await collectorSet.bulkFetchUsage(callCluster);
|
||||
const usageObject = collectorSet.toObject(usage);
|
||||
return collectorSet.toApiFieldNames(usageObject);
|
||||
};
|
||||
|
||||
export function xpackUsageRoute(server) {
|
||||
server.route({
|
||||
path: '/api/_xpack/usage',
|
||||
method: 'GET',
|
||||
async handler(req, reply) {
|
||||
const { server } = req;
|
||||
const { callWithRequest } = server.plugins.elasticsearch.getCluster('data');
|
||||
const callCluster = (...args) => callWithRequest(req, ...args); // All queries from HTTP API must use authentication headers from the request
|
||||
|
||||
try {
|
||||
const [ clusterUuid, xpackUsage ] = await Promise.all([
|
||||
getClusterUuid(callCluster),
|
||||
getUsage(callCluster, server),
|
||||
]);
|
||||
|
||||
reply({
|
||||
cluster_uuid: clusterUuid,
|
||||
...xpackUsage
|
||||
});
|
||||
} catch(err) {
|
||||
req.log(['error'], err); // FIXME doesn't seem to log anything useful if ES times out
|
||||
if (err.isBoom) {
|
||||
reply(err);
|
||||
} else {
|
||||
reply(wrapError(err, err.statusCode, err.message));
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue