influxdata / telegraf

Agent for collecting, processing, aggregating, and writing metrics, logs, and other arbitrary data.
https://influxdata.com/telegraf
MIT License
14.63k stars 5.58k forks source link

Enable building telegraf with only specific plugins #14070

Closed mpihlak closed 1 year ago

mpihlak commented 1 year ago

Use Case

With all the plugins the latest Telegraf builds to approximately 245 MB binary (arm64 Mac, stripped). This large binary also contributes to the memory footprint of the program, adding 30+ MB to RSS. This is an issue when running Telegraf on devices with little RAM (ie. Raspberry PI's etc.), where every megabyte counts.

Since often only a handful of plugins are actually used, it would be awesome if there was a feature to explicitly select the plugins to be built in to the binary. As tested this would reduce the binary size and memory requirements considerably. In my use case the binary size goes from 245MB down to 37M and RSS drops from ~70MB to 15MB.

Expected behavior

I don't have this figured out, but maybe it'd be good to specify the plugins to be included in an environment variable, so that the binary could be built without changing any of the files on disk. Something like:

TELEGRAF_ENABLE_INPUT_PLUGINS="cpu mem file kernel" make telegraf

I'm guessing that most folks who would want to do this would just use a handful of plugins and it'd be OK to just list the plugins to enable.

Actual behavior

The same behavior can be achieived by deleting the unwanted plugins from plugins/*/all directories. However since it's not documented anywhere there's no assurance that this will work in later versions. Maybe documenting that this works (if it does?) would be the easisest win.

Additional info

No response

srebhan commented 1 year ago

So why don't you just do it? See documentation... :-) More details can be found in the blog post...

mpihlak commented 1 year ago

Awesome :)

srebhan commented 1 year ago

I'm taking this as "solved" :-) and will close the issue. If you disagree please reopen the issue or open a new issue if you encounter problems. Please also make use of our Slack channel for these "support-type" issues!