I am using Telegraf - version 1.0.0
I tried using environment variables in telegraf.conf but Telegraf is not replacing them.

2016/09/22 09:08:13 Tags enabled: environment=$APP_ENV host=863eeea1c23b owner=$APP_OWNER stack=$APP_STACK
Are you running telegraf as a service? does the telegraf user have these env variables? try sudo -u telegraf printenv
closing for lack of updates, feel free to reopen if it's not apermission issue
Telegraf is running as a service on Ubuntu 14.04 inside a Docker container.
printenv shows the environment variables APP_ENV, APP_OWNER, APP_STACK
that doesn't answer the question of whether the env vars are accessible to the telegraf user
This is not working for me too.
I can answer your question sparrc.
I am running telegraf as a service and when I tried the command sudo -u telegraf printenv . It doesn't print the environment variables what I export.
But in the Configuration comments It says the one below,
Environment variables can be used anywhere in this config file, simply prepend
them with $. For strings the variable must be within quotes (ie, "$STR_VAR"),
for numbers and booleans they should be plain (ie, $INT_VAR, $BOOL_VAR)
Global tags can be specified here in key="value" format.
[global_tags]
dc = "us-east-1" # will tag all metrics with dc=us-east-1
rack = "1a"
Environment variables can be used as tags, and throughout the config file
user = "$USER"
If sudo -u telegraf printenv did not print the environment variables then they are not available for telegraf. How are you defining them?
I am exporting those variables through bash. Also I tried setting manually like export VPCNAME="test" and tried overriding the hostname in configuration like hostname="$VPCNAME". How we have to make the environment available for telegraf?
If you export a variable from your shell, it will only affect that shell and child shells. Try putting the definitions in /etc/default/telegraf which gets sourced when the service starts.
Cool. That worked. Thanks danielnelson. you may need to update this information in the telegraf.conf environment variables section.
Most helpful comment
Cool. That worked. Thanks danielnelson. you may need to update this information in the telegraf.conf environment variables section.