Communicating with Elasticsearchedit

Kibana exposes two clients on the server and browser for communicating with elasticsearch. There is an admin client which is used for managing Kibana’s state, and a data client for all

Server clientsedit

Server clients are exposed through the elasticsearch plugin.

  const adminCluster = server.plugins.elasticsearch.getCluster('admin);
  const dataCluster = server.plugins.elasticsearch.getCluster('data);

  //ping as the configured elasticsearch.user in kibana.yml
  adminCluster.callWithInternalUser('ping');

  //ping as the user specified in the current requests header
  adminCluster.callWithRequest(req, 'ping');

Browser clientsedit

Browser clients are exposed through AngularJS services.

uiModules.get('kibana')
.run(function (esAdmin, es) {
  es.ping()
  .then(() => esAdmin.ping())
  .catch(err => {
    console.log('error pinging servers');
  });
});