简体   繁体   中英

Configuring Proxy for Logstash

I'm trying to run Logstash to send the output to Elasticsearch through a proxy. As far as I can tell there is no configuration for the output that would allow me to specify a proxy. Currently I use:

output {
  elasticsearch {
    protocol => "http"
    host => "es-dev.local"
    port => "9200"
    index => "logstash-analysis-%{+YYYY.MM.dd}"
    flush_size => "200"
    workers => "2"
    template_name => "logstash_per_index"
  }
}

elasticsearch_http also has no option for that. How can I use a proxy?

Things are quite simple once you know that in the end it's all just plain Java...

In other words Logstash uses Java's system properties to make this work. Then the only piece left is knowing how to specify it. Using environment variable LS_JAVA_OPTS does the trick:

SET LS_JAVA_OPTS=-Dhttp.proxyHost=proxy.local -Dhttp.proxyPort=1337
logstash ...

The downside of this approach is that there can only be one proxy for all outputs. It's not possible to use the proxy for just one output or use different proxies for different outputs.

LS_JAVA_OPTS="-Dhttp.proxyHost=... -Dhttp.proxyPort=..." will effect anything using the java.net stack (ES output happens to be using the apache's http client - wasn't always case and might change)

for the output one should prefer setting proxy => ... on the plugin:

output {
  elasticsearch {
    hosts => 'es.host:9300'
    proxy => "${ES_PROXY:}"
  }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM