Bigger size of the telegraf binary

I’m using a Telegraf custom build myself, and had noticed this “issue”… it can be solved by adding some flags and/or limiting the numbers of included plugins.

Note that the additional compression using upx will take a lot more time, and not save that much (a few megabytes), therefore we run the compressed build, and then put the executable in a zip archive… the archive will have the same size as the upx compressed build (and to me, it’s not worth the additional time).
I’ve never been able to achieve the same level of compression of the official release, but it maybe it also depend on your OS (I’m using Windows).

Below my notes about it:

Requirements

  • building requires “make”
  • on Windows install “make” using chocolatey choco install make

Commands

to build just run (from the project folder) make tag="Q1.16.0"

to build and specify the version number run make tag="Q1.16.0" to check the version number on the executable telegraf.exe --version

for build level compression you can use the -s -w flag at command level, like below (to be set in makefile) go build -ldflags "-w -s"

additional compression can be reached by using the upx for compression (on the .exe itself) see: GitHub - upx/upx at v3.96 sample: .\upx.exe --brute telegraf.exe

Lightweight build (your own Telegraf)

In order to limit the size of the executable you can exclude unused plugins from the build. Telegraf checks which plugins to include using the all.go files

  • plugins\outputs\all\all.go
  • plugins\inputs\all\all.go

Those files specify which plugins must be included in the build