How can we set hosts dynamicaly in elasticsearch plugin in logstash conf file ? I am setting document_type => "%{type}" and type is substitued here. so cant we substitute %{host} ? for hosts parameter?

How can we set hosts dynamicaly in elasticsearch plugin in logstash conf file ? I am setting document_type => "%{type}" and type is substitued here. so cant we substitute %{host} ? for hosts parameter??

You can do something like this - https://www.elastic.co/guide/en/logstash/current/environment-variables.html

HOSTNAME environment variable is already set. And I am using it as hosts => ["${HOSTNAME}"]. But its showing error "bad URI(is not URI?): http://${HOSTNAME}:9200/". Then I added a flag --allow-env. But its showing error

Clamp::UsageError: Unrecognised option '--allow-env'
signal_usage_error at /home/workload/logstash-2.2.0/vendor/bundle/jruby/1.9/gems/clamp-0.6.5/lib/clamp/command.rb:103
find_option at /home/workload/logstash-2.2.0/vendor/bundle/jruby/1.9/gems/clamp-0.6.5/lib/clamp/option/parsing.rb:62
parse_options at /home/workload/logstash-2.2.0/vendor/bundle/jruby/1.9/gems/clamp-0.6.5/lib/clamp/option/parsing.rb:28
parse at /home/workload/logstash-2.2.0/vendor/bundle/jruby/1.9/gems/clamp-0.6.5/lib/clamp/command.rb:52
run at /home/workload/logstash-2.2.0/vendor/bundle/jruby/1.9/gems/logstash-core-2.2.0-java/lib/logstash/runner.rb:79
call at org/jruby/RubyProc.java:281
run at /home/workload/logstash-2.2.0/vendor/bundle/jruby/1.9/gems/logstash-core-2.2.0-java/lib/logstash/runner.rb:95
call at org/jruby/RubyProc.java:281
initialize at /home/workload/logstash-2.2.0/vendor/bundle/jruby/1.9/gems/stud-0.0.22/lib/stud/task.rb:24

You need to upgrade, that was not available in 2.2.

I am getting same error with 2.3