-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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 linux conntrack metrics to host metrics receiver #3370
Add linux conntrack metrics to host metrics receiver #3370
Conversation
@mx-psi |
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 left some comments :)
receiver/hostmetricsreceiver/internal/scraper/networkscraper/config.go
Outdated
Show resolved
Hide resolved
receiver/hostmetricsreceiver/internal/scraper/networkscraper/factory.go
Outdated
Show resolved
Hide resolved
receiver/hostmetricsreceiver/internal/scraper/networkscraper/network_linux.go
Outdated
Show resolved
Hide resolved
} | ||
|
||
// newNetworkScraper creates a set of Network related metrics | ||
func newNetworkScraper(_ context.Context, cfg *Config) (*scraper, error) { | ||
scraper := &scraper{config: cfg, bootTime: host.BootTime, ioCounters: net.IOCounters, connections: net.Connections} | ||
scraper := &scraper{config: cfg, bootTime: host.BootTime, ioCounters: net.IOCounters, connections: net.Connections, conntrack: net.FilterCounters} |
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.
Should we use FilterCountersWithContext
instead, so that we can pass the context in case we want to have cancellation at some point?
Not super convinced that we should do this here (IOCounters
also has IOCountersWithContext
and we are not using it), so maybe you can just open an issue and we can deal with it in a separate PR.
@@ -293,6 +293,22 @@ metrics: | |||
monotonic: false | |||
labels: [network.protocol, network.state] | |||
|
|||
system.network.conntrack.count: |
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 am not knowledgeable enough about macOS or Windows to know if there are equivalents to conntrack in these OSs. It might be a good idea to check this and make the name more general in case we want to add support for other platforms later.
A good way to get feedback on this is to open a PR on the https://github.com/open-telemetry/opentelemetry-specification repository so that other people can chime in.
receiver/hostmetricsreceiver/internal/scraper/networkscraper/network_scraper_test.go
Outdated
Show resolved
Hide resolved
Unit tests are failing with
|
@mx-psi First of all, thank you for the review. Still trying to understand why the e2e test fails, running the same docker image with this branch seems to work fine. |
@mx-psi Please review again.
Although they exist:
I believe it happens because the |
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.
Looks good, just one documentation comment! I think it's fine to not have the conntrack end to end test (but maintainers may disagree with me)
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.
Looks good to me! Now an approver/maintainer should have a look; remember that the focus is on getting to GA so please be patient; if this doesn't get attention feel free to raise this on the CNCF Slack
This PR was marked stale due to lack of activity. It will be closed in 7 days. |
Not stale but I don't have permissions to remove the label (I hope this comment is enough to mark it as active) |
This PR was marked stale due to lack of activity. It will be closed in 7 days. |
Hi! I'm commenting to remove the stale label. mx-psi is on vacation but will be reviewing this when he's back :) |
@emilgelman can you update the PR with the new |
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 code looks good, I added some suggestions to change the code from IntSum to Sum as per @mx-psi's recommendation, please take a look.
|
||
func assertNetworkConntrackMetricValid(t *testing.T, metric pdata.Metric, descriptor pdata.Metric) { | ||
internal.AssertDescriptorEqual(t, descriptor, metric) | ||
assert.Equal(t, 1, metric.IntSum().DataPoints().Len()) |
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.
assert.Equal(t, 1, metric.IntSum().DataPoints().Len()) | |
assert.Equal(t, 1, metric.Sum().DataPoints().Len()) |
func initializeNetworkConntrackMetric(metric pdata.Metric, metricIntf metadata.MetricIntf, now pdata.Timestamp, value int64) { | ||
metricIntf.Init(metric) | ||
|
||
idps := metric.IntSum().DataPoints() |
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.
idps := metric.IntSum().DataPoints() | |
idps := metric.Sum().DataPoints() |
func initializeNetworkConntrackDataPoint(dataPoint pdata.IntDataPoint, now pdata.Timestamp, value int64) { | ||
dataPoint.SetTimestamp(now) | ||
dataPoint.SetValue(value) |
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.
func initializeNetworkConntrackDataPoint(dataPoint pdata.IntDataPoint, now pdata.Timestamp, value int64) { | |
dataPoint.SetTimestamp(now) | |
dataPoint.SetValue(value) | |
func initializeNetworkConntrackDataPoint(dataPoint pdata.NumberDataPoint, now pdata.Timestamp, value int64) { | |
dataPoint.SetTimestamp(now) | |
dataPoint.SetIntVal(value) |
description: Number of currently allocated flow entries. | ||
unit: "{flow entries}" | ||
data: | ||
type: int sum |
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.
type: int sum | |
type: sum |
description: Size of connection tracking table. | ||
unit: "{flow entries}" | ||
data: | ||
type: int sum |
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.
type: int sum | |
type: sum |
@@ -59,6 +59,8 @@ type metricStruct struct { | |||
ProcessDiskIo MetricIntf |
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 will need to be regenerated after the suggestions are merged to change from IntSum
to Sum
This PR was marked stale due to lack of activity. It will be closed in 7 days. |
This PR was marked stale due to lack of activity. It will be closed in 7 days. |
@emilgelman sorry, unfortunately this needs to be moved to contrib, since we moved the hostmetricsreceiver there. |
Description:
Added support for collecting conntrack metrics (linux only) using the host metrics receiver. The metrics are taken from https://github.com/shirou/gopsutil (already being used in the receiver)