Convert examples from table to text to fix rendering issue

tweak

Fixes #5620
This commit is contained in:
DeDe Morton 2016-07-08 19:55:22 -07:00
parent c631ac4aa4
commit fe450a4a74

View file

@ -637,64 +637,61 @@ output {
----------------------------------
[[environment-variables]]
=== Using Environment Variables in Configuration
=== Using Environment Variables in the Configuration
This feature is _experimental_, to enable it you will need to run logstash with the `--allow-env` flag.
==== Overview
* You can set environment variable references into Logstash plugins configuration using `${var}`.
* Each reference will be replaced by environment variable value at Logstash startup.
* You can set environment variable references in the configuration for Logstash plugins by using `${var}`.
* At Logstash startup, each reference will be replaced by the value of the environment variable.
* The replacement is case-sensitive.
* References to undefined variables raise a Logstash configuration error.
* A default value can be given by using the form `${var:default value}`.
* You can add environment variable references in any plugin option type : string, number, boolean, array or hash.
* Environment variables are immutable. If you update the environment variable, you'll have to restart Logstash to pick the updated value.
* You can give a default value by using the form `${var:default value}`. Logstash uses the default value if the
environment variable is undefined.
* You can add environment variable references in any plugin option type : string, number, boolean, array, or hash.
* Environment variables are immutable. If you update the environment variable, you'll have to restart Logstash to pick up the updated value.
==== Examples
[cols="a,a,a"]
|==================================
|Logstash config source |Environment |Logstash config result
|
The following examples show you how to use environment variables to set the values of some commonly used
configuration options.
===== Setting the TCP Port
Here's an example that uses an environment variable to set the TCP port:
[source,ruby]
----
----------------------------------
input {
tcp {
port => "${TCP_PORT}"
}
}
----
----------------------------------
Now let's set the value of `TCP_PORT`:
|
[source,shell]
----
export TCP_PORT=12345
----
|
At startup, Logstash uses the following configuration:
[source,ruby]
----
----------------------------------
input {
tcp {
port => 12345
}
}
----
|
[source,ruby]
----
input {
tcp {
port => "${TCP_PORT}"
}
}
----
----------------------------------
If the `TCP_PORT` environment variable is not set, Logstash returns a configuration error.
You can fix this problem by specifying a default value:
|
No TCP_PORT defined
|
Raise a logstash configuration error
|
[source,ruby]
----
input {
@ -704,9 +701,8 @@ input {
}
----
|
No TCP_PORT defined
|
Now, instead of returning a configuration error if the variable is undefined, Logstash uses the default:
[source,ruby]
----
input {
@ -715,31 +711,13 @@ input {
}
}
----
|
[source,ruby]
----
input {
tcp {
port => "${TCP_PORT:54321}"
}
}
----
|
[source,shell]
----
export TCP_PORT=12345
----
|
[source,ruby]
----
input {
tcp {
port => 12345
}
}
----
|
If the environment variable is defined, Logstash uses the value specified for the variable instead of the default.
===== Setting the Value of a Tag
Here's an example that uses an environment variable to set the value of a tag:
[source,ruby]
----
filter {
@ -749,12 +727,15 @@ filter {
}
----
|
Let's set the value of `ENV_TAG`:
[source,shell]
----
export ENV_TAG="tag2"
----
|
At startup, Logstash uses the following configuration:
[source,ruby]
----
filter {
@ -763,7 +744,11 @@ filter {
}
}
----
|
===== Setting a File Path
Here's an example that uses an environment variable to set the path to a log file:
[source,ruby]
----
filter {
@ -774,12 +759,16 @@ filter {
}
}
----
|
Let's set the value of `HOME`:
[source,shell]
----
export HOME="/path"
----
|
At startup, Logstash uses the following configuration:
[source,ruby]
----
filter {
@ -790,7 +779,7 @@ filter {
}
}
----
|==================================
[[config-examples]]
=== Logstash Configuration Examples