# Custom plugin and Elasticsearch client using Java Api

**URL:** <https://discuss.elastic.co/t/custom-plugin-and-elasticsearch-client-using-java-api/147972>\
**Category:** Elasticsearch\
**Created:** [September 10, 2018, 2:20pm UTC](https://discuss.elastic.co/t/custom-plugin-and-elasticsearch-client-using-java-api/147972 "2018-09-10T14:20:59Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![dpupor](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dpupor/32/12251_2.png) [@dpupor](https://discuss.elastic.co/u/dpupor)\
**Post date:** [September 10, 2018, 2:20pm UTC](https://discuss.elastic.co/t/custom-plugin-and-elasticsearch-client-using-java-api/147972/1 "2018-09-10T14:20:59Z")

</div>

Hi!!  
I'm creating a custom plugin to monitorize docs indexed and deleted in elasticsearch indexes. In the plugin I'm using custom settings and a `HttpRestClient` to do the searchs and other stuff. The question here is, in the plugin settings I set the parameters to connect the client with the cluster, but the plugin is already running in a elasticsearch cluster, so I wanna skip this configurations, is there any via I can intialize the client or access to the parameters needed to intialize the client that I can access from elasticsearch and don't need to set in the plugin configuartion?  
Any ideas?

---

<div class="post-metadata">

**Author:** ![rjernst](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rjernst/32/6363_2.png) [@rjernst](https://discuss.elastic.co/u/rjernst)\
**Post date:** [September 13, 2018, 11:57pm UTC](https://discuss.elastic.co/t/custom-plugin-and-elasticsearch-client-using-java-api/147972/2 "2018-09-13T23:57:30Z")

</div>

It depends on which plugin APIs you are extending, but some have access to a NodeClient which you can use to make requests to the cluster.

---

<div class="post-metadata">

**Author:** ![dpupor](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dpupor/32/12251_2.png) [@dpupor](https://discuss.elastic.co/u/dpupor)\
**Post date:** [September 17, 2018, 6:49pm UTC](https://discuss.elastic.co/t/custom-plugin-and-elasticsearch-client-using-java-api/147972/3 "2018-09-17T18:49:40Z")

</div>

Ok, I relative new to Elasticsearch, I searched and found, for example, that the rest api has access to the node client but my plugin not register new endpoints, so, what is the most basic api I should extends mi plugin? Besides, with the node client I can access to the indexes stats?

Thanks for the reply!!

---

<div class="post-metadata">

**Author:** ![rjernst](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rjernst/32/6363_2.png) [@rjernst](https://discuss.elastic.co/u/rjernst)\
**Post date:** [September 17, 2018, 7:03pm UTC](https://discuss.elastic.co/t/custom-plugin-and-elasticsearch-client-using-java-api/147972/4 "2018-09-17T19:03:26Z")

</div>

The `handleRequest` method of `RestHandler` has the node client as an argument, so if you are adding your own rest apis, it should already be available to you.

---

<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:** [October 15, 2018, 7:09pm UTC](https://discuss.elastic.co/t/custom-plugin-and-elasticsearch-client-using-java-api/147972/5 "2018-10-15T19:09:12Z")

</div>

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