Alpine telegraf configurable through environment
10K+
based on telegraf:alpine docker image
BC Breaking Change in the environments:
The image is now using a small go utility (toml_update) to read, modify and write a valid toml configuration file.
# before
TEL_AGENT_HOSTNAME=hostname = "myhostname"
TEL_OUTPUTS_INFLUXDB_URLS=urls = ["http://yourinfluxhost:8086"]
TEL_INPUTS_CPU_FLAGS = "percpu = true\ntotalcpu = true"
# after
TEL_AGENT_NAMEDOESNOTMATTER=agent.hostname=myhostname
TEL_REALLYDOESNOTMATTER=outputs.influxdb.urls=["https://yourinfluxhost:8086"]
TEL_CPUFLAG1=inputs.cpu.percpu=true
TEL_CPUFLAG2=inputs.cpu.totalcpu=true
Try it in 3 steps
docker run --rm -it drpsychick/telegraf:latest cat /default.env > telegraf.env
Edit at least your hostname and output (influxdb or sth. else) in telegraf.env:
TLG_AGENT_HOSTNAME=agent.hostname="myhostname"
TLG_INFLUXDB_URL=outputs.influxdb.urls=["http://yourinfluxhost:8086"]
You can add as many variables as you want for more inputs and their configuration, there are only a few rules:
CONF_PREFIX variable in default.env)For more examples see default.env
TLG_INPUTS_CPU_PERCPU=inputs.cpu.percpu=true
TLG_INPUTS_CPU_TOTAL=inputs.cpu.totalcpu=true
TLG_INPUTS_CPU_TIME=inputs.cpu.collect_cpu_time=false
TLG_INPUTS_CPU_ACTIVE=inputs.cpu.report_active=false
The toml_update tool will take the configured prefixes in order and update the configuration file from all matching variables one-by-one.
Run in a separate teminal
docker run --rm -it --cap-add NET_ADMIN --env-file telegraf.env --name telegraf-1 drpsychick/telegraf:latest telegraf --test
docker run --rm -it --cap-add NET_ADMIN --env-file telegraf.env --name telegraf-1 drpsychick/telegraf:latest
Check your influxdb for new input
You can use any TLG_ variable in your telegraf.env. They will be added to the config during container startup.
TLG_INPUTS_DISK_FLAGS=inputs.disk.ignore_fs=["tmpfs", "devtmpfs", "devfs"]
Beware:
Docker only support simple variables. No ", no ' and especially no newlines in variables.
Content type
Image
Digest
sha256:b1b95db29…
Size
100.5 MB
Last updated
1 day ago
docker pull drpsychick/telegraf