Getting a hold of elastic data within Kibana Plugin

I've been developing a ReactJS based Kibana plugin and have been trying to search my elastic search data within the plugin. Does anyone know what's the best way to approach this? I attempted to use the elastic API but I ran into cross-origin issues and felt like it wouldn't be secure editing the elastic config file to allow cross origin data. I did some looking around and found that I can possibly use the elasticsearch.js library but I haven't figured out how to implement it. In addition, I'm not sure if its usable within a plugin.

Couple ways to do this.

Take the approach time series visual builder uses and query elasticsearch directly (from the server) and exposing this to the client via an API. Some code for reference:

Second way is to do what many visualization plugins do and make use of the client side Courier using SearchSource (see This might be too heavy handed for your approach based on what you are querying for. The courier code is also in quite a bit of flux as it's old code and needs to be refactored and de-angularized. So you might be better off, depending on your needs, going with the first approach.

1 Like

Are there any examples on how I can use const { callWithRequest } = req.server.plugins.elasticsearch.getCluster('data');. What would be the command to see how many hits there are in a cluster for a query I am searching.

I have figured this out by using some server side code that handles requests and search elastic search by using the elasticsearch.js plugin.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.