Skip to content

Commit 1c9245f

Browse files
committed
Remove Network IO metrics since they work differently from expectation
1 parent d83c0ec commit 1c9245f

File tree

3 files changed

+19
-51
lines changed

3 files changed

+19
-51
lines changed

cmd/exporter/metrics/proc_metrics.go

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,14 @@ import (
88
)
99

1010
type ProcessMetrics struct {
11-
cpuDuration float64
12-
cpuSampleTime time.Time
13-
ram uint64
14-
swap uint64
15-
diskReadBytes uint64
16-
diskWriteBytes uint64
17-
diskReadCount uint64
18-
diskWriteCount uint64
19-
networkInBytes uint64
20-
networkOutBytes uint64
11+
cpuDuration float64
12+
cpuSampleTime time.Time
13+
ram uint64
14+
swap uint64
15+
diskReadBytes uint64
16+
diskWriteBytes uint64
17+
diskReadCount uint64
18+
diskWriteCount uint64
2119
}
2220

2321
func getProcMetrics(pid int) (processMetrics *ProcessMetrics, err error) {
@@ -45,16 +43,5 @@ func getProcMetrics(pid int) (processMetrics *ProcessMetrics, err error) {
4543
m.diskWriteBytes = ioDisk.WriteBytes
4644
m.diskReadCount = ioDisk.ReadCount
4745
m.diskWriteCount = ioDisk.WriteCount
48-
ioNet, err := proc.NetIOCounters(false)
49-
if err != nil {
50-
return nil, fmt.Errorf("could not read net IO info of PID %d: %w", pid, err)
51-
}
52-
if len(ioNet) > 1 {
53-
return nil, fmt.Errorf("got IO info for multiple NICs seperately when total sum was requested for PID %d", pid)
54-
}
55-
if len(ioNet) == 1 {
56-
m.networkInBytes = ioNet[0].BytesRecv
57-
m.networkOutBytes = ioNet[0].BytesSent
58-
}
5946
return m, nil
6047
}

cmd/exporter/metrics/prom_proc_metrics.go

Lines changed: 8 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,14 @@ import (
1010
)
1111

1212
type PrometheusProcessMetrics struct {
13-
previousMetrics *ProcessMetrics
14-
cpuGauge prometheus.Gauge
15-
ramGauge prometheus.Gauge
16-
swapGauge prometheus.Gauge
17-
diskReadBytesGauge prometheus.Gauge
18-
diskWriteBytesGauge prometheus.Gauge
19-
diskReadCountGauge prometheus.Gauge
20-
diskWriteCountGauge prometheus.Gauge
21-
networkInBytesGauge prometheus.Gauge
22-
networkOutBytesGauge prometheus.Gauge
13+
previousMetrics *ProcessMetrics
14+
cpuGauge prometheus.Gauge
15+
ramGauge prometheus.Gauge
16+
swapGauge prometheus.Gauge
17+
diskReadBytesGauge prometheus.Gauge
18+
diskWriteBytesGauge prometheus.Gauge
19+
diskReadCountGauge prometheus.Gauge
20+
diskWriteCountGauge prometheus.Gauge
2321
}
2422

2523
func newPrometheusProcessMetrics(proc ps.Process, descriptiveName, metricNamespace string) (processMetrics *PrometheusProcessMetrics) {
@@ -28,7 +26,6 @@ func newPrometheusProcessMetrics(proc ps.Process, descriptiveName, metricNamespa
2826
pid := fmt.Sprintf("%d", proc.Pid())
2927
processMetrics.makeGauges(metricNamespace, pid, binaryName, descriptiveName)
3028
processMetrics.makeDiskGauges(metricNamespace, pid, binaryName, descriptiveName)
31-
processMetrics.makeNetworkGauges(metricNamespace, pid, binaryName, descriptiveName)
3229
return processMetrics
3330
}
3431

@@ -80,21 +77,6 @@ func (pm *PrometheusProcessMetrics) makeDiskGauges(metricNamespace, pid, binaryN
8077
})
8178
}
8279

83-
func (pm *PrometheusProcessMetrics) makeNetworkGauges(metricNamespace, pid, binaryName, descriptiveName string) {
84-
pm.networkInBytesGauge = prometheus.NewGauge(prometheus.GaugeOpts{
85-
Namespace: metricNamespace,
86-
Name: "net_read_bytes",
87-
Help: "Total read from disk (bytes)",
88-
ConstLabels: prometheus.Labels{"pid": pid, "bin": binaryName, "name": descriptiveName},
89-
})
90-
pm.networkOutBytesGauge = prometheus.NewGauge(prometheus.GaugeOpts{
91-
Namespace: metricNamespace,
92-
Name: "net_write_bytes",
93-
Help: "Total written to disk (bytes)",
94-
ConstLabels: prometheus.Labels{"pid": pid, "bin": binaryName, "name": descriptiveName},
95-
})
96-
}
97-
9880
func (pm *PrometheusProcessMetrics) Register() error {
9981
registeredCollectors := make([]prometheus.Collector, 0)
10082
var err error
@@ -106,8 +88,6 @@ func (pm *PrometheusProcessMetrics) Register() error {
10688
pm.diskWriteBytesGauge,
10789
pm.diskReadCountGauge,
10890
pm.diskWriteCountGauge,
109-
pm.networkInBytesGauge,
110-
pm.networkOutBytesGauge,
11191
} {
11292
err = prometheus.Register(collector)
11393
if err != nil {
@@ -146,7 +126,5 @@ func (pm *PrometheusProcessMetrics) Set(processMetrics *ProcessMetrics) {
146126
pm.diskWriteBytesGauge.Set(float64(processMetrics.diskWriteBytes))
147127
pm.diskReadCountGauge.Set(float64(processMetrics.diskReadCount))
148128
pm.diskWriteCountGauge.Set(float64(processMetrics.diskWriteCount))
149-
pm.networkInBytesGauge.Set(float64(processMetrics.networkInBytes))
150-
pm.networkOutBytesGauge.Set(float64(processMetrics.networkOutBytes))
151129
pm.previousMetrics = processMetrics
152130
}

go.sum

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6r
1111
github.com/cespare/xxhash/v2 v2.1.0 h1:yTUvW7Vhb89inJ+8irsUqiWjh8iT6sQPZiQzI6ReGkA=
1212
github.com/cespare/xxhash/v2 v2.1.0/go.mod h1:dgIUBU3pDso/gPgZ1osOZ0iQf77oPR28Tjxl5dIMyVM=
1313
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
14+
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
1415
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
1516
github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
1617
github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
@@ -42,6 +43,7 @@ github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3Rllmb
4243
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
4344
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
4445
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
46+
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
4547
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
4648
github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
4749
github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo=
@@ -66,6 +68,7 @@ github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6Mwd
6668
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
6769
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
6870
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
71+
github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q=
6972
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
7073
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
7174
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=

0 commit comments

Comments
 (0)