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: socketstat input plugin #3649

Merged
merged 127 commits into from
Dec 22, 2021
Merged

feat: socketstat input plugin #3649

merged 127 commits into from
Dec 22, 2021

Conversation

sajoupa
Copy link
Contributor

@sajoupa sajoupa commented Jan 9, 2018

Required for all PRs:

  • Signed CLA.
  • Associated README.md updated.
  • Has appropriate unit tests.

Hi,

The ss command (package iproute2) gives very useful metrics about sockets on Linux machines, this is a plugin to expose them with telegraf.

Thanks.

@danielnelson
Copy link
Contributor

@sajoupa Thanks for the pull request. I think there may be two high level concerns with this pr:

  • Since a new series is made for every state+src+dst, this output format will be very high cardinality, you will probably need to pair this with a short retention policy to avoid overloading your database.
  • Shelling out to ss will be somewhat expensive, perhaps we can bypass this and directly retrieve the data from /proc or another method.

@sajoupa
Copy link
Contributor Author

sajoupa commented Feb 13, 2018

Hi @danielnelson , you're totally right about data cardinality, I added a warning to the README.
I'm quite reluctant to parse /proc/net/ however. We would duplicate (and then maintain) logic which is already implemented by ss. I don't think that it would be worth it, given the small cost of shelling out to ss.

I have also updated the code to make the same changes which had been requested for the ipset input plugin (use a timeout, buffio scanner, ... ref #3346)

@danielnelson
Copy link
Contributor

I'm not sure if I will want to merge this in, in the meantime we can leave the pr open for anyone who would like to use it.

@sajoupa
Copy link
Contributor Author

sajoupa commented Feb 16, 2018

@danielnelson which of the two reasons you first mentioned would block this ?
I can replace shelling out to ss by parsing /proc (I believe it's better to shell out, but both solutions work), however, there's no reducing data cardinality if we want to get ss data.
My intent is to have ss exported data sent to graylog. According to https://github.com/Graylog2/graylog-plugin-netflow and https://www.graylog.org/post/snmp-netflow-plug-ins-extend-graylog-network-infrastructure-support, graylog can handle the cardinality of network packets metadata.
I just find it a lot more convenient to get data from telegraf agents than network equipments. (also, activating netflow on network equipments won't help for cloud VMs).
Thanks.

@danielnelson
Copy link
Contributor

Shelling out to ss is the bigger issue, we can add warnings to the documentation about cardinality and how to deal with it.

@sajoupa
Copy link
Contributor Author

sajoupa commented Mar 30, 2018

@danielnelson Hi, I looked further into it and think shelling out is the only option.
ss uses the tcp_diag kernel module to get its data much faster than parsing /proc/net (https://www.cyberciti.biz/files/ss.html). Also, /proc/net won't provide counters such as bytes_acked, received, etc.
And after looking at ss's 4900+ lines of code, I'm not sure we want to recreate them into telegraf ;)

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 your patience @sajoupa! There are a few additional improvements I'd like to see going in. Some are just a matter of taste, so please speak-up if you don't like them.

plugins/inputs/socketstat/socketstat.go Outdated Show resolved Hide resolved
plugins/inputs/socketstat/socketstat.go Outdated Show resolved Hide resolved
plugins/inputs/socketstat/socketstat.go Outdated Show resolved Hide resolved
plugins/inputs/socketstat/socketstat.go Outdated Show resolved Hide resolved
plugins/inputs/socketstat/socketstat.go Outdated Show resolved Hide resolved
@telegraf-tiger
Copy link
Contributor

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.

Awesome! Thanks for driving this home @sajoupa! LGTM.

@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 Dec 22, 2021
@powersj powersj merged commit 911c0a9 into influxdata:master Dec 22, 2021
@sajoupa
Copy link
Contributor Author

sajoupa commented Dec 23, 2021

Awesome! Thanks for driving this home @sajoupa! LGTM.

Cheers, thanks for the patient reviews.

powersj pushed a commit to powersj/telegraf that referenced this pull request Jan 21, 2022
@sajoupa sajoupa deleted the socketstat branch February 2, 2022 07:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new plugin plugin/input 1. Request for new input plugins 2. Issues/PRs that are related to input plugins 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
Development

Successfully merging this pull request may close these issues.

5 participants