telegraf: External Environment Variables are not set when running Telegraf
Relevant telegraf.conf:
[global_tags]
env = "ENVIRONMENT"
[agent]
interval = "60s"
hostname = "telegraf-snmp-compute-leafs"
omit_hostname = false
[[outputs.wavefront]]
host = "$WF_PROXY"
port = $WF_PORT1
metric_separator = "."
convert_paths = true
use_regex = false
[[inputs.snmp]]
agents = [AGENTS]
version = 3
auth_password = "$TELEGRAF_SNMP_TOKEN"
auth_protocol = "MD5"
priv_password = "$TELEGRAF_SNMP_TOKEN"
priv_protocol = "AES"
sec_name = "$SNMP_SECURITY_USER"
sec_level = "authPriv"
max_repetitions = 10
timeout = "10s"
retries = 1
name_prefix = "dev."
[[inputs.snmp.field]]
name = "hostname"
oid = ".1.3.6.1.2.1.1.5.0"
is_tag = true
[[inputs.snmp.field]]
name = "cseSysCPUutilization"
oid = ".1.3.6.1.4.1.9.9.305.1.1.1.0"
[[inputs.snmp.field]]
name = "cseSysUpTime"
oid = ".1.3.6.1.4.1.9.9.305.1.1.10.0"
[[inputs.snmp.field]]
name = "cseSysMemoryUtilization"
oid = ".1.3.6.1.4.1.9.9.305.1.1.2.0"
[[inputs.snmp.table]]
name = "interfaceStats"
inherit_tags = ["hostname"]
[[inputs.snmp.table.field]]
name = "ifAlias"
oid = ".1.3.6.1.2.1.31.1.1.1.18"
is_tag = true
[[inputs.snmp.table.field]]
name = "ifName"
oid = ".1.3.6.1.2.1.31.1.1.1.1"
is_tag = true
[[inputs.snmp.table.field]]
name = "ifType"
oid = ".1.3.6.1.2.1.2.2.1.3"
[[inputs.snmp.table.field]]
name = "ifInNUcastPkts"
oid = "1.3.6.1.2.1.2.2.1.12"
[[inputs.snmp.table.field]]
name = "ifInDiscards"
oid = "1.3.6.1.2.1.2.2.1.13"
[[inputs.snmp.table.field]]
name = "ifInErrors"
oid = "1.3.6.1.2.1.2.2.1.14"
[[inputs.snmp.table.field]]
name = "ifOutUcastPkts"
oid = "1.3.6.1.2.1.2.2.1.14"
[[inputs.snmp.table.field]]
name = "ifOutNUcastPkts"
oid = "1.3.6.1.2.1.2.2.1.18"
[[inputs.snmp.table.field]]
name = "ifOutDiscards"
oid = "1.3.6.1.2.1.2.2.1.19"
[[inputs.snmp.table.field]]
name = "ifOutErrors"
oid = "1.3.6.1.2.1.2.2.1.20"
[[inputs.snmp.table.field]]
name = "ifMtu"
oid = "1.3.6.1.2.1.2.2.1.4"
System info:
DOCKER CONTAINER RUNNING telegraf:1.10-alpine
Steps to reproduce:
- Build Docker Container and set appropriate Environment Variables. Afterwards the config file in the container does not have the appropriate values.
- When creating env variable that is not a string, get a
Error running agent: Error parsing /etc/telegraf/telegraf.conf, toml: line 9: parse error - Have tried the variables with “${SNMP_SECURITY_USER}” and with just “$SNMP_SECURITY_USER” and neither seem to work. Currently it works when I run the config with a sed command, but would like to pass in the variables directly instead.
Expected behavior:
The environment variables that are set in the container are populated in the config file when telegraf starts.
Actual behavior:
Getting either a parse error or the environment variable is just showing up with the variable name instead of the value.
Additional info:
Have tried the Telegraf Alpine versions 9, 10 and 10.5 and still not working.
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 19 (7 by maintainers)
Can anyone summaries the solution? I tried all possible solutions but not working for me. My Telegraf version is 1.13.2
Running Telegraf in docker-compose.
I receive
unsupported scheme ["${INFLUX_URL}"]error.With Telegraf 1.10.4 you will need to use the format without braces:
$INFLUXDB_ADMIN_USER. The${}format will be new in 1.11.