Skip to content
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(processors.batch): Add batch processor #15869

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

LarsStegman
Copy link
Contributor

@LarsStegman LarsStegman commented Sep 11, 2024

Summary

This new processor can distribute metrics across batches by adding a tag indicating what batch number it is in. This makes it possible to distribute the load of a high number of metrics across multiple instances of the same output plugin.

Checklist

  • No AI generated code was used in this PR

Related issues

resolves #15621
resolves #11707

@telegraf-tiger telegraf-tiger bot added feat Improvement on an existing feature such as adding a new setting/mode to an existing plugin plugin/processor labels Sep 11, 2024
@LarsStegman
Copy link
Contributor Author

@srebhan the implementation is a little different than what you suggested. I did not see the added benefit of also specifying the batch size, since any overflow would probably just overflow into the next batch, which then also overflows. Please let me know if it should still be added.

Copy link
Member

@srebhan srebhan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @LarsStegman for the contribution! Just two small comments from my side. Furthermore, should we also add a force_rebatch option that will only overwrite the batch tag if it does not already exists? I'm asking because in the current default, Telegraf will run each processor twice, once before and once after aggregators if any.

plugins/processors/batch/batch.go Outdated Show resolved Hide resolved
plugins/processors/batch/README.md Outdated Show resolved Hide resolved
@srebhan srebhan self-assigned this Sep 11, 2024
@LarsStegman
Copy link
Contributor Author

should we also add a force_rebatch option that will only overwrite the batch tag if it does not already exists? I'm asking because in the current default, Telegraf will run each processor twice, once before and once after aggregators if any.

Hmmm interesting. The results after the second pass will indeed be different, because the processor will already have run a pass and the count will have increased. I think it is better to add that feature indeed. It will be more predictable for users.

@LarsStegman
Copy link
Contributor Author

I made the rebatching enabled by default, because it is less computational load. By default it will now not check the existing tags.

Copy link
Member

@srebhan srebhan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two more comments. Regarding the flag, I'm fine either way but slightly tend to your approach...

plugins/processors/batch/sample.conf Outdated Show resolved Hide resolved
plugins/processors/batch/batch_test.go Outdated Show resolved Hide resolved
@srebhan srebhan changed the title feat(processors.batch): create batch processor feat(processors.batch): Add batch processor Sep 11, 2024
@LarsStegman

This comment was marked as outdated.

Copy link
Member

@srebhan srebhan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@LarsStegman awesome! Maybe just avoid abbreviations in config options? How about naming this just batches?

plugins/processors/batch/sample.conf Outdated Show resolved Hide resolved
@LarsStegman
Copy link
Contributor Author

@srebhan looks like the test runner timed out or something

Copy link
Member

@srebhan srebhan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @LarsStegman!

@telegraf-tiger
Copy link
Contributor

Download PR build artifacts for linux_amd64.tar.gz, darwin_arm64.tar.gz, and windows_amd64.zip.
Downloads for additional architectures and packages are available below.

🥳 This pull request decreases the Telegraf binary size by -8.01 % for linux amd64 (new size: 239.8 MB, nightly size 260.6 MB)

📦 Click here to get additional PR build artifacts

Artifact URLs

DEB RPM TAR GZ ZIP
amd64.deb aarch64.rpm darwin_amd64.tar.gz windows_amd64.zip
arm64.deb armel.rpm darwin_arm64.tar.gz windows_arm64.zip
armel.deb armv6hl.rpm freebsd_amd64.tar.gz windows_i386.zip
armhf.deb i386.rpm freebsd_armv7.tar.gz
i386.deb ppc64le.rpm freebsd_i386.tar.gz
mips.deb riscv64.rpm linux_amd64.tar.gz
mipsel.deb s390x.rpm linux_arm64.tar.gz
ppc64el.deb x86_64.rpm linux_armel.tar.gz
riscv64.deb linux_armhf.tar.gz
s390x.deb linux_i386.tar.gz
linux_mips.tar.gz
linux_mipsel.tar.gz
linux_ppc64le.tar.gz
linux_riscv64.tar.gz
linux_s390x.tar.gz

@srebhan srebhan added the ready for final review This pull request has been reviewed and/or tested by multiple users and is ready for a final review. label Sep 13, 2024
@srebhan srebhan assigned DStrand1 and unassigned srebhan Sep 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat Improvement on an existing feature such as adding a new setting/mode to an existing plugin new plugin plugin/processor ready for final review This pull request has been reviewed and/or tested by multiple users and is ready for a final review.
Projects
None yet
3 participants