Add Modbus TCP input configuration with Docker

noob’s question (sorry): I’d test Telegraf with Modbus TCP since the input plugin was recently added but here

the method starts from assumption, if I understand correctly, that with the installed Telegraf instance you can create a .conf file passing -filter-input to the command line but… how would I do that with a Dockerized Telegraf instance? I’ve searched on the DockerHub page but can’t figure out.

You would only want to use --filter-input when testing, normally you would want to run all the plugins defined in the configuration file. However, if you do want to pass cli options to Telegraf in the container you can just tack them onto the end of the docker run command:

docker run telegraf --filter-config modbus --test

Also, you probably know this but, the modbus plugin is not yet in the latest official docker image. It will only be in the official container once 1.14.0 releases (hopefully next week). We haven’t done it in the past, but if you are interested I will work on an image of the release candidate that I could publish to

Daniel, at first thanks for your super fast and kind answer, that said:

  • if I understand correctly the --input-filter command parameter is to generate a .conf file with the specified input “activated” (two other questions come to mind but I’ll try to discover myself! - 1. how and where and when Telegraf retrieves plug-in, go package? go modules? -; 2. telegraf.conf file is packed with input/output/etc. parameters, the ones you specify in the --input-filter command where are going to appear? at the end? at their supposed place? -)
  • the --input-filter way command is best suited for test and not for production
  • the --input-filter command can also be used with docker in the way you showed me
  • in a week or so Modbus TCP input plug-in will be in the official 1.14.0 release and so its paramters should appear in the telegraf.conf template file at their place (maybe something like [[inputs.modbus]]

I appreciate also your will to make an image for me, too kind of you, I can wait a week or two no problem, I’m really impatient to test Telegraf with PLCs and Modbus is a handy and fast protocol I’m used to since a lifetime… (even if I’m waiting for OPC UA too :slight_smile:).

Thanks again

Daniel, I’ve tryed to do what you suggest, I get this:

flag provided but not defined: -filter-config

Thank you

Sorry about the confusion, I’m not sure why my fingers typed --filter-config but I meant to write --input-filter.

You are correct that this option is useful when generating a configuration file. Another use that I had more in mind was with the --test option, and there it is used to limit which plugin is tested. When generating the configuration you can also pair it with --output-filter and others to reduce the configuration size, this will give you a minimal configuration for modbus -> influxdb:

telegraf --input-filter modbus --processor-filter none --aggregator-filter none --output-filter influxdb config

All the plugins are currently built into the telegraf binary itself, it’s a bit of a misnomer. Let us know if you have more questions.

Daniel it works! But… I suppose having the latest 1.13.4 stable release under the input configuration of the .conf file there is nothing :smiley:
If I try with another released plugin, for example jenkins, at the end of the file I find all the parameters.
I’m here waiting for the 1.14 (then more questions will come out for sure)!