Logstashのoutput.httpのproxyに動的に設定したい

logstashのoutput.httpにあるproxyをconfを変更せずに外部から動的に変更したいと考えています。

現在以下設定で試したのですがエラーが発生して上手くいきません。
良い方法はないでしょうか?
よろしくお願いいたします。

input {
  stdin{}
}

filter {
  environment {
    add_metadata_from_env => {"proxysrv" => "ProxySrv"}
  }
}
output {
  stdout{
    codec => rubydebug {metadata => true}
  }
  http {
    http_method => "post"
    url => "http://xxx.xxx.xxx.xxx:80"
    http_compression => true
    proxy => "%{[@metadata][proxysrv]}"
  }
}

エラーは以下の通りです。

[2019-07-22T19:58:21,760][ERROR][logstash.outputs.http ] Error in http output loop {:class=>"URI::InvalidURIError", :message=>"bad URI(is not URI?): %{[@metadata][proxysrv]}", :backtrace=>["uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/uri/rfc3986_parser.rb:67:in split'", "uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/uri/rfc3986_parser.rb:73:in parse'", "uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/uri/common.rb:227:in parse'", "C:/Users/test/Desktop/logstash/vendor/bundle/jruby/2.3.0/gems/manticore-0.6.4-java/lib/manticore/client.rb:521:in get_proxy_host'", "C:/Users/test/Desktop/logstash/vendor/bundle/jruby/2.3.0/gems/manticore-0.6.4-java/lib/manticore/client.rb:187:in initialize'", "C:/Users/test/Desktop/logstash/vendor/bundle/jruby/2.3.0/gems/logstash-mixin-http_client-6.0.1/lib/logstash/plugin_mixins/http_client.rb:180:in make_client'", "C:/Users/test/Desktop/logstash/vendor/bundle/jruby/2.3.0/gems/logstash-mixin-http_client-6.0.1/lib/logstash/plugin_mixins/http_client.rb:185:in client'", "C:/Users/test/Desktop/logstash/vendor/bundle/jruby/2.3.0/gems/logstash-output-http-5.2.2/lib/logstash/outputs/http.rb:240:in send_event'", "C:/Users/test/Desktop/logstash/vendor/bundle/jruby/2.3.0/gems/logstash-output-http-5.2.2/lib/logstash/outputs/http.rb:175:in send_events'", "C:/Users/test/Desktop/logstash/vendor/bundle/jruby/2.3.0/gems/logstash-output-http-5.2.2/lib/logstash/outputs/http.rb:124:in multi_receive'", "org/logstash/config/ir/compiler/OutputStrategyExt.java:114:in multi_receive'", "org/logstash/config/ir/compiler/AbstractOutputDelegatorExt.java:97:in multi_receive'", "C:/Users/test/Desktop/logstash/logstash-core/lib/logstash/pipeline.rb:372:in block in output_batch'", "org/jruby/RubyHash.java:1343:in each'", "C:/Users/test/Desktop/logstash/logstash-core/lib/logstash/pipeline.rb:371:in output_batch'", "C:/Users/test/Desktop/logstash/logstash-core/lib/logstash/pipeline.rb:323:in worker_loop'", "C:/Users/test/Desktop/logstash/logstash-core/lib/logstash/pipeline.rb:285:in block in start_workers'"]} [2019-07-22T19:58:21,938][FATAL][logstash.runner ] An unexpected error occurred! {:error=>#<URI::InvalidURIError: bad URI(is not URI?): %{[@metadata][proxysrv]}>, :backtrace=>["uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/uri/rfc3986_parser.rb:67:in split'", "uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/uri/rfc3986_parser.rb:73:in parse'", "uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/uri/common.rb:227:in parse'", "C:/Users/test/Desktop/logstash/vendor/bundle/jruby/2.3.0/gems/manticore-0.6.4-java/lib/manticore/client.rb:521:in get_proxy_host'", "C:/Users/test/Desktop/logstash/vendor/bundle/jruby/2.3.0/gems/manticore-0.6.4-java/lib/manticore/client.rb:187:in initialize'", "C:/Users/test/Desktop/logstash/vendor/bundle/jruby/2.3.0/gems/logstash-mixin-http_client-6.0.1/lib/logstash/plugin_mixins/http_client.rb:180:in make_client'", "C:/Users/test/Desktop/logstash/vendor/bundle/jruby/2.3.0/gems/logstash-mixin-http_client-6.0.1/lib/logstash/plugin_mixins/http_client.rb:185:in client'", "C:/Users/test/Desktop/logstash/vendor/bundle/jruby/2.3.0/gems/logstash-output-http-5.2.2/lib/logstash/outputs/http.rb:240:in send_event'", "C:/Users/test/Desktop/logstash/vendor/bundle/jruby/2.3.0/gems/logstash-output-http-5.2.2/lib/logstash/outputs/http.rb:175:in send_events'", "C:/Users/test/Desktop/logstash/vendor/bundle/jruby/2.3.0/gems/logstash-output-http-5.2.2/lib/logstash/outputs/http.rb:124:in multi_receive'", "org/logstash/config/ir/compiler/OutputStrategyExt.java:114:in multi_receive'", "org/logstash/config/ir/compiler/AbstractOutputDelegatorExt.java:97:in multi_receive'", "C:/Users/test/Desktop/logstash/logstash-core/lib/logstash/pipeline.rb:372:in block in output_batch'", "org/jruby/RubyHash.java:1343:in each'", "C:/Users/test/Desktop/logstash/logstash-core/lib/logstash/pipeline.rb:371:in output_batch'", "C:/Users/test/Desktop/logstash/logstash-core/lib/logstash/pipeline.rb:323:in worker_loop'", "C:/Users/test/Desktop/logstash/logstash-core/lib/logstash/pipeline.rb:285:in block in start_workers'"]}
[2019-07-22T19:58:22,094][ERROR][org.logstash.Logstash ] java.lang.IllegalStateException: Logstash stopped processing because of an error: (SystemExit) exit

データごとに変更したいということですか?
それとも、環境変数であればOKですか?

環境変数の使用方法については、こちらをご覧いただくのが良いかと。
https://www.elastic.co/guide/en/logstash/current/environment-variables.html

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