2017-01-12 23:34:01 +01:00
|
|
|
[[development-elasticsearch]]
|
|
|
|
=== Communicating with Elasticsearch
|
|
|
|
|
|
|
|
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
|
2019-10-16 02:33:08 +02:00
|
|
|
other requests. The clients use the {jsclient-current}/index.html[elasticsearch.js library].
|
2017-01-12 23:34:01 +01:00
|
|
|
|
|
|
|
[float]
|
|
|
|
[[client-server]]
|
|
|
|
=== Server clients
|
|
|
|
|
|
|
|
Server clients are exposed through the elasticsearch plugin.
|
|
|
|
[source,javascript]
|
|
|
|
----
|
2018-06-18 18:11:53 +02:00
|
|
|
const adminCluster = server.plugins.elasticsearch.getCluster('admin');
|
|
|
|
const dataCluster = server.plugins.elasticsearch.getCluster('data');
|
2017-01-12 23:34:01 +01:00
|
|
|
|
|
|
|
//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');
|
|
|
|
----
|
|
|
|
|
|
|
|
[float]
|
|
|
|
[[client-browser]]
|
|
|
|
=== Browser clients
|
|
|
|
|
|
|
|
Browser clients are exposed through AngularJS services.
|
|
|
|
|
|
|
|
[source,javascript]
|
|
|
|
----
|
|
|
|
uiModules.get('kibana')
|
2017-08-10 18:30:44 +02:00
|
|
|
.run(function (es) {
|
2017-01-12 23:34:01 +01:00
|
|
|
es.ping()
|
|
|
|
.catch(err => {
|
|
|
|
console.log('error pinging servers');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
----
|