-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
[Metricbeat] add a network_summary metricset #15196
[Metricbeat] add a network_summary metricset #15196
Conversation
jenkins, test this |
efa7888
to
0568dd5
Compare
I believe it is going to be fixed by this PR: #15265 |
} | ||
|
||
// combineMap concatinates two given maps | ||
func combineMap(map1, map2 map[string]int64) map[string]int64 { |
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.
Is there any designated utils package for such functions?
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 don't think I could find any, but someone else might know.
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.
This looks a lot like:
beats/libbeat/common/mapstr.go
Lines 270 to 284 in c115bb1
// MapStrUnion creates a new MapStr containing the union of the | |
// key-value pairs of the two maps. If the same key is present in | |
// both, the key-value pairs from dict2 overwrite the ones from dict1. | |
func MapStrUnion(dict1 MapStr, dict2 MapStr) MapStr { | |
dict := MapStr{} | |
for k, v := range dict1 { | |
dict[k] = v | |
} | |
for k, v := range dict2 { | |
dict[k] = v | |
} | |
return dict | |
} |
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.
So, considering that takes a MapStr
and I have a map[string]int64
I'm not sure whatever memory/performance overhead of copying/casting is worth it.
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.
The memory layout for MapStr would be quite different and we currently have no functions to convert any type into MapStr (in the filebeat-new-registry-file feature branch we have some functionality that can convert between abritrary types). We do not have a designated package for custom map types. Plus MapStr would be a little overkill here.
It's tempting to have a package dealing with common cases in the future once we have generics :), but I'm not keen to use tools that rely on code generation (unless it's very local in another package).
How much of a problem is this in metricbeat? Do we have 10+ modules repeating this piece of code, or is it the first one we ever need this?
If it is no "real" problem, I'd rather keep this function here as is. Small optimization tip: var compMap = make(map[string]int64, len(map1) + len(map2))
.
If we find this to be a real problem, we should discuss it again in a broader context.
metricbeat/module/system/network_summary/network_summary_test.go
Outdated
Show resolved
Hide resolved
metricbeat/module/system/network_summary/network_summary_test.go
Outdated
Show resolved
Hide resolved
netstat -su
What info would you gather from netstat? It would be really nice to be able to graph udp:
In order to troubleshoot udp performance issues on Logstash. |
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 addressing all comments. If there are no more comments, feel free to ship it!
"system": { | ||
"network_summary": { | ||
"icmp": { | ||
"InAddrMaskReps": 0, |
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.
is it common practice in metricbeat to use camel case for a set of 'undocumented' metrics? Do we want to convert to snake case (e.g. github.com/stoewer/go-strcase).
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.
So, my thinking was that since we're inserting "blind" metrics with no real opinionated manipulating of the data, keeping the key values the same as the their OS values might be a good idea. Let me hunt around the system module to see if we do this in other places.
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.
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.
We have done this when ingesting metrics in raw from a source, to avoid confusion. AWS cloudwatch is an example. That said, I don't have a strong opinion here
metricbeat/module/system/network_summary/network_summary_test.go
Outdated
Show resolved
Hide resolved
compMap[k] = checkMaxConn(k, v) | ||
} | ||
return compMap | ||
} |
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.
Now we've got a type similar to common.MapStr
. Consider to split normalizing and merging into separate functions like:
func combineMap(m1, m2 map[string]uint64) common.MapStr {
return common.MapStrUnion(normalizeMap(m1), normalizeMap(m2))
}
func normalizeMap(m map[string]uint64) common.MapStr {
to := common.MapStr{}
for k, v := range {
to[k] = normalize(k, v)
}
return to
}
func normalize(k string, v uint64) interface{} {
if k == "MacConn" {
return int64(v)
}
return v
}
* commit of system/network_summary (cherry picked from commit 8b9ffbd)
Missing from reference config: #15637 |
See #12210
This adds a new
system
metricset,network_summary
, that reports global network counters under Linux. This is a fairly small code addition, as most of the complexity is ingo-sysinfo
. The large diff is because we need to updatego-sysinfo
, and alsogolang.org/x/sys
due to this: elastic/go-sysinfo#67This is a draft as there's two things we need to sort out:
netstat -s
does things, and how the raw data coming off of/proc/net/{snmp,netstat}
is shown.netstat
provides human-readable descriptions and key values, but the actual counters that we get are hard-coded, meaning we don't get 100% of the data the kernel presents. On the other side, the/proc/net
data is complete, but the key values aren't particularly helpful. My philosophy was that we should present as much of the data as we can get in a mapping that's reasonably intuitive, and then maybe provide a dashboard to make the data more human-readableTest plan:
_meta/data.json