Skip to content

Commit f1694b4

Browse files
committed
Fix undercounting of EC2 awsvpc network stats
As discussed in #4618, it seems that scaling down these network stats by the number of containers is simply incorrect. On that issue, I have empirically compared EC2 awsvpc numbers to both Fargate awsvpc and EC2 bridge numbers to deduce this. Fixes #4618.
1 parent eaff425 commit f1694b4

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

agent/stats/task_linux.go

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -102,16 +102,16 @@ func (taskStat *StatsTask) populateNIDeviceList(containerPID string) ([]string,
102102
return deviceList, err
103103
}
104104

105-
func linkStatsToDockerStats(netLinkStats *netlinklib.LinkStatistics, numberOfContainers uint64) dockerstats.NetworkStats {
105+
func linkStatsToDockerStats(netLinkStats *netlinklib.LinkStatistics) dockerstats.NetworkStats {
106106
networkStats := dockerstats.NetworkStats{
107-
RxBytes: netLinkStats.RxBytes / numberOfContainers,
108-
RxPackets: netLinkStats.RxPackets / numberOfContainers,
109-
RxErrors: netLinkStats.RxErrors / numberOfContainers,
110-
RxDropped: netLinkStats.RxDropped / numberOfContainers,
111-
TxBytes: netLinkStats.TxBytes / numberOfContainers,
112-
TxPackets: netLinkStats.TxPackets / numberOfContainers,
113-
TxErrors: netLinkStats.TxErrors / numberOfContainers,
114-
TxDropped: netLinkStats.TxDropped / numberOfContainers,
107+
RxBytes: netLinkStats.RxBytes,
108+
RxPackets: netLinkStats.RxPackets,
109+
RxErrors: netLinkStats.RxErrors,
110+
RxDropped: netLinkStats.RxDropped,
111+
TxBytes: netLinkStats.TxBytes,
112+
TxPackets: netLinkStats.TxPackets,
113+
TxErrors: netLinkStats.TxErrors,
114+
TxDropped: netLinkStats.TxDropped,
115115
}
116116
return networkStats
117117
}
@@ -142,8 +142,7 @@ func (taskStat *StatsTask) retrieveNetworkStatistics() (map[string]dockerstats.N
142142
return nil, err
143143
}
144144
netLinkStats := link.Attrs().Statistics
145-
networkStats[link.Attrs().Name] = linkStatsToDockerStats(netLinkStats,
146-
uint64(taskStat.TaskMetadata.NumberContainers))
145+
networkStats[link.Attrs().Name] = linkStatsToDockerStats(netLinkStats)
147146
}
148147

149148
return networkStats, nil

0 commit comments

Comments
 (0)