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

Add NetStat to parse /proc/net/stat/... #316

Merged
merged 14 commits into from Aug 9, 2021
Merged

Conversation

AlexZzz
Copy link
Contributor

@AlexZzz AlexZzz commented Jun 30, 2020

This PR is a step to expose arp/ndisc/route cache stats from /proc/net/stat/. It was described in the issue prometheus/node_exporter#1626.

I decided to make it similar to lnstat tool, so it will parse all new files in /proc/net/stat in future.

Copy link
Collaborator

@pgier pgier 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 contribution! I added a few in-line comments. I think the struct could be changed to better match the structure of the data. For example, each header name could be the key of a struct which points to a slice of the cpu values.

type NetStat struct {
    Filename string
    Stats map[string]uint64[]
}

Also, since this is a new feature, can you add a test for this?

lnstat.go Outdated Show resolved Hide resolved
lnstat.go Outdated Show resolved Hide resolved
lnstat.go Outdated Show resolved Hide resolved
lnstat.go Outdated Show resolved Hide resolved
@AlexZzz
Copy link
Contributor Author

AlexZzz commented Jul 3, 2020

Thank you for the review!
I've changed data structure, also added a test.

Copy link
Member

@discordianfish discordianfish left a comment

Choose a reason for hiding this comment

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

LGTM!
Just not 100% sure about the name. Maybe we should just call it NetStats?

@AlexZzz
Copy link
Contributor Author

AlexZzz commented Jul 6, 2020

I thought about the name, but there's /proc/net/netstat file already, and it is used by node-exporter netstat collector, so netstats name will add mess, IMO.

It could be named netcache, or something related to network-and-cache. But if there is a new file under /proc/net/stat and it is not about cache, it will be confusing again:)

@discordianfish
Copy link
Member

Oh right, hrm yeah I guess lnstat is fine then - unless somebody else has a better idea. @SuperQ @pgier

@AlexZzz
Copy link
Contributor Author

AlexZzz commented Jul 20, 2020

@pgier @SuperQ , any suggestions?

@SuperQ
Copy link
Member

SuperQ commented Jul 20, 2020

We still need to port over the /proc/net/netstat (and snmp/snmp6) parsing from the node_exporter. So we don't have a naming conflict to worry about. We do have a bit of a precedent for /proc/net/sockstat -> NetSockstat. I wish there was some documentation about this outside of the lnstat man page. I can't find anything in the usual kernel.org/doc.

Maybe slightly confusing, but how about we follow this pattern:

  • /proc/net/netstat -> NetNetstat
  • /proc/net/stat/* -> NetStat

@AlexZzz
Copy link
Contributor Author

AlexZzz commented Jul 20, 2020

* `/proc/net/netstat` -> `NetNetstat`
* `/proc/net/stat/*` -> `NetStat`

I think this looks good, because it looks like a naming convention really: name consists of path. I'll rename Lnstat to NetStat then. And here we don't care about the name of the collector, right? I mean, we're leaving lnstat and netstat collectors names and they'll work with NetStat and NetNetstat structs, right?

@SuperQ
Copy link
Member

SuperQ commented Jul 20, 2020

If you're talking about the node_exporter collector name, Yes, we could call it --collector.lnstat to match the normal user utility. That seems right to me. What do you think @discordianfish?

@SuperQ
Copy link
Member

SuperQ commented Jul 21, 2020

When digging through some other issues/PRs, I discovered we already have some partial parsing of /proc/net/stat in #254.

How do we want to handle this? We have prometheus/node_exporter#1155 open to add handling of nf_conntrack to the node_exporter, but this would be duplicated by lnstat.

@pgier Should we use this generic parser instead of the conntrack parser?

@AlexZzz
Copy link
Contributor Author

AlexZzz commented Nov 5, 2020

@pgier , @SuperQ , how is it going?
I would like to vote for this generic parser:)

Copy link
Member

@discordianfish discordianfish left a comment

Choose a reason for hiding this comment

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

Ok, let's merge this. We can make net_conntrackstat.go use the parser here.

@AlexZzz
Copy link
Contributor Author

AlexZzz commented Nov 24, 2020

@discordianfish , btw, I also have a wip pr with more generic metrics exposer which will expose conntrack stats if they appear at /proc/net/stat: prometheus/node_exporter#1771

@discordianfish
Copy link
Member

What should we do with this now that prometheus/node_exporter#1155 has been merged?

@AlexZzz
Copy link
Contributor Author

AlexZzz commented Jul 13, 2021

I suggest, prometheus/node_exporter#1155 might be reverted in favor of this one 😂

IMHO, it's better to have generic parser for any metric and any file, instead of hard-code here. Kernel API shouldn't be changed and files format should always be the same. Any new metric will be exposed with no human interaction with generic parser.

@discordianfish
Copy link
Member

@AlexZzz I agree, lets rebase this and merge it, then create an issue to track using this to replace the conntrack stats in node-exporter.

@AlexZzz AlexZzz force-pushed the lnstat branch 3 times, most recently from 062efc4 to 448ddf5 Compare July 16, 2021 11:26
Signed-off-by: Aleksei Zakharov <zaharov@selectel.ru>
Signed-off-by: Aleksei Zakharov <zaharov@selectel.ru>
Signed-off-by: Aleksei Zakharov <zaharov@selectel.ru>
Signed-off-by: Aleksei Zakharov <zaharov@selectel.ru>
Signed-off-by: Aleksei Zakharov <zaharov@selectel.ru>
Signed-off-by: Aleksei Zakharov <zaharov@selectel.ru>
Signed-off-by: Aleksei Zakharov <zaharov@selectel.ru>
Signed-off-by: Aleksei Zakharov <zaharov@selectel.ru>
Signed-off-by: Aleksei Zakharov <zaharov@selectel.ru>
Signed-off-by: Aleksei Zakharov <zaharov@selectel.ru>
Signed-off-by: Aleksei Zakharov <zaharov@selectel.ru>
Signed-off-by: Aleksei Zakharov <zaharov@selectel.ru>
Signed-off-by: Aleksei Zakharov <zaharov@selectel.ru>
Signed-off-by: Aleksei Zakharov <zaharov@selectel.ru>
@AlexZzz
Copy link
Contributor Author

AlexZzz commented Jul 16, 2021

@discordianfish , rebased.

@discordianfish
Copy link
Member

cc/ @SuperQ

Copy link
Member

@SuperQ SuperQ left a comment

Choose a reason for hiding this comment

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

LGTM

@SuperQ SuperQ changed the title Lnstat Add NetStat to parse /proc/net/stat/... Aug 9, 2021
@SuperQ SuperQ merged commit f436cbb into prometheus:master Aug 9, 2021
remijouannet pushed a commit to remijouannet/procfs that referenced this pull request Oct 20, 2022
* Add NetStat to parse /proc/net/stat/...

Signed-off-by: Aleksei Zakharov <zaharov@selectel.ru>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants