# SIngle URL for elastic cluster

**URL:** https://discuss.elastic.co/t/single-url-for-elastic-cluster/274062
**Category:** Elasticsearch
**Created:** [May 26, 2021, 1:23pm UTC](https://discuss.elastic.co/t/single-url-for-elastic-cluster/274062 "2021-05-26T13:23:23Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Bryce\_Fernandes](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bryce_fernandes/32/71166_2.png) [@Bryce\_Fernandes](https://discuss.elastic.co/u/Bryce_Fernandes)
#### Post date: [May 26, 2021, 1:23pm UTC](https://discuss.elastic.co/t/single-url-for-elastic-cluster/274062/1 "2021-05-26T13:23:23Z")

</div>

Hi,

Can we create a single URL for elastic cluster if we have a cluster with 10 12 nodes so we can use a single URL in beats or logstash output.

Regards,  
Bryce Fernandes.

---

<div class="post-metadata">

### Author: ![leandrojmp](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/leandrojmp/32/107231_2.png) [@leandrojmp](https://discuss.elastic.co/u/leandrojmp)
#### Post date: [May 26, 2021, 1:43pm UTC](https://discuss.elastic.co/t/single-url-for-elastic-cluster/274062/2 "2021-05-26T13:43:38Z")

</div>

You can, but you need to use a load balancer tool like NGINX or HAProxy, or use environment variables, at least for Logstash, I'm not sure if the environment variables for hosts will work with the beats.

For logstash you can have a variable named, for example `ES_HOSTS` with all your hosts in the following format.

```auto
ES_HOSTS="https://es1:9200 https://es2:9200 https://esN:9200"

```

Then in your output you will have:

```auto
elasticsearch {
    hosts => ["${ES_HOSTS}"]
}

```

You can have this variable in the environment for the user running logstash, in the `logstash.keystore` [file](https://www.elastic.co/guide/en/logstash/current/keystore.html) or in the `/etc/sysconfig/logstash` file.

I'm not sure if the same approach will work in the beats family, never tested.

The other way would be setting up a load balancer with NGINX, HAProxy or any other similar tool.

---

<div class="post-metadata">

### Author: ![Bryce\_Fernandes](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bryce_fernandes/32/71166_2.png) [@Bryce\_Fernandes](https://discuss.elastic.co/u/Bryce_Fernandes)
#### Post date: [May 26, 2021, 2:13pm UTC](https://discuss.elastic.co/t/single-url-for-elastic-cluster/274062/3 "2021-05-26T14:13:04Z")

</div>

Hi @leandrojmp ,

Thanks for quick reply, I think environment variables is good option for now  
had 2 doubts:

1.In the hosts you mentioned will it be comma separated or as it is.  
2.Can we do it in windows as well if yes which file to edit.

Thanks,  
Bryce Fernandes.

---

<div class="post-metadata">

### Author: ![leandrojmp](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/leandrojmp/32/107231_2.png) [@leandrojmp](https://discuss.elastic.co/u/leandrojmp)
#### Post date: [May 26, 2021, 2:18pm UTC](https://discuss.elastic.co/t/single-url-for-elastic-cluster/274062/4 "2021-05-26T14:18:13Z")

</div>

The variable with the hosts for logstash it is as it is, space separated.

```auto
ES_HOSTS="https://es1:9200 https://es2:9200 https://esN:9200"

```

I do not use windows, but you can use `logstash.keystore` in Windows as well or set an Environment Variable in your system, you need to make sure that this variable is available for the logstash user.

---

<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: [June 23, 2021, 2:18pm UTC](https://discuss.elastic.co/t/single-url-for-elastic-cluster/274062/5 "2021-06-23T14:18:56Z")

</div>

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