I wish to use telegraf with some custom plugins in a docker container (as [[“input.exec”]]). To do so I am using this flag: –config-directory, which works perfectly in the command line but I can’t make it work inside a docker.
My setup : Ubuntu 16.04, docker 17.03, docker-compose 1.13.0
Extract of my docker-compose file :
version: ‘3’
services:
telegraf:
image: telegraf:1.3.2
volumes:
- ./telegraf.conf:/etc/telegraf/telegraf.conf:ro
- ./telegraf.d/:/etc/telegraf/telegraf.d/ # custom *.conf
- ./plugins/:/etc/telegraf/plugins/ # custom plugins
command:
- “–config-directory /etc/telegraf/telegraf.d”
Running with:
docker-compose up
Result:
telegraf_1 | flag provided but not defined: -config-directory /etc/telegraf/telegraf.d
What am I doing wrong ?
Do I need to build my custom telegraf container ?
I tried that too, with FROM: telegraf:1.3.2 and COPY for the config files and plugins, and CMD=["-config-directory /etc/telegraf/telegraf.d/]), but not a complete build (with FROM:alpine-linux for instance)
Everything works as expected on my machine
- in ./plugins, I have the code for the plugins (eg: in python), which output metrics in json format
- in ./telegraf.d, I put my conf file (eg: pythontimer.conf)
My command line is :
telegraf -config ./telegraf.conf --config-directory ./telegraf.d
One example of conf file is:
[[inputs.exec]]
command= "<fullpath>/plugins/simpletimer.py"
data_format = "json"
name_suffix = "_custom"
interval = "10s"