# Add multiple host on xpack.monitoring.elasticsearch.hosts with enviroment variable

**URL:** https://discuss.elastic.co/t/add-multiple-host-on-xpack-monitoring-elasticsearch-hosts-with-enviroment-variable/289514
**Category:** Logstash
**Tags:** elastic-stack-monitoring
**Created:** [November 18, 2021, 12:00am UTC](https://discuss.elastic.co/t/add-multiple-host-on-xpack-monitoring-elasticsearch-hosts-with-enviroment-variable/289514 "2021-11-18T00:00:48Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![IsraelPerales](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/israelperales/32/85001_2.png) [@IsraelPerales](https://discuss.elastic.co/u/IsraelPerales)
#### Post date: [November 18, 2021, 12:00am UTC](https://discuss.elastic.co/t/add-multiple-host-on-xpack-monitoring-elasticsearch-hosts-with-enviroment-variable/289514/1 "2021-11-18T00:00:48Z")

</div>

Hi i try monitoring logstash for detect why i have delay on the logs ingest.

But when i try put multiple hosts in the property `xpack.monitoring.elasticsearch.hosts` this fails .

The value is injected with the enviroment variable ELASTIC\_SERVER

This is an example

```auto
xpack.monitoring.enabled: true
xpack.monitoring.elasticsearch.username: ${ELASTIC_USER}
xpack.monitoring.elasticsearch.password: ${ELASTIC_PASS}
xpack.monitoring.elasticsearch.hosts: ['${ELASTIC_SERVER}']

```

And the environment variable have this value

`https://host1:9200,https://host2:9200`

Logstash show this error:

`[2021-11-17T17:32:01,398][ERROR][logstash.licensechecker.licensereader] Unable to retrieve license information from license server {:message=>"URI is not valid - host is not specified"}`

I try different values for the environment variable and logstash.yml but i have same error, only works with one host, if i put more than one, fails.

Examples of values and logstash.yml

```auto
'https://host1:9200,https://host2:9200'
'https://host1:9200','https://host2:9200'
"https://host1:9200,https://host2:9200"
"https://host1:9200","https://host2:9200"

```

```auto
xpack.monitoring.elasticsearch.hosts: ['${ELASTIC_SERVER}']

xpack.monitoring.elasticsearch.hosts: [${ELASTIC_SERVER}]

xpack.monitoring.elasticsearch.hosts: ["${ELASTIC_SERVER}"]

xpack.monitoring.elasticsearch.hosts: '${ELASTIC_SERVER}'

xpack.monitoring.elasticsearch.hosts: '${ELASTIC_SERVER}'

xpack.monitoring.elasticsearch.hosts: ${ELASTIC_SERVER}

```

Actually my conf is:

```auto
https://host1:9200

xpack.monitoring.elasticsearch.hosts: ['${ELASTIC_SERVER}']

```

NOTE: Logstash **7.14.1** run as a pod inside openshift, is a custom image and for now i no have intention to add metricbeat inside to this image.

_Dockerfile fragment_

```auto
ADD logstash-${version}.tar.gz /opt/
ADD root /
ADD offline-plugins /opt/logstash-${version}/offline-plugins
COPY logstash.conf /opt/logstash-${version}/conf/logstash.conf
COPY run /opt/logstash-${version}/
COPY install_plugin /opt/logstash-${version}/
COPY logstash.yml /opt/logstash-${version}/config/

```

---

<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: [November 18, 2021, 3:28pm UTC](https://discuss.elastic.co/t/add-multiple-host-on-xpack-monitoring-elasticsearch-hosts-with-enviroment-variable/289514/2 "2021-11-18T15:28:15Z")

</div>

> [@IsraelPerales](#):
>
> I try different values for the environment variable and logstash.yml but i have same error, only works with one host, if i put more than one, fails.

That is what I would expect. Related answer [here](https://discuss.elastic.co/t/filter-elements-based-on-array-constant-or-array-environment-variable/269074/2).

---

<div class="post-metadata">

### Author: ![IsraelPerales](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/israelperales/32/85001_2.png) [@IsraelPerales](https://discuss.elastic.co/u/IsraelPerales)
#### Post date: [November 25, 2021, 1:02am UTC](https://discuss.elastic.co/t/add-multiple-host-on-xpack-monitoring-elasticsearch-hosts-with-enviroment-variable/289514/3 "2021-11-25T01:02:51Z")

</div>

logstash.conf works,

logstash.yml no, it's for monitoring logstash.

> **[Collect Logstash monitoring data using legacy collectors | Logstash Reference...](https://www.elastic.co/guide/en/logstash/current/monitoring-internal-collection-legacy.html)**

---

<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: [December 23, 2021, 1:03am UTC](https://discuss.elastic.co/t/add-multiple-host-on-xpack-monitoring-elasticsearch-hosts-with-enviroment-variable/289514/4 "2021-12-23T01:03:11Z")

</div>

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