# How to use the connection that kibana is using to Elasticsearch in kibana plugin?

**URL:** https://discuss.elastic.co/t/how-to-use-the-connection-that-kibana-is-using-to-elasticsearch-in-kibana-plugin/213669
**Category:** Kibana
**Created:** [January 3, 2020, 7:18am UTC](https://discuss.elastic.co/t/how-to-use-the-connection-that-kibana-is-using-to-elasticsearch-in-kibana-plugin/213669 "2020-01-03T07:18:12Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![jaytran](https://avatars.discourse-cdn.com/v4/letter/j/db5fbb/32.png) [@jaytran](https://discuss.elastic.co/u/jaytran)
#### Post date: [January 3, 2020, 7:18am UTC](https://discuss.elastic.co/t/how-to-use-the-connection-that-kibana-is-using-to-elasticsearch-in-kibana-plugin/213669/1 "2020-01-03T07:18:12Z")

</div>

Hi all,

I'm building a kibana plugin with a new connection such as below:

const elasticsearch = require('elasticsearch');  
const client = new elasticsearch.Client({ host: '127.0.0.1:9200'});

const search = function search(index, body) {  
return client.search({index: index, body: body});  
};

Now I want to use the connection that kibana is using Instead of creating new a new connection to elasticsearch from plugin.  
Please tell me know how to do it? thank you for any response.

---

<div class="post-metadata">

### Author: ![bhavyarm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bhavyarm/32/22392_2.png) [@bhavyarm](https://discuss.elastic.co/u/bhavyarm)
#### Post date: [January 3, 2020, 11:41pm UTC](https://discuss.elastic.co/t/how-to-use-the-connection-that-kibana-is-using-to-elasticsearch-in-kibana-plugin/213669/2 "2020-01-03T23:41:44Z")

</div>

Kibana connects to elasticsearch at \<\>:9200 which is the default and defined in Kibana.yml.

[https://www.elastic.co/guide/en/kibana/current/settings.html](https://www.elastic.co/guide/en/kibana/current/settings.html)

So you should be fine with your plugin?

Thanks,  
Bhavya

---

<div class="post-metadata">

### Author: ![Jay\_Tran](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jay_tran/32/47985_2.png) [@Jay\_Tran](https://discuss.elastic.co/u/Jay_Tran)
#### Post date: [January 4, 2020, 2:05am UTC](https://discuss.elastic.co/t/how-to-use-the-connection-that-kibana-is-using-to-elasticsearch-in-kibana-plugin/213669/3 "2020-01-04T02:05:12Z")

</div>

Hi bhavyarm,

currently my plugin connect to Elasticsearch by opening a new connection, I want to know how I can reused the connection kibana is using?

---

<div class="post-metadata">

### Author: ![Gasp3ar](https://avatars.discourse-cdn.com/v4/letter/g/e47774/32.png) [@Gasp3ar](https://discuss.elastic.co/u/Gasp3ar)
#### Post date: [January 4, 2020, 5:55am UTC](https://discuss.elastic.co/t/how-to-use-the-connection-that-kibana-is-using-to-elasticsearch-in-kibana-plugin/213669/4 "2020-01-04T05:55:58Z")

</div>

There is an admin client which is used for managing Kibana's state, and a data client for all other requests[!](https://www.upsers.review/)

---

<div class="post-metadata">

### Author: ![Jay\_Tran](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jay_tran/32/47985_2.png) [@Jay\_Tran](https://discuss.elastic.co/u/Jay_Tran)
#### Post date: [January 6, 2020, 12:19pm UTC](https://discuss.elastic.co/t/how-to-use-the-connection-that-kibana-is-using-to-elasticsearch-in-kibana-plugin/213669/5 "2020-01-06T12:19:41Z")

</div>

Do you have a sample source code that a plugin reuses elasticsearch connection that kibana is using?

---

<div class="post-metadata">

### Author: ![jaytran](https://avatars.discourse-cdn.com/v4/letter/j/db5fbb/32.png) [@jaytran](https://discuss.elastic.co/u/jaytran)
#### Post date: [January 9, 2020, 4:41am UTC](https://discuss.elastic.co/t/how-to-use-the-connection-that-kibana-is-using-to-elasticsearch-in-kibana-plugin/213669/6 "2020-01-09T04:41:02Z")

</div>

so far, I understood how elasticsearch work. We don't need to implement any connectionpool for ES, it already created a connectionpool for per nodes, normally ES there are 13 connections per node, maximun 14(one that is used for node discovery/sniffing/sampling.)

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [February 6, 2020, 4:41am UTC](https://discuss.elastic.co/t/how-to-use-the-connection-that-kibana-is-using-to-elasticsearch-in-kibana-plugin/213669/7 "2020-02-06T04:41:20Z")

</div>

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