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


I'm running Logstash with Environment variable configuration. I'm also trying to follow Using Environment Variables in the Configuration to define Elasticsearch output plugin.

my environment variable:

# grep HOSTS .env

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

Please advise.

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.

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.

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}" ]

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...

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