Logstash dynamic elasticsearch hosts output


(Eloa Cardoso) #1
output { 
  elasticsearch { 
     ...
     hosts => ["%{ELASTICSEARCH_URL}"]
  } 
}

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


#2

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?


(Eloa Cardoso) #3

I want ELASTICSEARCH_URL field of the current event.


(Eloa Cardoso) #4

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.


#5

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)"

(Eloa Cardoso) #6

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


(Eloa Cardoso) #7

@magnusbaeck: Do you have any idea about that?


(system) #8

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