Skip to content

Commit

Permalink
[server/stats] add server.getKibanaStats() for programatic access (#1…
Browse files Browse the repository at this point in the history
  • Loading branch information
spalger authored Aug 9, 2017
1 parent db4eb64 commit 12142da
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/server/stats/stats_mixin.js
Original file line number Diff line number Diff line change
@@ -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',
Expand Down

0 comments on commit 12142da

Please sign in to comment.