-
Notifications
You must be signed in to change notification settings - Fork 5.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Tool to customize Telegraf builds #11524
Conversation
Thanks, @srebhan, for tackling the minify work. There is clearly a need for users to have a smaller telegraf. Two initial questions as to the design of this
|
Hey @powersj,
There were multiple reasons to support both ways:
In all the above cases users will be forced to write a "Telegraf configuration-file" without the help of globbing and black-/whitelisting which might be cumbersome. Furthermore, configuring My goal was to provide easy ways to cover both, having a working config and only using what is in there and cases where you don't have a config or want to extend it.
My thoughts were the following:
All of the above being said, I think both design decisions are well justified. However, if the decision is to remove both, I can do this. In this case, I think, there is no point in having |
@srebhan, thanks for the background. It does help to understand your approach.
In the spec, Telegraf configuration files are the center of the design. The assumption was that minify was for users who already knew what they wanted and desired a smaller Telegraf binary. I would argue that if someone does not know what plugins they may or may not use, then they have no business using minify in the first place. That user must continue to determine what is best for their use cases, and only after determining what they need to use minify.
Nothing should stop users from accomplishing this with a Telegraf config. While the spec declared that we expected a valid Telegraf configuration, I think it is more accurate to say we expect a valid TOML file that specifies the plugins required. If a user wanted to include additional plugins, then they could pass any number of "empty" plugin sections (e.g. re: minify in build, I need more time to digest that. |
@powersj first of all thanks for the helpful discussion!
All specified use cases of the specs work IIRC, so there is no trade-off here.
As I said, it is possible, but please give examples for the following use-cases and estimate their effort
Please find my examples for the 3 attached (created by hand). You also did not address the issue that in larger organizations or external service companies the one building Telegraf has potentially no access to the config files... |
We had a virtual discussion about this and I think this boils down to these questions:
@srebhan feel free to update/re-word those questions :) edit: I updated the questions based on your invite! |
After internal discussion the decision was to
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the updates! I really do appreciate you driving this, and I am excited to see what our users say.
I have a few changes to the README and a couple of questions.
Have you run this at least once on Windows? I can run it on my Mac later as well.
The docs and code look good to me. Thanks for putting this together! I'd approve now except that I am still concerned about what we're naming this tool. (Sorry to be picky about naming at the last minute and for also rejecting your first name choice, "bob") I think our audience of users and developers are more familiar with minify or minification being the process of making code (especially interpreted code like javascript or markup like html) smaller by removing unnecessary characters like whitespace, while retaining all the functionality of the original version. When I google "minify" I get things only with this specific definition. This tool leaves the whitespace alone and builds a smaller binary by removing functionality. That is not minifying. I think if we use the name "minify" it will be a source of confusion and that when people see it for the first time they will think it doesn't remove functionality. They will also know telegraf is written in a compiled language and will wonder why it even has a tool to remove unnecessary characters in source code. Previous proposals for this kind of tool used these names
I'd like the name to indicate what it does and not be a codename or inside joke. It doesn't need to include "telegraf" because it is in the telegraf repo in the tools directory. Since this tool produces custom builds that include only the plugins that are necessary for a given configuration, the name should include a term like custom, specialized, reduced, lite, or minimal. Of those I think minimal stands out because it also makes you think small size is the point. It's a more general term than "minify" and doesn't already have a software connotation. The other tools in telegraf/tools use underscores instead of dashes. What does everyone think of renaming this to telegraf/tools/minimal_builder? |
@reimda no worries, I think naming is important here to make this discoverable.... I like |
Yay! A bikeshed we can paint together! Here's my In the future, I envisaged that Telegraf would have three distinct options for users to pick from when selecting which build of Telegraf best suits their use case.
I believe the terms Complete, Core and Custom enable us to very clearly identify what kind of build a customer or community member is using, when helping in issues or other support avenues. I do agree that "minify" has become the internal "codename" or shorthand for the feature which builds "Telegraf Custom". I also see that it's an overloaded term, as it's often used to obfuscate or shrink an existing source codebase like JavaScript to reduce transmission time, and hide the operation of the code. I don't believe we want to obfuscate or hide anything. So for that reason perhaps we should seek some name other than "minifiy" so as not to be associated with this existing use case. I like terms to reflect exactly what they do. Given this tool is building a custom telegraf, I feel the words are right in front of us.
|
team consensus: |
@powersj name changed... |
@@ -277,7 +280,14 @@ func runAgent(ctx context.Context, | |||
|
|||
logger.SetupLogging(logConfig) | |||
|
|||
log.Printf("I! Starting Telegraf %s", version) | |||
log.Printf("I! Starting Telegraf %s%s", version, internal.Customized) | |||
log.Printf("I! Available plugins: %d inputs, %d aggregators, %d processors, %d parsers, %d outputs", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I love this additional output, thank you!
I built with a config of just inputs.diskio
and outputs.file
and I ended up seeing:
2022-08-16T17:43:50Z I! Available plugins: 3 inputs, 0 aggregators, 0 processors, 0 parsers, 2 outputs
Which are:
telegraf-sven on minify [?] via 🐹 v1.19
❯ ./telegraf --input-list
Available Input Plugins:
diskio
io
system
telegraf-sven on minify [?] via 🐹 v1.19
❯ ./telegraf --output-list
Available Output Plugins:
file
wavefront
Two questions:
- Why is wavefront pulled in? I understand the other inputs due to dependencies
- Should we document this in the README, additional plugins may get pulled in due to dependencies. This could be a single sentence added to the readme.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems wavefront
is coming through the backyard. ;-) The route is
file
output importsgh.neting.cc/influxdata/telegraf/plugins/serializers
serializers/registry.go
importsgh.neting.cc/influxdata/telegraf/plugins/serializers/wavefront
wavefront
serializer importsgh.neting.cc/influxdata/telegraf/plugins/outputs/wavefront
😨
This happens with the epic comment:
// TODO: this dependency is going the wrong way: Move MetricPoint into the serializer.
🤦♂️
I guess this has to be fixed, but is not an issue of custom_builder
... What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we document this in the README, additional plugins may get pulled in due to dependencies. This could be a single sentence added to the readme.
Absolutely. Will do.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lol @ that comment, let's circle around and fix that after this is merged. I can file an issue.
Also tested on Arch, M1 mac, and Windows 10. |
Cross builds look good too (btw this is why I want us to continue to print out the GOOS and GOARCH values during a build, really nice to see it was correctly passed in logs):
|
… plugins per category on startup.
Download PR build artifacts for linux_amd64.tar.gz, darwin_amd64.tar.gz, and windows_amd64.zip. 📦 Click here to get additional PR build artifactsArtifact URLs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎉 thank you, I really like how this ended up!
resolves #9556
replaces #8519
replaces #5809
This PR adds a tool to reduce the binary size of Telegraf by only including user-selected plugins in the build. A Telegraf binary only including the
modbus
input plugin, theinfluxdb
output plugin as well as thestarlark
processor, but noparser
will be ~18Mb in size. See the includedREADME.md
for more details.