Bigger size of the telegraf binary

I need some help
I am building telegraf from the github source code:

amd64=1 make telegraf_1.20.0~3b20b93a-0_amd64.deb

but when I install it from dpkg, the size of the binary in /usr/bin/telegraf is 122M, while when it’s installed from apt-get from the repo(not custom build) it(/usr/bin/telegraf ) takes around 29M
What parameters do I pass to optimise the size of the binary I built via the custom deb file

Hi there. I think this looks about right.

The deb in the repo is ~33MB, and when unpacked it’s ~122MB. I just built from the repo, and the deb is 34MB and the telegraf binary inside is 127MB

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:


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


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