Logstash dynamic elasticsearch hosts output

output { 
  elasticsearch { 
     ...
     hosts => ["%{ELASTICSEARCH_URL}"]
  } 
}

Is that possible? Because it is not working within Logstash 6.1.4.

1 Like

That references the ELASTICSEARCH_URL field of the current event. Did you want that, or do you want ${ELASTICSEARCH_URL}, which reference an environment variable?

I want ELASTICSEARCH_URL field of the current event.

Because I am using a condicional in the filter plugin:

if ([headers][request_uri] == "/fep") {
  mutate { add_field => { "ELASTICSEARCH_URL" => "https://e95444bf74974e44b8c8011d48c96f25.rb-elasticsearch.de.bosch.com:9243" } }
}

just if the field [headers][request_uri] is equal /fep that I add to the hosts field the value of the ELASTICSEARCH_URL variable.

I would have expected it to work, but you are right, it does not.

exception=>"Java::JavaNet::URISyntaxException", :message=>"Malformed escape pair at index 0: %{ELASTICSEARCH_URL}", :backtrace=>["java.net.URI$Parser.fail(java/net/URI.java:2848)"

Yes, and I really need that in that way... :frowning_face:

@magnusbaeck: Do you have any idea about that?

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