From d6aa3974d19ceb8cbc564be90982de0215edf518 Mon Sep 17 00:00:00 2001 From: Ivaylo Papratilov Date: Mon, 29 Jan 2024 14:36:29 +0200 Subject: [PATCH 1/3] 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, } From 83958a2bc36e241bd665eb896ff41fb5f27de1d5 Mon Sep 17 00:00:00 2001 From: Ivaylo Papratilov Date: Mon, 29 Jan 2024 16:00:29 +0200 Subject: [PATCH 2/3] log lifetime of missing conn --- collector/collector.go | 2 +- collector/collector_test.go | 4 ++ exporter/exporter.go | 1 + pb/metrics.pb.go | 126 +++++++++++++++++++----------------- pb/metrics.proto | 1 + 5 files changed, 75 insertions(+), 59 deletions(-) diff --git a/collector/collector.go b/collector/collector.go index b495ebc..8dbd6d8 100644 --- a/collector/collector.go +++ b/collector/collector.go @@ -213,7 +213,6 @@ 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) } @@ -252,6 +251,7 @@ func (c *Collector) collect() error { RxBytes: int64(conn.RxBytes), RxPackets: int64(conn.RxPackets), Proto: int32(conn.Proto), + Lifetime: conn.Lifetime.Format(time.RFC3339), }, lifetime: conn.Lifetime, } diff --git a/collector/collector_test.go b/collector/collector_test.go index 0ebfeed..d3f27f9 100644 --- a/collector/collector_test.go +++ b/collector/collector_test.go @@ -122,6 +122,7 @@ func TestCollector(t *testing.T) { RxBytes: 30, RxPackets: 1, Proto: 6, + Lifetime: "0001-01-01T00:00:00Z", }, items[0]) r.Equal(&pb.RawNetworkMetric{ @@ -132,6 +133,7 @@ func TestCollector(t *testing.T) { RxBytes: 0, RxPackets: 0, Proto: 17, + Lifetime: "0001-01-01T00:00:00Z", }, items[1]) }) @@ -247,6 +249,7 @@ func TestCollector(t *testing.T) { RxBytes: 0, RxPackets: 0, Proto: 6, + Lifetime: "0001-01-01T00:00:00Z", }) r.Contains(items, &pb.RawNetworkMetric{ @@ -257,6 +260,7 @@ func TestCollector(t *testing.T) { RxBytes: 0, RxPackets: 0, Proto: 6, + Lifetime: "0001-01-01T00:00:00Z", }) }) diff --git a/exporter/exporter.go b/exporter/exporter.go index 5ba663f..aa3199e 100644 --- a/exporter/exporter.go +++ b/exporter/exporter.go @@ -156,6 +156,7 @@ func (e *Exporter) export(ctx context.Context) error { for _, rawMetrics := range batch.Items { podMetrics, err := e.buildPodNetworkMetric(rawMetrics) if err != nil { + e.log.Infof("processing metrics: %d %d %s", rawMetrics.SrcIp, rawMetrics.DstIp, rawMetrics.Lifetime) if errors.Is(err, kube.ErrNotFound) { e.log.Warnf("skipping pod metrics: %v", err) } else { diff --git a/pb/metrics.pb.go b/pb/metrics.pb.go index a85e454..898e918 100644 --- a/pb/metrics.pb.go +++ b/pb/metrics.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.28.1 -// protoc v4.23.4 +// protoc-gen-go v1.32.0 +// protoc v4.25.2 // source: pb/metrics.proto package pb @@ -25,13 +25,14 @@ type RawNetworkMetric struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - SrcIp int32 `protobuf:"varint,1,opt,name=src_ip,json=srcIp,proto3" json:"src_ip,omitempty"` - DstIp int32 `protobuf:"varint,2,opt,name=dst_ip,json=dstIp,proto3" json:"dst_ip,omitempty"` - TxBytes int64 `protobuf:"varint,3,opt,name=tx_bytes,json=txBytes,proto3" json:"tx_bytes,omitempty"` - TxPackets int64 `protobuf:"varint,4,opt,name=tx_packets,json=txPackets,proto3" json:"tx_packets,omitempty"` - RxBytes int64 `protobuf:"varint,5,opt,name=rx_bytes,json=rxBytes,proto3" json:"rx_bytes,omitempty"` - RxPackets int64 `protobuf:"varint,6,opt,name=rx_packets,json=rxPackets,proto3" json:"rx_packets,omitempty"` - Proto int32 `protobuf:"varint,7,opt,name=proto,proto3" json:"proto,omitempty"` + SrcIp int32 `protobuf:"varint,1,opt,name=src_ip,json=srcIp,proto3" json:"src_ip,omitempty"` + DstIp int32 `protobuf:"varint,2,opt,name=dst_ip,json=dstIp,proto3" json:"dst_ip,omitempty"` + TxBytes int64 `protobuf:"varint,3,opt,name=tx_bytes,json=txBytes,proto3" json:"tx_bytes,omitempty"` + TxPackets int64 `protobuf:"varint,4,opt,name=tx_packets,json=txPackets,proto3" json:"tx_packets,omitempty"` + RxBytes int64 `protobuf:"varint,5,opt,name=rx_bytes,json=rxBytes,proto3" json:"rx_bytes,omitempty"` + RxPackets int64 `protobuf:"varint,6,opt,name=rx_packets,json=rxPackets,proto3" json:"rx_packets,omitempty"` + Proto int32 `protobuf:"varint,7,opt,name=proto,proto3" json:"proto,omitempty"` + Lifetime string `protobuf:"bytes,8,opt,name=lifetime,proto3" json:"lifetime,omitempty"` } func (x *RawNetworkMetric) Reset() { @@ -115,6 +116,13 @@ func (x *RawNetworkMetric) GetProto() int32 { return 0 } +func (x *RawNetworkMetric) GetLifetime() string { + if x != nil { + return x.Lifetime + } + return "" +} + type RawNetworkMetricBatch struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -443,7 +451,7 @@ var File_pb_metrics_proto protoreflect.FileDescriptor var file_pb_metrics_proto_rawDesc = []byte{ 0x0a, 0x10, 0x70, 0x62, 0x2f, 0x6d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x73, 0x2e, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x22, 0xca, 0x01, 0x0a, 0x10, 0x52, 0x61, 0x77, 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, + 0x74, 0x6f, 0x22, 0xe6, 0x01, 0x0a, 0x10, 0x52, 0x61, 0x77, 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x4d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x12, 0x15, 0x0a, 0x06, 0x73, 0x72, 0x63, 0x5f, 0x69, 0x70, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x73, 0x72, 0x63, 0x49, 0x70, 0x12, 0x15, 0x0a, 0x06, 0x64, 0x73, 0x74, 0x5f, 0x69, 0x70, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, @@ -455,54 +463,56 @@ var file_pb_metrics_proto_rawDesc = []byte{ 0x03, 0x52, 0x07, 0x72, 0x78, 0x42, 0x79, 0x74, 0x65, 0x73, 0x12, 0x1d, 0x0a, 0x0a, 0x72, 0x78, 0x5f, 0x70, 0x61, 0x63, 0x6b, 0x65, 0x74, 0x73, 0x18, 0x06, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x72, 0x78, 0x50, 0x61, 0x63, 0x6b, 0x65, 0x74, 0x73, 0x12, 0x14, 0x0a, 0x05, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x18, 0x07, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, - 0x6a, 0x0a, 0x15, 0x52, 0x61, 0x77, 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x4d, 0x65, 0x74, - 0x72, 0x69, 0x63, 0x42, 0x61, 0x74, 0x63, 0x68, 0x12, 0x27, 0x0a, 0x05, 0x69, 0x74, 0x65, 0x6d, - 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x11, 0x2e, 0x52, 0x61, 0x77, 0x4e, 0x65, 0x74, - 0x77, 0x6f, 0x72, 0x6b, 0x4d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x52, 0x05, 0x69, 0x74, 0x65, 0x6d, - 0x73, 0x12, 0x28, 0x0a, 0x09, 0x69, 0x70, 0x32, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x18, 0x02, - 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0a, 0x2e, 0x49, 0x50, 0x32, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, - 0x52, 0x09, 0x69, 0x70, 0x32, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x22, 0xda, 0x03, 0x0a, 0x10, - 0x50, 0x6f, 0x64, 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x4d, 0x65, 0x74, 0x72, 0x69, 0x63, - 0x12, 0x15, 0x0a, 0x06, 0x73, 0x72, 0x63, 0x5f, 0x69, 0x70, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x05, 0x73, 0x72, 0x63, 0x49, 0x70, 0x12, 0x17, 0x0a, 0x07, 0x73, 0x72, 0x63, 0x5f, 0x70, - 0x6f, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x73, 0x72, 0x63, 0x50, 0x6f, 0x64, - 0x12, 0x23, 0x0a, 0x0d, 0x73, 0x72, 0x63, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, - 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x73, 0x72, 0x63, 0x4e, 0x61, 0x6d, 0x65, - 0x73, 0x70, 0x61, 0x63, 0x65, 0x12, 0x19, 0x0a, 0x08, 0x73, 0x72, 0x63, 0x5f, 0x6e, 0x6f, 0x64, - 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x73, 0x72, 0x63, 0x4e, 0x6f, 0x64, 0x65, - 0x12, 0x19, 0x0a, 0x08, 0x73, 0x72, 0x63, 0x5f, 0x7a, 0x6f, 0x6e, 0x65, 0x18, 0x05, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x07, 0x73, 0x72, 0x63, 0x5a, 0x6f, 0x6e, 0x65, 0x12, 0x15, 0x0a, 0x06, 0x64, - 0x73, 0x74, 0x5f, 0x69, 0x70, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x64, 0x73, 0x74, - 0x49, 0x70, 0x12, 0x17, 0x0a, 0x07, 0x64, 0x73, 0x74, 0x5f, 0x70, 0x6f, 0x64, 0x18, 0x07, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x06, 0x64, 0x73, 0x74, 0x50, 0x6f, 0x64, 0x12, 0x23, 0x0a, 0x0d, 0x64, - 0x73, 0x74, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x18, 0x08, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x0c, 0x64, 0x73, 0x74, 0x4e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, - 0x12, 0x19, 0x0a, 0x08, 0x64, 0x73, 0x74, 0x5f, 0x6e, 0x6f, 0x64, 0x65, 0x18, 0x09, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x07, 0x64, 0x73, 0x74, 0x4e, 0x6f, 0x64, 0x65, 0x12, 0x19, 0x0a, 0x08, 0x64, - 0x73, 0x74, 0x5f, 0x7a, 0x6f, 0x6e, 0x65, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x64, - 0x73, 0x74, 0x5a, 0x6f, 0x6e, 0x65, 0x12, 0x19, 0x0a, 0x08, 0x74, 0x78, 0x5f, 0x62, 0x79, 0x74, - 0x65, 0x73, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x03, 0x52, 0x07, 0x74, 0x78, 0x42, 0x79, 0x74, 0x65, - 0x73, 0x12, 0x1d, 0x0a, 0x0a, 0x74, 0x78, 0x5f, 0x70, 0x61, 0x63, 0x6b, 0x65, 0x74, 0x73, 0x18, - 0x0c, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x74, 0x78, 0x50, 0x61, 0x63, 0x6b, 0x65, 0x74, 0x73, - 0x12, 0x19, 0x0a, 0x08, 0x72, 0x78, 0x5f, 0x62, 0x79, 0x74, 0x65, 0x73, 0x18, 0x0d, 0x20, 0x01, - 0x28, 0x03, 0x52, 0x07, 0x72, 0x78, 0x42, 0x79, 0x74, 0x65, 0x73, 0x12, 0x1d, 0x0a, 0x0a, 0x72, - 0x78, 0x5f, 0x70, 0x61, 0x63, 0x6b, 0x65, 0x74, 0x73, 0x18, 0x0e, 0x20, 0x01, 0x28, 0x03, 0x52, - 0x09, 0x72, 0x78, 0x50, 0x61, 0x63, 0x6b, 0x65, 0x74, 0x73, 0x12, 0x14, 0x0a, 0x05, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x18, 0x0f, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x12, 0x20, 0x0a, 0x0c, 0x64, 0x73, 0x74, 0x5f, 0x64, 0x6e, 0x73, 0x5f, 0x6e, 0x61, 0x6d, 0x65, - 0x18, 0x11, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x64, 0x73, 0x74, 0x44, 0x6e, 0x73, 0x4e, 0x61, - 0x6d, 0x65, 0x4a, 0x04, 0x08, 0x10, 0x10, 0x11, 0x22, 0x40, 0x0a, 0x15, 0x50, 0x6f, 0x64, 0x4e, - 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x4d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x42, 0x61, 0x74, 0x63, - 0x68, 0x12, 0x27, 0x0a, 0x05, 0x69, 0x74, 0x65, 0x6d, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, - 0x32, 0x11, 0x2e, 0x50, 0x6f, 0x64, 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x4d, 0x65, 0x74, - 0x72, 0x69, 0x63, 0x52, 0x05, 0x69, 0x74, 0x65, 0x6d, 0x73, 0x22, 0x33, 0x0a, 0x09, 0x49, 0x50, - 0x32, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x70, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x05, 0x52, 0x02, 0x69, 0x70, 0x12, 0x16, 0x0a, 0x06, 0x64, 0x6f, 0x6d, 0x61, 0x69, - 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x42, - 0x1e, 0x5a, 0x1c, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x61, - 0x73, 0x74, 0x61, 0x69, 0x2f, 0x65, 0x67, 0x72, 0x65, 0x73, 0x73, 0x64, 0x2f, 0x70, 0x62, 0x62, - 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x74, 0x6f, 0x18, 0x07, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, + 0x1a, 0x0a, 0x08, 0x6c, 0x69, 0x66, 0x65, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x08, 0x6c, 0x69, 0x66, 0x65, 0x74, 0x69, 0x6d, 0x65, 0x22, 0x6a, 0x0a, 0x15, 0x52, + 0x61, 0x77, 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x4d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x42, + 0x61, 0x74, 0x63, 0x68, 0x12, 0x27, 0x0a, 0x05, 0x69, 0x74, 0x65, 0x6d, 0x73, 0x18, 0x01, 0x20, + 0x03, 0x28, 0x0b, 0x32, 0x11, 0x2e, 0x52, 0x61, 0x77, 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, + 0x4d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x52, 0x05, 0x69, 0x74, 0x65, 0x6d, 0x73, 0x12, 0x28, 0x0a, + 0x09, 0x69, 0x70, 0x32, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, + 0x32, 0x0a, 0x2e, 0x49, 0x50, 0x32, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x52, 0x09, 0x69, 0x70, + 0x32, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x22, 0xda, 0x03, 0x0a, 0x10, 0x50, 0x6f, 0x64, 0x4e, + 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x4d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x12, 0x15, 0x0a, 0x06, + 0x73, 0x72, 0x63, 0x5f, 0x69, 0x70, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x73, 0x72, + 0x63, 0x49, 0x70, 0x12, 0x17, 0x0a, 0x07, 0x73, 0x72, 0x63, 0x5f, 0x70, 0x6f, 0x64, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x73, 0x72, 0x63, 0x50, 0x6f, 0x64, 0x12, 0x23, 0x0a, 0x0d, + 0x73, 0x72, 0x63, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x18, 0x03, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x0c, 0x73, 0x72, 0x63, 0x4e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, + 0x65, 0x12, 0x19, 0x0a, 0x08, 0x73, 0x72, 0x63, 0x5f, 0x6e, 0x6f, 0x64, 0x65, 0x18, 0x04, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x07, 0x73, 0x72, 0x63, 0x4e, 0x6f, 0x64, 0x65, 0x12, 0x19, 0x0a, 0x08, + 0x73, 0x72, 0x63, 0x5f, 0x7a, 0x6f, 0x6e, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, + 0x73, 0x72, 0x63, 0x5a, 0x6f, 0x6e, 0x65, 0x12, 0x15, 0x0a, 0x06, 0x64, 0x73, 0x74, 0x5f, 0x69, + 0x70, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x64, 0x73, 0x74, 0x49, 0x70, 0x12, 0x17, + 0x0a, 0x07, 0x64, 0x73, 0x74, 0x5f, 0x70, 0x6f, 0x64, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x06, 0x64, 0x73, 0x74, 0x50, 0x6f, 0x64, 0x12, 0x23, 0x0a, 0x0d, 0x64, 0x73, 0x74, 0x5f, 0x6e, + 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, + 0x64, 0x73, 0x74, 0x4e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x12, 0x19, 0x0a, 0x08, + 0x64, 0x73, 0x74, 0x5f, 0x6e, 0x6f, 0x64, 0x65, 0x18, 0x09, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, + 0x64, 0x73, 0x74, 0x4e, 0x6f, 0x64, 0x65, 0x12, 0x19, 0x0a, 0x08, 0x64, 0x73, 0x74, 0x5f, 0x7a, + 0x6f, 0x6e, 0x65, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x64, 0x73, 0x74, 0x5a, 0x6f, + 0x6e, 0x65, 0x12, 0x19, 0x0a, 0x08, 0x74, 0x78, 0x5f, 0x62, 0x79, 0x74, 0x65, 0x73, 0x18, 0x0b, + 0x20, 0x01, 0x28, 0x03, 0x52, 0x07, 0x74, 0x78, 0x42, 0x79, 0x74, 0x65, 0x73, 0x12, 0x1d, 0x0a, + 0x0a, 0x74, 0x78, 0x5f, 0x70, 0x61, 0x63, 0x6b, 0x65, 0x74, 0x73, 0x18, 0x0c, 0x20, 0x01, 0x28, + 0x03, 0x52, 0x09, 0x74, 0x78, 0x50, 0x61, 0x63, 0x6b, 0x65, 0x74, 0x73, 0x12, 0x19, 0x0a, 0x08, + 0x72, 0x78, 0x5f, 0x62, 0x79, 0x74, 0x65, 0x73, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x03, 0x52, 0x07, + 0x72, 0x78, 0x42, 0x79, 0x74, 0x65, 0x73, 0x12, 0x1d, 0x0a, 0x0a, 0x72, 0x78, 0x5f, 0x70, 0x61, + 0x63, 0x6b, 0x65, 0x74, 0x73, 0x18, 0x0e, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x72, 0x78, 0x50, + 0x61, 0x63, 0x6b, 0x65, 0x74, 0x73, 0x12, 0x14, 0x0a, 0x05, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x18, + 0x0f, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x20, 0x0a, 0x0c, + 0x64, 0x73, 0x74, 0x5f, 0x64, 0x6e, 0x73, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x11, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x0a, 0x64, 0x73, 0x74, 0x44, 0x6e, 0x73, 0x4e, 0x61, 0x6d, 0x65, 0x4a, 0x04, + 0x08, 0x10, 0x10, 0x11, 0x22, 0x40, 0x0a, 0x15, 0x50, 0x6f, 0x64, 0x4e, 0x65, 0x74, 0x77, 0x6f, + 0x72, 0x6b, 0x4d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x42, 0x61, 0x74, 0x63, 0x68, 0x12, 0x27, 0x0a, + 0x05, 0x69, 0x74, 0x65, 0x6d, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x11, 0x2e, 0x50, + 0x6f, 0x64, 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x4d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x52, + 0x05, 0x69, 0x74, 0x65, 0x6d, 0x73, 0x22, 0x33, 0x0a, 0x09, 0x49, 0x50, 0x32, 0x44, 0x6f, 0x6d, + 0x61, 0x69, 0x6e, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x70, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, + 0x02, 0x69, 0x70, 0x12, 0x16, 0x0a, 0x06, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x06, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x42, 0x1e, 0x5a, 0x1c, 0x67, + 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x61, 0x73, 0x74, 0x61, 0x69, + 0x2f, 0x65, 0x67, 0x72, 0x65, 0x73, 0x73, 0x64, 0x2f, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x33, } var ( diff --git a/pb/metrics.proto b/pb/metrics.proto index 155ea76..388a272 100644 --- a/pb/metrics.proto +++ b/pb/metrics.proto @@ -10,6 +10,7 @@ message RawNetworkMetric { int64 rx_bytes = 5; int64 rx_packets = 6; int32 proto = 7; + string lifetime = 8; } message RawNetworkMetricBatch { From c8f946c7a09bf158def98374cf66d4fa0d31c101 Mon Sep 17 00:00:00 2001 From: Ivaylo Papratilov Date: Mon, 29 Jan 2024 16:08:23 +0200 Subject: [PATCH 3/3] fix tests --- kube/watcher_test.go | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/kube/watcher_test.go b/kube/watcher_test.go index 3192fc1..5bb3d94 100644 --- a/kube/watcher_test.go +++ b/kube/watcher_test.go @@ -95,23 +95,7 @@ func TestWatcher(t *testing.T) { }, } - // pod exited a while ago, and should not be found - p4 := &corev1.Pod{ - ObjectMeta: metav1.ObjectMeta{ - Name: "p4", - Namespace: "team1", - CreationTimestamp: thirtySecsAgo, - }, - Spec: corev1.PodSpec{ - NodeName: n1.Name, - }, - Status: corev1.PodStatus{ - PodIP: "10.14.7.13", - Phase: corev1.PodSucceeded, - }, - } - - clientset := fake.NewSimpleClientset(n1, p1, p2, p3, p4) + clientset := fake.NewSimpleClientset(n1, p1, p2, p3) informersFactory := informers.NewSharedInformerFactoryWithOptions(clientset, 30*time.Second) podsInformer := informersFactory.Core().V1().Pods().Informer()