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(inputs.ipset): Add metric for number of entries and individual IPs #16124

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

Conversation

verybadsoldier
Copy link

@verybadsoldier verybadsoldier commented Nov 1, 2024

Summary

Some automatic blacklist systems (like e.g. FireHOL) are feeding known malicious IP addresses regularly into ipsets to be blocked by firewalls (e.g. iptables/nftables). It would be useful to be able to track the number of entries of such ipsets over time.

As entries can use CIDR notation to target a range of IPs (e.g. 10.12.4.0/8) with a single ipset entry, it is also useful to see the number of actualy IPs affected by one ipset.

Checklist

  • No AI generated code was used in this PR

Related issues

resolves #16103

@telegraf-tiger telegraf-tiger bot added feat Improvement on an existing feature such as adding a new setting/mode to an existing plugin plugin/input 1. Request for new input plugins 2. Issues/PRs that are related to input plugins labels Nov 1, 2024
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 @verybadsoldier for your contribution. I do have some comments in the code...

plugins/inputs/ipset/ipset.go Outdated Show resolved Hide resolved
plugins/inputs/ipset/ipset_entries.go Outdated Show resolved Hide resolved
plugins/inputs/ipset/ipset_entries.go Outdated Show resolved Hide resolved
plugins/inputs/ipset/ipset_entries.go Outdated Show resolved Hide resolved
plugins/inputs/ipset/ipset.go Outdated Show resolved Hide resolved
plugins/inputs/ipset/ipset_entries.go Outdated Show resolved Hide resolved
plugins/inputs/ipset/ipset_entries_test.go Outdated Show resolved Hide resolved
plugins/inputs/ipset/sample.conf Outdated Show resolved Hide resolved
@srebhan srebhan self-assigned this Nov 4, 2024
@verybadsoldier
Copy link
Author

Thanks for the review comments!

@verybadsoldier
Copy link
Author

Should I resolve the conversation I think I have solved or is that up to you?

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 for the update @verybadsoldier! A few more comments...

plugins/inputs/ipset/ipset.go Outdated Show resolved Hide resolved
plugins/inputs/ipset/ipset_entries.go Outdated Show resolved Hide resolved
plugins/inputs/ipset/ipset_entries.go Outdated Show resolved Hide resolved
plugins/inputs/ipset/ipset_entries.go Outdated Show resolved Hide resolved
plugins/inputs/ipset/ipset_entries.go Outdated Show resolved Hide resolved
@srebhan srebhan changed the title feat(inputs.ipset): add option to include number of entries and numbe… feat(inputs.ipset): Add metric for the tion to include number of entries and numbe of individual IPs Nov 12, 2024
@srebhan srebhan changed the title feat(inputs.ipset): Add metric for the tion to include number of entries and numbe of individual IPs feat(inputs.ipset): Add metric for the number of entries and individual IPs Nov 12, 2024
@srebhan srebhan changed the title feat(inputs.ipset): Add metric for the number of entries and individual IPs feat(inputs.ipset): Add metric for number of entries and individual IPs Nov 12, 2024
* rename misnamed "initialized" parameter
* remove "reset" function
* remove "initSet" function
* return err from addLine instead of adding to acc
* rework switch block in addLine
@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 increases the Telegraf binary size by 2.30 % for linux amd64 (new size: 262.4 MB, nightly size 256.5 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

@verybadsoldier
Copy link
Author

Thanks for bearing with me, I think I addressed all your latest comments now.

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 plugin/input 1. Request for new input plugins 2. Issues/PRs that are related to input plugins
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[inputs.ipset] add metrics for number of entries in ipsets and number of individual IPs (resolve CIDR)
2 participants