plugins/common/shim/README.md
The goal of this shim is to make it trivial to extract an internal input, processor, or output plugin from the main Telegraf repo out to a stand-alone repo. This allows anyone to build and run it as a separate app using one of the execd plugins:
plugins/inputs/cpu, it's recommended that it also be under plugins/inputs/cpu
in the new repo. For a further example of what this might look like, take a
look at ssoroka/rand or
danielnelson/telegraf-pluginscmd folder. This will be the entrypoint to the plugin when run as
a stand-alone program, and it will call the shim code for you to make that
happen. It's recommended to have only one plugin per repo, as the shim is not
designed to run multiple plugins at the same time (it would vastly complicate
things)._ "github.com/me/my-plugin-telegraf/plugins/inputs/cpu"go build -o rand cmd/main.go./rand -config plugin.confDepending on your polling settings and whether
you implemented a service plugin or an input gathering plugin, you may see
data right away, or you may have to hit enter first, or wait for your poll
duration to elapse, but the metrics will be written to STDOUT. Ctrl-C to end
your test. If you're testing a processor or output manually, you can still do
this but you will need to feed valid metrics in on STDIN to verify that it is
doing what you want. This can be a very valuable debugging technique before
hooking it up to Telegraf.[[inputs.execd]]
command = ["/path/to/rand", "-config", "/path/to/plugin.conf"]
signal = "none"
Refer to the execd plugin readmes for more information.
You've done it! Consider publishing your plugin to github and open a Pull Request back to the Telegraf repo letting us know about the availability of your external plugin.