diff --git a/src/server/stats/stats_mixin.js b/src/server/stats/stats_mixin.js index 0559793dd3268..9df5cc0f7fbcd 100644 --- a/src/server/stats/stats_mixin.js +++ b/src/server/stats/stats_mixin.js @@ -1,6 +1,21 @@ import { getStats } from './stats'; export function statsMixin(kbnServer, server) { + + /** + * Get a summary about the number of objects in the kibana index + * @name server.getKibanaStats + * @param {Object} options + * @property {Function} options.callCluster method for calling the elasticsearch cluster + */ + server.decorate('server', 'getKibanaStats', async ({ callCluster }) => { + const savedObjectsClient = server.savedObjectsClientFactory({ callCluster }); + return await getStats( + server.config().get('kibana.index'), + savedObjectsClient + ); + }); + server.route({ method: 'GET', path: '/api/stats',