From 5caf9f2baac092adb966a43a92fcc168e5e688d7 Mon Sep 17 00:00:00 2001 From: Tim Sullivan Date: Tue, 24 Jul 2018 08:52:29 -0700 Subject: [PATCH] Remove xpack usage module (#21099) --- .../server/routes/api/v1/xpack_usage.js | 54 ------------------- 1 file changed, 54 deletions(-) delete mode 100644 x-pack/plugins/xpack_main/server/routes/api/v1/xpack_usage.js diff --git a/x-pack/plugins/xpack_main/server/routes/api/v1/xpack_usage.js b/x-pack/plugins/xpack_main/server/routes/api/v1/xpack_usage.js deleted file mode 100644 index ea01d119efe7f..0000000000000 --- a/x-pack/plugins/xpack_main/server/routes/api/v1/xpack_usage.js +++ /dev/null @@ -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)); - } - } - } - }); -}