Using environment variables

I am trying to execute a conf file and get the following error:
Connecion refused - failed to open TCP connection

The error does not occur when I export the http and https_proxy variables before executing the conf file.

I've read in the documentation for Logstash that: " You can set environment variable references in the configuration for Logstash plugins by using ${var}"

However I don't understand what this means? I assume that I need to edit my conf file to add a reference to these variables, but I am not sure how to do this.

Run printenv in your terminal. These are your enviromoment variables you can use. So if you want to use USER in logstash you would use ${USER} and that would be replaced by the value when you start your pipeline.

1 Like

Thank you. That was helpful!

I've defined the HTTP and HTTPS_PROXY variable for the logstash user.

If I undestood correctly, I should now edit my conf file. However, I'm not sure about the syntax.

The example provided in the documentation uses the tcp_port variable. I assume that for the http, I still need to add:

http {
proxy => "${HTTP_PROXY}"
}

within the scope of input. Is this the correct syntax?

That looks corerct.

1 Like

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