mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
* [tribe] Init docs * [docs] Init es client section * [docs] Link to client api, move client library docs to core development section * [docs] Add tribe server settings * [tribe] Link to elasticsearch tribe docs * [tribe] Document which nodes server configuration points towards * [docs] Add index link to elasticsearch clients section
41 lines
1.2 KiB
Text
41 lines
1.2 KiB
Text
[[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
|
|
other requests. The clients use the https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/index.html[elasticsearch.js library].
|
|
|
|
[float]
|
|
[[client-server]]
|
|
=== Server clients
|
|
|
|
Server clients are exposed through the elasticsearch plugin.
|
|
[source,javascript]
|
|
----
|
|
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');
|
|
----
|
|
|
|
[float]
|
|
[[client-browser]]
|
|
=== Browser clients
|
|
|
|
Browser clients are exposed through AngularJS services.
|
|
|
|
[source,javascript]
|
|
----
|
|
uiModules.get('kibana')
|
|
.run(function (esAdmin, es) {
|
|
es.ping()
|
|
.then(() => esAdmin.ping())
|
|
.catch(err => {
|
|
console.log('error pinging servers');
|
|
});
|
|
});
|
|
----
|