# Cannot read elasticsearch.hosts from kibana configuration

**URL:** <https://discuss.elastic.co/t/cannot-read-elasticsearch-hosts-from-kibana-configuration/269232>\
**Category:** Kibana\
**Tags:** kibana-plugin-development\
**Created:** [April 5, 2021, 12:10pm UTC](https://discuss.elastic.co/t/cannot-read-elasticsearch-hosts-from-kibana-configuration/269232 "2021-04-05T12:10:33Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![K\_Chaitanya](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/k_chaitanya/32/46387_2.png) [@K\_Chaitanya](https://discuss.elastic.co/u/K_Chaitanya)\
**Post date:** [April 5, 2021, 12:10pm UTC](https://discuss.elastic.co/t/cannot-read-elasticsearch-hosts-from-kibana-configuration/269232/1 "2021-04-05T12:10:33Z")

</div>

Hi all,

We were trying to read the elasticsearch cluster hosts in out plugin's server-side, but we were unable to find anything in the `context` parameter in callback function.

as shown in below code:

```auto
export function defineRoutes(router: IRouter, client: IScopedClusterClient, config: HttpServerInfo) {
router.get(
    {
      path: '/endpoint',
      validate: false,
    },
    async (context, request, response) => {
      const requestOptions = {
        method: 'GET',
        headers: { 'Content-Type': 'application/json', 'Cluster': process.env["cluster"], 'Authorization': request.headers.authorization },
        agent: httpsAgent
      };
      const info = await context.core.elasticsearch.client.asCurrentUser.nodes.info()
      return fetch(serverURL + '/endpoint/', requestOptions)
        .then(response => {
          logger.info('Enpoint: Endpoint success');
          logger.info(info)
          
          if (response.status == 200) {
            return response.json()
          } else {
            throw new Error(response)
          }
        }).then(res => {
          return response.ok({
            body: {
              Response: res
            },
          });
        })
        .catch(async (err) => {
          logger.info('EndPoint : ' + err);
          let message_ = await err.text().then(mm => {
            return mm;
          });
          var resp_ = response.custom({
            body: {
              message: message_
            },
            statusCode: err.status
          });
          return resp_;
        });
    }
  );
}

```

Neither I was able to find in `const cluster = await config.hostname` with the `HttpServerInfo`.

Please suggest any alternatives to retrieve the desired information.

Thanks and regards  
Chaitanya

---

<div class="post-metadata">

**Author:** ![mattkime](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mattkime/32/43522_2.png) [@mattkime](https://discuss.elastic.co/u/mattkime)\
**Post date:** [April 5, 2021, 2:59pm UTC](https://discuss.elastic.co/t/cannot-read-elasticsearch-hosts-from-kibana-configuration/269232/2 "2021-04-05T14:59:32Z")

</div>

Hello @K_Chaitanya

Which version of the Elastic stack are you using? Why do you want access to `elasticsearch.hosts`? Are you looking to make an Elasticsearch query?

Thanks,  
Matt

---

<div class="post-metadata">

**Author:** ![K\_Chaitanya](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/k_chaitanya/32/46387_2.png) [@K\_Chaitanya](https://discuss.elastic.co/u/K_Chaitanya)\
**Post date:** [April 6, 2021, 5:29am UTC](https://discuss.elastic.co/t/cannot-read-elasticsearch-hosts-from-kibana-configuration/269232/3 "2021-04-06T05:29:27Z")

</div>

Hi @mattkime ,

Thank you for your reply.

We running our ELK stack on version: 7.10.1

We have a decoupled architecture with Django in place with our Kibana plugin, so there is a scenario where a single Django API instance will communicate with different Elasticsearch deployments (we running on ECK).

So as to make python API aware of the Elasticsearch instance with which it needs to talk, we need to pass the hosts' information to python API.

Thanks,  
Chaitanya

---

<div class="post-metadata">

**Author:** ![mattkime](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mattkime/32/43522_2.png) [@mattkime](https://discuss.elastic.co/u/mattkime)\
**Post date:** [April 6, 2021, 2:12pm UTC](https://discuss.elastic.co/t/cannot-read-elasticsearch-hosts-from-kibana-configuration/269232/4 "2021-04-06T14:12:51Z")

</div>

I'm not sure how Django is communicating with your kibana plugin but I'd encourage you to use the query functionality available via the Kibana APIs rather than having Django make requests.

I'm checking to see if `elasticsearch.hosts` is exposed and will report back.

* * *

Update - Its not exposed.

---

<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:** [May 4, 2021, 2:13pm UTC](https://discuss.elastic.co/t/cannot-read-elasticsearch-hosts-from-kibana-configuration/269232/5 "2021-05-04T14:13:25Z")

</div>

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