-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
Environment Variable expansion in Ping plugin #5201
Comments
I think the environment variable is quoted, and ping is trying to ping |
It appears to work if I don't include quotes in the environment variable. For example:
The above works as expected and writes ping data. This tells me that it was a double-quotes issue after all, for whatever reason (clearly I'm not understanding expansion correctly). That said, if I go to add a second domain to the list, it lumps the whole environment variable within that double quotes, causing it to fail as, for exampe, "google.com,gentoo.org" isn't a valid domain name. @danielnelson -- Your reply came in just as I was writing this! You're correct, that's what's happening, and it appears to be correctable by not including the quotes in the environment variable, but prohibits multiple domains this way. I suppose that's a separate issue though, or should I just update this issue title to better reflect what the question now is? |
If it is possible to set the environment variable to
edit: added comma to environment variable value |
I've set the following per your post @danielnelson --
I then set
It makes sense that this should work, though I'm noting that in the Telegraf documentation located here, it explicitly states that string variables need to be quoted. It doesn't necessarily make sense to me why that would be, but it appears that this is why the expected result isn't manifesting. |
It looks like it is because we escape strings, so it turns into something like:
I believe you will need to use separate variables for this. |
Thank you for your help, @danielnelson -- it's appreciated! At this point, in regard to my goal, it looks like I'm just going to have to output a full config as opposed to breaking certain parts of the overall config into smaller files. |
La variable FQDN_LIST puede ser el name de una consulta input.snmp, en donde tenga las ip consultadas por snmp? |
Relevant telegraf.conf:
[[inputs.ping]]
urls = ["$FQDN_LIST"]
Relevant environment variable:
FQDN_LIST="google.com"
System info:
Docker 18.09, running on Windows 10
Steps to reproduce:
Expected behavior:
The environment variable should expand in the IP list as urls = ["google.com"], as printenv FQDN_LIST reports "google.com" for the environment variable. Thus, telegraf should be pinging google.com.
Actual behavior:
[inputs.ping]: Error in plugin: lookup "google.com": no such host
Additional info:
I'm running into this through a Docker Compose exercise in which I'm trying to build a Docker App that starts up a TICK stack with next to no manual configuration on the part of the end user, assuming the end user is running a Windows environment. I've written a rudimentary GUI tool to write a .env file that is imported when the composition is brought up, which includes setting FQDN_LIST and using it in the ping module.
I've considered that perhaps environment variables can't be used with the plugins, but Telegraf is reporting what I believe to be a correctly expanded variable. As the variable is a string, if I remove the quotes (thinking here that maybe it's a double quotes issue?) telegraf exits at startup and using single quotes prevents the variable from expanding, so I'm at a loss here on what to do to get this to work correctly, sans rewriting my configuration tool to output an entire telegraf.conf instead of breaking the config down into smaller individual files.
The text was updated successfully, but these errors were encountered: