From d6aa3974d19ceb8cbc564be90982de0215edf518 Mon Sep 17 00:00:00 2001 From: Ivaylo Papratilov Date: Mon, 29 Jan 2024 14:36:29 +0200 Subject: [PATCH] Log connection lifetime in collector --- collector/collector.go | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/collector/collector.go b/collector/collector.go index 6fea349..b495ebc 100644 --- a/collector/collector.go +++ b/collector/collector.go @@ -213,6 +213,7 @@ func (c *Collector) collect() error { defer c.mu.Unlock() for _, conn := range conns { + c.log.Infof("connection lifecycle %s %s", conn.Src.IP().String(), conn.Lifetime.Format(time.RFC3339)) if c.cfg.GroupPublicIPs && !conn.Dst.IP().IsPrivate() { conn.Dst = netaddr.IPPortFrom(netaddr.IPv4(0, 0, 0, 0), 0) } @@ -244,13 +245,13 @@ func (c *Collector) collect() error { } else { c.podMetrics[groupKey] = &rawNetworkMetric{ RawNetworkMetric: &pb.RawNetworkMetric{ - SrcIp: dns.ToIPint32(conn.Src.IP()), - DstIp: dns.ToIPint32(conn.Dst.IP()), - TxBytes: int64(conn.TxBytes), - TxPackets: int64(conn.TxPackets), - RxBytes: int64(conn.RxBytes), - RxPackets: int64(conn.RxPackets), - Proto: int32(conn.Proto), + SrcIp: dns.ToIPint32(conn.Src.IP()), + DstIp: dns.ToIPint32(conn.Dst.IP()), + TxBytes: int64(conn.TxBytes), + TxPackets: int64(conn.TxPackets), + RxBytes: int64(conn.RxBytes), + RxPackets: int64(conn.RxPackets), + Proto: int32(conn.Proto), }, lifetime: conn.Lifetime, }