# exception=\>"Java::JavaNet::URISyntaxException", :message=\>"Illegal character in path at index 0: \[\\"esi1\\",\\"esi2\\"\]"

**URL:** <https://discuss.elastic.co/t/exception-java-urisyntaxexception-message-illegal-character-in-path-at-index-0-esi1-esi2/165456>\
**Category:** Logstash\
**Created:** [January 23, 2019, 4:44pm UTC](https://discuss.elastic.co/t/exception-java-urisyntaxexception-message-illegal-character-in-path-at-index-0-esi1-esi2/165456 "2019-01-23T16:44:05Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![alexus](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/alexus/32/12696_2.png) [@alexus](https://discuss.elastic.co/u/alexus)\
**Post date:** [January 23, 2019, 4:44pm UTC](https://discuss.elastic.co/t/exception-java-urisyntaxexception-message-illegal-character-in-path-at-index-0-esi1-esi2/165456/1 "2019-01-23T16:44:05Z")

</div>

Hello,

I'm running Logstash with [Environment variable configuration](https://www.elastic.co/guide/en/logstash/current/docker-config.html#docker-env-config). I'm also trying to follow [Using Environment Variables in the Configuration](https://www.elastic.co/guide/en/logstash/current/environment-variables.html) to define [Elasticsearch output plugin](https://www.elastic.co/guide/en/logstash/current/plugins-outputs-elasticsearch.html#plugins-outputs-elasticsearch-hosts).

my environment variable:

```
# grep HOSTS .env
HOSTS=["esi1","esi2"]
# 

```

yet, getting following message through Logstash' logs:

> [2019-01-23T16:31:56,508][ERROR][logstash.agent] Failed to execute action {:action=\>LogStash::PipelineAction::Create/pipeline\_id:X, :exception=\>"Java::JavaNet::URISyntaxException", :message=\>"Illegal character in path at index 0: ["esi1","esi2"]",...

however, if I use single host instead of multiple (array), everything works as expected:

```
# grep ^HOSTS .env
HOSTS=esi1:9200
# 

```

Please advise.

---

<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:** [January 23, 2019, 4:54pm UTC](https://discuss.elastic.co/t/exception-java-urisyntaxexception-message-illegal-character-in-path-at-index-0-esi1-esi2/165456/2 "2019-01-23T16:54:28Z")

</div>

I think this is working as expected. The configuration parser does not convert a string that looks like an array into an array when it does variable substitution. So the plugin thinks it has a single URI, not an array of URIs.

---

<div class="post-metadata">

**Author:** ![alexus](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/alexus/32/12696_2.png) [@alexus](https://discuss.elastic.co/u/alexus)\
**Post date:** [January 23, 2019, 5:00pm UTC](https://discuss.elastic.co/t/exception-java-urisyntaxexception-message-illegal-character-in-path-at-index-0-esi1-esi2/165456/3 "2019-01-23T17:00:09Z")

</div>

It only works as expected if I use _single_ host (defined via string) instead of _multiple_ hosts (defined via array), I'm trying to get to multiple hosts instead of using single host.

---

<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:** [January 23, 2019, 5:13pm UTC](https://discuss.elastic.co/t/exception-java-urisyntaxexception-message-illegal-character-in-path-at-index-0-esi1-esi2/165456/4 "2019-01-23T17:13:23Z")

</div>

Yes, I understand what you are trying to do. The code that processes hosts expects to receive either a string containing a single host, or an array containing mulitple hosts. When you do that variable substitution it gets passed a string containing multiple hosts, and that does not work.

If it is always two hosts then you can use

```
hosts => ["${HOST1}", "${HOST2}"]
```

---

<div class="post-metadata">

**Author:** ![alexus](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/alexus/32/12696_2.png) [@alexus](https://discuss.elastic.co/u/alexus)\
**Post date:** [January 23, 2019, 5:57pm UTC](https://discuss.elastic.co/t/exception-java-urisyntaxexception-message-illegal-character-in-path-at-index-0-esi1-esi2/165456/5 "2019-01-23T17:57:43Z")

</div>

while this may work, it is more of workaround rather then a solution... as this has hard coded number of hosts and the whole idea of using environment variables is so it can be easily adjusted if needed and in your case if additional host is added, one would have to change environment variable _AND_ pipeline...

---

<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:** [February 20, 2019, 5:57pm UTC](https://discuss.elastic.co/t/exception-java-urisyntaxexception-message-illegal-character-in-path-at-index-0-esi1-esi2/165456/6 "2019-02-20T17:57:44Z")

</div>

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