-
Notifications
You must be signed in to change notification settings - Fork 3.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support Environment Variable in conditionals #5115
Comments
@githubmui The environment variable option was mostly added for substituting values, and not using it in conditional. But it seems this is a good usecase too. I'll keep this open as an enhancement. |
Hi, |
As a workaround you could use mutate and metadata fields
|
The usage in
|
any update on this ? currently I am using the same approach as @IrlJidel, but it's more convenient to have the env. var. in the condition |
I also want conditional inputs based on comparisons with environmental variables:
This is because I wish to have development and production inputs in the one configuration stack and control the mode of the pipeline using |
+1 I also would like to change behaviour based upon environment variables. |
+1 for being able to use environment variables in conditionals. |
Was very surprised and sad to find that I couldn't do this. I would have thought that environment variables would substitute anywhere in the config on load. Really confused as to why this isn't the case. |
+1 |
+1 although my desired use case is something like:
Using psuedo code for the conditional because I'm not sure what the best way to check based on the current documentation, but that's a different topic. |
You need to assign the environment variable to a field then do your if
statement. I assign it to metadata fields so they don't make it through the
output ie. `[@metadata][es-hosts]`
…On 14 Feb. 2017 6:38 am, "Addy Kim" ***@***.***> wrote:
+1 although my desired use case is something like:
output {
stdout { codec => rubydebug }
if ${ELASTICSEARCH_HOST} is set {
elasticsearch {
hosts => ["${ELASTICSEARCH_HOST}"]
...
}
}
}
Using psuedo code for the conditional because I'm not sure what the best
way to check based on the current documentation
<https://www.elastic.co/guide/en/logstash/current/event-dependent-configuration.html>,
but that's a different topic.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#5115 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AL4NqhRIchkUc_uDD7yja6f698g8cXG3ks5rcL9UgaJpZM4IHD4b>
.
|
Can't get @IrlJidel 's workaround working on logstash 5.2.1. My conditionals are getting ignored. E.g., this always writes to localhost:9200: input { filter { output { I've tried miriad variations to no success :( |
+1 - just found this, and tried the other method first. |
Can elastic please call this out in documentation or put a warning for it at least? Got blocked for most of a day wondering what the hell I was doing wrong. |
+1 |
Would be great to see this feature being worked on. |
Hi, |
any progress? |
Any update on this issue? This is something we would really like to use in our pipelines. |
Can we please push this? It's a very useful feature that been requested for years. |
I have a customer who opened a Support Ticket because his use of conditional logic on an env variable was being rejected as an error. In fact this is a very desirable enhancement and the existing documentation, while not showing examples of using an ENV within a conditional statement, does not explicitly forbid such use. |
This is affecting me too. I just spent hours backtracking and making changes to my configs on a new build that's using a lot of variables. Any progress on this? |
Anyone using env variables with conditionals? I need something like this:
|
There have been a few users that have expressed interest in this functionality, as this would be a desirable enhancement in order to satisfy their use cases. +1 for being able to use environment variables in conditionals. |
I'm also voting for this one, it will definitely be helpful to control the Logstash pipelines using environment variables. |
any progress? |
I'd love to see this feature as well! |
Environment variable expansion only works in plugin parameters, not in conditionals. For more on this limitation see #5115
Environment variable expansion only works in plugin parameters, not in conditionals. For more on this limitation see #5115
) Environment variable expansion only works in plugin parameters, not in conditionals. For more on this limitation see elastic#5115 (cherry picked from commit 096eb7a)
) Environment variable expansion only works in plugin parameters, not in conditionals. For more on this limitation see elastic#5115 (cherry picked from commit 096eb7a)
This PR substitutes ${VAR} in Expression, except RegexValueExpression, with the value in secret store, env. The substitution happens after syntax parsing and before graph execution. Fixed: #5115
This PR substitutes ${VAR} in Expression, except RegexValueExpression, with the value in secret store, env. The substitution happens after syntax parsing and before graph execution. Fixed: elastic#5115
This PR substitutes ${VAR} in Expression, except RegexValueExpression, with the value in secret store, env. The substitution happens after syntax parsing and before graph execution. Fixed: elastic#5115
Logstash 7.17 has a fix for this issue |
Is it possible to use this feature to check if an environment variable is set? Something like:
I'm having trouble getting this to work. |
@brunobastosg You can alternatively check by the following
You can give a default value by using the form |
@kaisecheng does logstash still try to parse the http_poller block? Because after I tried your suggestion I got the following error:
Apparently it tried to validate the url Here is the logstash.conf file:
|
@brunobastosg |
Sorry, I hadn't noticed that in the documentation. I assumed it could be anywhere. Thank you for your time! |
FYI . VAR cannot be evaluated to a number, hence cannot do number comparison. |
Hi,
in LS 2.3.0. I have got the problem that following expression doesn't evaluate to TRUE (if environment variable doesn't exists).
if "${LS_ENDP_JDBC:a}" == "a" { ... }
Thx in advance for reply.
The text was updated successfully, but these errors were encountered: