# Externalization of hosts settings in output

**URL:** https://discuss.elastic.co/t/externalization-of-hosts-settings-in-output/253680
**Category:** Logstash
**Created:** [October 29, 2020, 11:08am UTC](https://discuss.elastic.co/t/externalization-of-hosts-settings-in-output/253680 "2020-10-29T11:08:55Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![sunilmchaudhari](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sunilmchaudhari/32/9475_2.png) [@sunilmchaudhari](https://discuss.elastic.co/u/sunilmchaudhari)
#### Post date: [October 29, 2020, 11:08am UTC](https://discuss.elastic.co/t/externalization-of-hosts-settings-in-output/253680/1 "2020-10-29T11:08:55Z")

</div>

Hi,  
I have a logstash indexing to 3 elasticsearch nodes.  
The output filter is as below:  
elasticsearch  
{  
hosts =\> ["[https://myHost9a.vsi.uat.dbs.com:9202](https://myhost9a.vsi.uat.dbs.com:9202/)", "[https://myHost10a.vsi.uat.dbs.com:9202](https://myhost10a.vsi.uat.dbs.com:9202/)", "[https://myHost11a.vsi.uat.dbs.com:9202](https://myhost11a.vsi.uat.dbs.com:9202/)" ]  
index =\> "index\_name\_missing-%{+YYYY.MM.dd}"  
timeout =\> 300  
ssl =\> true

}

you can ignore the syntax and other settings. I am only concerned about the hosts setting.  
In future, It may happen that I remove myHost11a.  
So, If I have 3 such instances of logstash with 5 pipelines, then I have to change the output config from 3\*5=15 output files.

is there any way, where I can mention some proxy or dummy names in actual config files and original host names will be there in some external file with key value pair.  
Then I will change only the external file. I will remove the thir node from external file and restart logstash, OR logstash will auto reload it.  
So that after restart logstash will not index to the "myHost11a".

So basically I want to know if there is possibility of externalization of the hosts setting, where instead of mentioning actual ES hosts I will give some dummy values which will be read from external txt file?

Regards,  
Sunil.

---

<div class="post-metadata">

### Author: ![ylasri](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ylasri/32/86120_2.png) [@ylasri](https://discuss.elastic.co/u/ylasri)
#### Post date: [October 29, 2020, 12:30pm UTC](https://discuss.elastic.co/t/externalization-of-hosts-settings-in-output/253680/2 "2020-10-29T12:30:31Z")

</div>

You can use [environment-variables](https://www.elastic.co/guide/en/logstash/current/environment-variables.html)

---

<div class="post-metadata">

### Author: ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)
#### Post date: [October 29, 2020, 4:00pm UTC](https://discuss.elastic.co/t/externalization-of-hosts-settings-in-output/253680/3 "2020-10-29T16:00:53Z")

</div>

> [@ylasri](#):
>
> You can use [environment-variables](https://www.elastic.co/guide/en/logstash/current/environment-variables.html)

Are you sure about that? My recollection is that elasticsearch will treat a string that look like an array as a string, not an array, so it will not parse the hostname correctly.

---

<div class="post-metadata">

### Author: ![ylasri](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ylasri/32/86120_2.png) [@ylasri](https://discuss.elastic.co/u/ylasri)
#### Post date: [October 29, 2020, 5:24pm UTC](https://discuss.elastic.co/t/externalization-of-hosts-settings-in-output/253680/4 "2020-10-29T17:24:50Z")

</div>

Hi @Badger, Thanks for comenting, i would agree with you for parameter that accept arrays  
There is a specific [PR](https://github.com/elastic/logstash/pull/12051) for URI array that has been fixed and i guess that would adress this issue.

So Something like this should work

```auto
export ES_HOSTS="es1.example.com es2.example.com:9201 es3.example.com:9201"

```

```auto
output {
  elasticsearch {
    hosts => "${ES_HOSTS}"
  }
}

```

---

<div class="post-metadata">

### Author: ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)
#### Post date: [October 29, 2020, 5:35pm UTC](https://discuss.elastic.co/t/externalization-of-hosts-settings-in-output/253680/5 "2020-10-29T17:35:09Z")

</div>

> [@ylasri](#):
>
> There is a specific [PR](https://github.com/elastic/logstash/pull/12051) for URI array that has been fixed

Excellent!

---

<div class="post-metadata">

### Author: ![sunilmchaudhari](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sunilmchaudhari/32/9475_2.png) [@sunilmchaudhari](https://discuss.elastic.co/u/sunilmchaudhari)
#### Post date: [October 31, 2020, 6:33am UTC](https://discuss.elastic.co/t/externalization-of-hosts-settings-in-output/253680/6 "2020-10-31T06:33:28Z")

</div>

Hi @ylasri,  
I already tried Env variable before I saw your reply. However, I tried this way with comma separated.

export ES\_HOSTS="[es1.example.com](http://es1.example.com), [es2.example.com:9201](http://es2.example.com:9201) [es3.example.com:9201](http://es3.example.com:9201)"

This was giving error. Current version I am using is, 7.5.0  
May I will try without comma separated.  
If that doesnt work, Let me know whether I have to upgrade.

regards,  
Sunil.

---

<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: [November 28, 2020, 6:33am UTC](https://discuss.elastic.co/t/externalization-of-hosts-settings-in-output/253680/7 "2020-11-28T06:33:35Z")

</div>

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