From ccbf29198dd033e662c10e105d3088318d09899a Mon Sep 17 00:00:00 2001 From: Eswar Rajan Subramanian Date: Fri, 2 Sep 2022 20:18:17 +0530 Subject: [PATCH 1/4] Handling request type for summary Signed-off-by: Eswar Rajan Subramanian --- src/observability/cilium.go | 53 +++-- src/observability/summary.go | 55 +++-- .../v1/observability/observability.pb.go | 216 +++++++++++------- .../v1/observability/observability.proto | 18 +- src/types/observability.go | 15 +- 5 files changed, 212 insertions(+), 145 deletions(-) diff --git a/src/observability/cilium.go b/src/observability/cilium.go index 837e0bb5..162b7c7e 100644 --- a/src/observability/cilium.go +++ b/src/observability/cilium.go @@ -201,14 +201,14 @@ func ProcessCiliumFlow(flowLog *flow.Flow) { NetworkLogsMutex.Unlock() } -func GetCiliumSummaryData(req *opb.Request) ([]types.NetObsData, types.ObsPodDetail) { +func GetCiliumSummaryData(req *opb.Request) ([]types.NwObsIngressEgressData, []types.NwObsIngressEgressData, types.ObsPodDetail) { var err error - var ingressEgressData []types.NetObsData + var ingressData, egressData []types.NwObsIngressEgressData var podInfo types.ObsPodDetail ciliumLogs, logCount, err := libs.GetCiliumLogs(CfgDB, types.CiliumLog{}) if err != nil { - return nil, types.ObsPodDetail{} + return nil, nil, types.ObsPodDetail{} } for netindex, netlog := range ciliumLogs { @@ -219,15 +219,7 @@ func GetCiliumSummaryData(req *opb.Request) ([]types.NetObsData, types.ObsPodDet } t := time.Unix(netlog.UpdatedTime, 0) - var srcDestPod, protocol, port, status string - - // Extract ingress/egress traffic - switch netlog.TrafficDirection { - case "INGRESS": - srcDestPod = netlog.SourcePodName + " <-- " + netlog.DestinationPodName - case "EGRESS": - srcDestPod = netlog.SourcePodName + " --> " + netlog.DestinationPodName - } + var protocol, port, status string // Extract port and protocol if netlog.L4TCPDestinationPort != 0 { @@ -260,15 +252,34 @@ func GetCiliumSummaryData(req *opb.Request) ([]types.NetObsData, types.ObsPodDet status = "AUDIT" } - ingressEgressData = append(ingressEgressData, types.NetObsData{ - Protocol: protocol, - SrcDestPod: srcDestPod, - Port: port, - Count: strconv.Itoa(int(logCount[netindex])), - UpdatedTime: t.Format(time.UnixDate), - Status: status, - }) + // Extract ingress/egress traffic + switch netlog.TrafficDirection { + case "INGRESS": + ingressData = append(ingressData, types.NwObsIngressEgressData{ + Protocol: protocol, + SrcPodName: netlog.SourcePodName, + DestPodName: netlog.DestinationPodName, + DestinationNamespace: netlog.DestinationNamespace, + DestinationLabel: netlog.DestinationLabels, + Port: port, + Count: strconv.Itoa(int(logCount[netindex])), + UpdatedTime: t.Format(time.UnixDate), + Status: status, + }) + case "EGRESS": + egressData = append(egressData, types.NwObsIngressEgressData{ + Protocol: protocol, + SrcPodName: netlog.SourcePodName, + DestPodName: netlog.DestinationPodName, + DestinationNamespace: netlog.DestinationNamespace, + DestinationLabel: netlog.DestinationLabels, + Port: port, + Count: strconv.Itoa(int(logCount[netindex])), + UpdatedTime: t.Format(time.UnixDate), + Status: status, + }) + } } - return ingressEgressData, podInfo + return ingressData, egressData, podInfo } diff --git a/src/observability/summary.go b/src/observability/summary.go index 62fd1dfc..491e5e46 100644 --- a/src/observability/summary.go +++ b/src/observability/summary.go @@ -3,6 +3,7 @@ package observability import ( "errors" "strconv" + "strings" opb "github.com/accuknox/auto-policy-discovery/src/protobuf/v1/observability" ) @@ -11,7 +12,8 @@ func GetSummaryData(request *opb.Request) (*opb.Response, error) { resp := opb.Response{} var err error = nil - if request.Type == "system" || request.Type == "all" { + if strings.Contains(request.Type, "process") || strings.Contains(request.Type, "file") || + strings.Contains(request.Type, "network") || strings.Contains(request.Type, "all") { proc, file, nw, podInfo := GetKubearmorSummaryData(request) if len(proc) <= 0 && len(file) <= 0 && len(nw) <= 0 { @@ -29,7 +31,7 @@ func GetSummaryData(request *opb.Request) (*opb.Response, error) { resp.Label = podInfo.Labels resp.ContainerName = podInfo.ContainerName - if len(proc) > 0 { + if len(proc) > 0 && (strings.Contains(request.Type, "process") || strings.Contains(request.Type, "all")) { for _, loc_proc := range proc { procResp = append(procResp, &opb.SysProcFileSummaryData{ ParentProcName: loc_proc.Source, @@ -41,7 +43,7 @@ func GetSummaryData(request *opb.Request) (*opb.Response, error) { } } - if len(file) > 0 { + if len(file) > 0 && (strings.Contains(request.Type, "file") || strings.Contains(request.Type, "all")) { for _, loc_file := range file { fileResp = append(fileResp, &opb.SysProcFileSummaryData{ ParentProcName: loc_file.Source, @@ -53,7 +55,7 @@ func GetSummaryData(request *opb.Request) (*opb.Response, error) { } } - if len(nw) > 0 { + if len(nw) > 0 && (strings.Contains(request.Type, "network") || strings.Contains(request.Type, "all")) { for _, loc_nw := range nw { if loc_nw.InOut == "IN" { inNwResp = append(inNwResp, &opb.SysNwSummaryData{ @@ -82,24 +84,38 @@ func GetSummaryData(request *opb.Request) (*opb.Response, error) { resp.OutNwData = outNwResp } - if request.Type == "network" || request.Type == "all" { - nwSummaryData, podInfo := GetCiliumSummaryData(request) + if strings.Contains(request.Type, "ingress") || strings.Contains(request.Type, "egress") || strings.Contains(request.Type, "all") { + ingressData, egressData, podInfo := GetCiliumSummaryData(request) - if len(nwSummaryData) <= 0 && request.Type == "network" { + if len(ingressData) <= 0 && len(egressData) <= 0 && request.Type == "network" { return nil, errors.New("no ingress/egress summary info present for the requested pod") } - ingressEgressSummData := []*opb.CiliumSummData{} - - for _, locNwSummData := range nwSummaryData { - ingressEgressSummData = append(ingressEgressSummData, &opb.CiliumSummData{ - SrcDestPod: locNwSummData.SrcDestPod, - Protocol: locNwSummData.Protocol, - Port: locNwSummData.Port, - Count: locNwSummData.Count, - Status: locNwSummData.Status, - UpdatedTime: locNwSummData.UpdatedTime, - }) + ingressSummData := []*opb.CiliumSummData{} + egressSummData := []*opb.CiliumSummData{} + + if len(ingressData) > 0 && (strings.Contains(request.Type, "ingress") || strings.Contains(request.Type, "all")) { + for _, locIngressData := range ingressData { + ingressSummData = append(ingressSummData, &opb.CiliumSummData{ + Protocol: locIngressData.Protocol, + Port: locIngressData.Port, + Count: locIngressData.Count, + Status: locIngressData.Status, + UpdatedTime: locIngressData.UpdatedTime, + }) + } + } + + if len(egressData) > 0 && (strings.Contains(request.Type, "egress") || strings.Contains(request.Type, "all")) { + for _, locIngressData := range ingressData { + egressSummData = append(egressSummData, &opb.CiliumSummData{ + Protocol: locIngressData.Protocol, + Port: locIngressData.Port, + Count: locIngressData.Count, + Status: locIngressData.Status, + UpdatedTime: locIngressData.UpdatedTime, + }) + } } if request.Type == "network" { @@ -107,7 +123,8 @@ func GetSummaryData(request *opb.Request) (*opb.Response, error) { resp.Namespace = podInfo.Namespace resp.Label = podInfo.Labels } - resp.IngressEgressData = ingressEgressSummData + resp.IngressData = ingressSummData + resp.EgressData = egressSummData } return &resp, err diff --git a/src/protobuf/v1/observability/observability.pb.go b/src/protobuf/v1/observability/observability.pb.go index f2c65c93..92b0cab0 100644 --- a/src/protobuf/v1/observability/observability.pb.go +++ b/src/protobuf/v1/observability/observability.pb.go @@ -112,16 +112,17 @@ type Response struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - PodName string `protobuf:"bytes,1,opt,name=PodName,proto3" json:"PodName,omitempty"` - ClusterName string `protobuf:"bytes,2,opt,name=ClusterName,proto3" json:"ClusterName,omitempty"` - Namespace string `protobuf:"bytes,3,opt,name=Namespace,proto3" json:"Namespace,omitempty"` - Label string `protobuf:"bytes,4,opt,name=Label,proto3" json:"Label,omitempty"` - ContainerName string `protobuf:"bytes,5,opt,name=ContainerName,proto3" json:"ContainerName,omitempty"` - ProcessData []*SysProcFileSummaryData `protobuf:"bytes,6,rep,name=ProcessData,proto3" json:"ProcessData,omitempty"` - FileData []*SysProcFileSummaryData `protobuf:"bytes,7,rep,name=FileData,proto3" json:"FileData,omitempty"` - InNwData []*SysNwSummaryData `protobuf:"bytes,8,rep,name=InNwData,proto3" json:"InNwData,omitempty"` - OutNwData []*SysNwSummaryData `protobuf:"bytes,9,rep,name=OutNwData,proto3" json:"OutNwData,omitempty"` - IngressEgressData []*CiliumSummData `protobuf:"bytes,10,rep,name=IngressEgressData,proto3" json:"IngressEgressData,omitempty"` + PodName string `protobuf:"bytes,1,opt,name=PodName,proto3" json:"PodName,omitempty"` + ClusterName string `protobuf:"bytes,2,opt,name=ClusterName,proto3" json:"ClusterName,omitempty"` + Namespace string `protobuf:"bytes,3,opt,name=Namespace,proto3" json:"Namespace,omitempty"` + Label string `protobuf:"bytes,4,opt,name=Label,proto3" json:"Label,omitempty"` + ContainerName string `protobuf:"bytes,5,opt,name=ContainerName,proto3" json:"ContainerName,omitempty"` + ProcessData []*SysProcFileSummaryData `protobuf:"bytes,6,rep,name=ProcessData,proto3" json:"ProcessData,omitempty"` + FileData []*SysProcFileSummaryData `protobuf:"bytes,7,rep,name=FileData,proto3" json:"FileData,omitempty"` + InNwData []*SysNwSummaryData `protobuf:"bytes,8,rep,name=InNwData,proto3" json:"InNwData,omitempty"` + OutNwData []*SysNwSummaryData `protobuf:"bytes,9,rep,name=OutNwData,proto3" json:"OutNwData,omitempty"` + IngressData []*CiliumSummData `protobuf:"bytes,10,rep,name=IngressData,proto3" json:"IngressData,omitempty"` + EgressData []*CiliumSummData `protobuf:"bytes,11,rep,name=EgressData,proto3" json:"EgressData,omitempty"` } func (x *Response) Reset() { @@ -219,9 +220,16 @@ func (x *Response) GetOutNwData() []*SysNwSummaryData { return nil } -func (x *Response) GetIngressEgressData() []*CiliumSummData { +func (x *Response) GetIngressData() []*CiliumSummData { if x != nil { - return x.IngressEgressData + return x.IngressData + } + return nil +} + +func (x *Response) GetEgressData() []*CiliumSummData { + if x != nil { + return x.EgressData } return nil } @@ -397,12 +405,15 @@ type CiliumSummData struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - SrcDestPod string `protobuf:"bytes,1,opt,name=SrcDestPod,proto3" json:"SrcDestPod,omitempty"` - Protocol string `protobuf:"bytes,2,opt,name=Protocol,proto3" json:"Protocol,omitempty"` - Port string `protobuf:"bytes,3,opt,name=Port,proto3" json:"Port,omitempty"` - Count string `protobuf:"bytes,4,opt,name=Count,proto3" json:"Count,omitempty"` - UpdatedTime string `protobuf:"bytes,5,opt,name=UpdatedTime,proto3" json:"UpdatedTime,omitempty"` - Status string `protobuf:"bytes,6,opt,name=Status,proto3" json:"Status,omitempty"` + SrcPod string `protobuf:"bytes,1,opt,name=SrcPod,proto3" json:"SrcPod,omitempty"` + DestPod string `protobuf:"bytes,2,opt,name=DestPod,proto3" json:"DestPod,omitempty"` + DestNamespace string `protobuf:"bytes,3,opt,name=DestNamespace,proto3" json:"DestNamespace,omitempty"` + DestLabel string `protobuf:"bytes,4,opt,name=DestLabel,proto3" json:"DestLabel,omitempty"` + Protocol string `protobuf:"bytes,5,opt,name=Protocol,proto3" json:"Protocol,omitempty"` + Port string `protobuf:"bytes,6,opt,name=Port,proto3" json:"Port,omitempty"` + Count string `protobuf:"bytes,7,opt,name=Count,proto3" json:"Count,omitempty"` + UpdatedTime string `protobuf:"bytes,8,opt,name=UpdatedTime,proto3" json:"UpdatedTime,omitempty"` + Status string `protobuf:"bytes,9,opt,name=Status,proto3" json:"Status,omitempty"` } func (x *CiliumSummData) Reset() { @@ -437,9 +448,30 @@ func (*CiliumSummData) Descriptor() ([]byte, []int) { return file_v1_observability_observability_proto_rawDescGZIP(), []int{4} } -func (x *CiliumSummData) GetSrcDestPod() string { +func (x *CiliumSummData) GetSrcPod() string { if x != nil { - return x.SrcDestPod + return x.SrcPod + } + return "" +} + +func (x *CiliumSummData) GetDestPod() string { + if x != nil { + return x.DestPod + } + return "" +} + +func (x *CiliumSummData) GetDestNamespace() string { + if x != nil { + return x.DestNamespace + } + return "" +} + +func (x *CiliumSummData) GetDestLabel() string { + if x != nil { + return x.DestLabel } return "" } @@ -543,7 +575,7 @@ var file_v1_observability_observability_proto_rawDesc = []byte{ 0x61, 0x62, 0x65, 0x6c, 0x12, 0x24, 0x0a, 0x0d, 0x43, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x43, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x54, 0x79, - 0x70, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x54, 0x79, 0x70, 0x65, 0x22, 0x84, + 0x70, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x54, 0x79, 0x70, 0x65, 0x22, 0xba, 0x04, 0x0a, 0x08, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x50, 0x6f, 0x64, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x50, 0x6f, 0x64, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, @@ -571,62 +603,71 @@ var file_v1_observability_observability_proto_rawDesc = []byte{ 0x18, 0x09, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x22, 0x2e, 0x76, 0x31, 0x2e, 0x6f, 0x62, 0x73, 0x65, 0x72, 0x76, 0x61, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x79, 0x2e, 0x53, 0x79, 0x73, 0x4e, 0x77, 0x53, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x44, 0x61, 0x74, 0x61, 0x52, 0x09, 0x4f, 0x75, 0x74, 0x4e, - 0x77, 0x44, 0x61, 0x74, 0x61, 0x12, 0x4e, 0x0a, 0x11, 0x49, 0x6e, 0x67, 0x72, 0x65, 0x73, 0x73, - 0x45, 0x67, 0x72, 0x65, 0x73, 0x73, 0x44, 0x61, 0x74, 0x61, 0x18, 0x0a, 0x20, 0x03, 0x28, 0x0b, - 0x32, 0x20, 0x2e, 0x76, 0x31, 0x2e, 0x6f, 0x62, 0x73, 0x65, 0x72, 0x76, 0x61, 0x62, 0x69, 0x6c, - 0x69, 0x74, 0x79, 0x2e, 0x43, 0x69, 0x6c, 0x69, 0x75, 0x6d, 0x53, 0x75, 0x6d, 0x6d, 0x44, 0x61, - 0x74, 0x61, 0x52, 0x11, 0x49, 0x6e, 0x67, 0x72, 0x65, 0x73, 0x73, 0x45, 0x67, 0x72, 0x65, 0x73, - 0x73, 0x44, 0x61, 0x74, 0x61, 0x22, 0xac, 0x01, 0x0a, 0x16, 0x53, 0x79, 0x73, 0x50, 0x72, 0x6f, - 0x63, 0x46, 0x69, 0x6c, 0x65, 0x53, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x44, 0x61, 0x74, 0x61, - 0x12, 0x1a, 0x0a, 0x08, 0x50, 0x72, 0x6f, 0x63, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x08, 0x50, 0x72, 0x6f, 0x63, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x26, 0x0a, 0x0e, - 0x50, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x50, 0x72, 0x6f, 0x63, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x02, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x0e, 0x50, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x50, 0x72, 0x6f, 0x63, - 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x03, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x05, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x20, 0x0a, 0x0b, 0x55, 0x70, - 0x64, 0x61, 0x74, 0x65, 0x64, 0x54, 0x69, 0x6d, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x0b, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x16, 0x0a, 0x06, - 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x53, 0x74, - 0x61, 0x74, 0x75, 0x73, 0x22, 0xa2, 0x01, 0x0a, 0x10, 0x53, 0x79, 0x73, 0x4e, 0x77, 0x53, 0x75, - 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x44, 0x61, 0x74, 0x61, 0x12, 0x1a, 0x0a, 0x08, 0x50, 0x72, 0x6f, - 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x50, 0x72, 0x6f, - 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x12, 0x18, 0x0a, 0x07, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x12, - 0x0e, 0x0a, 0x02, 0x49, 0x50, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x49, 0x50, 0x12, - 0x12, 0x0a, 0x04, 0x50, 0x6f, 0x72, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x50, - 0x6f, 0x72, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x4c, 0x61, 0x62, 0x65, 0x6c, 0x73, 0x18, 0x05, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x06, 0x4c, 0x61, 0x62, 0x65, 0x6c, 0x73, 0x12, 0x1c, 0x0a, 0x09, 0x4e, - 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, - 0x4e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x22, 0xb0, 0x01, 0x0a, 0x0e, 0x43, 0x69, - 0x6c, 0x69, 0x75, 0x6d, 0x53, 0x75, 0x6d, 0x6d, 0x44, 0x61, 0x74, 0x61, 0x12, 0x1e, 0x0a, 0x0a, - 0x53, 0x72, 0x63, 0x44, 0x65, 0x73, 0x74, 0x50, 0x6f, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x0a, 0x53, 0x72, 0x63, 0x44, 0x65, 0x73, 0x74, 0x50, 0x6f, 0x64, 0x12, 0x1a, 0x0a, 0x08, - 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, - 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x12, 0x12, 0x0a, 0x04, 0x50, 0x6f, 0x72, 0x74, - 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x50, 0x6f, 0x72, 0x74, 0x12, 0x14, 0x0a, 0x05, - 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x43, 0x6f, 0x75, - 0x6e, 0x74, 0x12, 0x20, 0x0a, 0x0b, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x54, 0x69, 0x6d, - 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, - 0x54, 0x69, 0x6d, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x06, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x22, 0x2b, 0x0a, 0x0f, - 0x50, 0x6f, 0x64, 0x4e, 0x61, 0x6d, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, - 0x18, 0x0a, 0x07, 0x50, 0x6f, 0x64, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, - 0x52, 0x07, 0x50, 0x6f, 0x64, 0x4e, 0x61, 0x6d, 0x65, 0x32, 0x9e, 0x01, 0x0a, 0x0d, 0x4f, 0x62, - 0x73, 0x65, 0x72, 0x76, 0x61, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x79, 0x12, 0x40, 0x0a, 0x07, 0x53, - 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x12, 0x19, 0x2e, 0x76, 0x31, 0x2e, 0x6f, 0x62, 0x73, 0x65, - 0x72, 0x76, 0x61, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x79, 0x2e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, - 0x74, 0x1a, 0x1a, 0x2e, 0x76, 0x31, 0x2e, 0x6f, 0x62, 0x73, 0x65, 0x72, 0x76, 0x61, 0x62, 0x69, - 0x6c, 0x69, 0x74, 0x79, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x4b, 0x0a, - 0x0b, 0x47, 0x65, 0x74, 0x50, 0x6f, 0x64, 0x4e, 0x61, 0x6d, 0x65, 0x73, 0x12, 0x19, 0x2e, 0x76, - 0x31, 0x2e, 0x6f, 0x62, 0x73, 0x65, 0x72, 0x76, 0x61, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x79, 0x2e, - 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x21, 0x2e, 0x76, 0x31, 0x2e, 0x6f, 0x62, 0x73, - 0x65, 0x72, 0x76, 0x61, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x79, 0x2e, 0x50, 0x6f, 0x64, 0x4e, 0x61, - 0x6d, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x49, 0x5a, 0x47, 0x67, 0x69, - 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x61, 0x63, 0x63, 0x75, 0x6b, 0x6e, 0x6f, - 0x78, 0x2f, 0x61, 0x75, 0x74, 0x6f, 0x2d, 0x70, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x2d, 0x64, 0x69, - 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2f, 0x73, 0x72, 0x63, 0x2f, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x76, 0x31, 0x2f, 0x6f, 0x62, 0x73, 0x65, 0x72, 0x76, 0x61, 0x62, - 0x69, 0x6c, 0x69, 0x74, 0x79, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x77, 0x44, 0x61, 0x74, 0x61, 0x12, 0x42, 0x0a, 0x0b, 0x49, 0x6e, 0x67, 0x72, 0x65, 0x73, 0x73, + 0x44, 0x61, 0x74, 0x61, 0x18, 0x0a, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x76, 0x31, 0x2e, + 0x6f, 0x62, 0x73, 0x65, 0x72, 0x76, 0x61, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x79, 0x2e, 0x43, 0x69, + 0x6c, 0x69, 0x75, 0x6d, 0x53, 0x75, 0x6d, 0x6d, 0x44, 0x61, 0x74, 0x61, 0x52, 0x0b, 0x49, 0x6e, + 0x67, 0x72, 0x65, 0x73, 0x73, 0x44, 0x61, 0x74, 0x61, 0x12, 0x40, 0x0a, 0x0a, 0x45, 0x67, 0x72, + 0x65, 0x73, 0x73, 0x44, 0x61, 0x74, 0x61, 0x18, 0x0b, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x20, 0x2e, + 0x76, 0x31, 0x2e, 0x6f, 0x62, 0x73, 0x65, 0x72, 0x76, 0x61, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x79, + 0x2e, 0x43, 0x69, 0x6c, 0x69, 0x75, 0x6d, 0x53, 0x75, 0x6d, 0x6d, 0x44, 0x61, 0x74, 0x61, 0x52, + 0x0a, 0x45, 0x67, 0x72, 0x65, 0x73, 0x73, 0x44, 0x61, 0x74, 0x61, 0x22, 0xac, 0x01, 0x0a, 0x16, + 0x53, 0x79, 0x73, 0x50, 0x72, 0x6f, 0x63, 0x46, 0x69, 0x6c, 0x65, 0x53, 0x75, 0x6d, 0x6d, 0x61, + 0x72, 0x79, 0x44, 0x61, 0x74, 0x61, 0x12, 0x1a, 0x0a, 0x08, 0x50, 0x72, 0x6f, 0x63, 0x4e, 0x61, + 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x50, 0x72, 0x6f, 0x63, 0x4e, 0x61, + 0x6d, 0x65, 0x12, 0x26, 0x0a, 0x0e, 0x50, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x50, 0x72, 0x6f, 0x63, + 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0e, 0x50, 0x61, 0x72, 0x65, + 0x6e, 0x74, 0x50, 0x72, 0x6f, 0x63, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x43, 0x6f, + 0x75, 0x6e, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x43, 0x6f, 0x75, 0x6e, 0x74, + 0x12, 0x20, 0x0a, 0x0b, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x54, 0x69, 0x6d, 0x65, 0x18, + 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x54, 0x69, + 0x6d, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x05, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x06, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x22, 0xa2, 0x01, 0x0a, 0x10, 0x53, + 0x79, 0x73, 0x4e, 0x77, 0x53, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x44, 0x61, 0x74, 0x61, 0x12, + 0x1a, 0x0a, 0x08, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x08, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x12, 0x18, 0x0a, 0x07, 0x43, + 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x43, 0x6f, + 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x12, 0x0e, 0x0a, 0x02, 0x49, 0x50, 0x18, 0x03, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x02, 0x49, 0x50, 0x12, 0x12, 0x0a, 0x04, 0x50, 0x6f, 0x72, 0x74, 0x18, 0x04, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x04, 0x50, 0x6f, 0x72, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x4c, 0x61, 0x62, + 0x65, 0x6c, 0x73, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x4c, 0x61, 0x62, 0x65, 0x6c, + 0x73, 0x12, 0x1c, 0x0a, 0x09, 0x4e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x18, 0x06, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x4e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x22, + 0x86, 0x02, 0x0a, 0x0e, 0x43, 0x69, 0x6c, 0x69, 0x75, 0x6d, 0x53, 0x75, 0x6d, 0x6d, 0x44, 0x61, + 0x74, 0x61, 0x12, 0x16, 0x0a, 0x06, 0x53, 0x72, 0x63, 0x50, 0x6f, 0x64, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x06, 0x53, 0x72, 0x63, 0x50, 0x6f, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x44, 0x65, + 0x73, 0x74, 0x50, 0x6f, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x44, 0x65, 0x73, + 0x74, 0x50, 0x6f, 0x64, 0x12, 0x24, 0x0a, 0x0d, 0x44, 0x65, 0x73, 0x74, 0x4e, 0x61, 0x6d, 0x65, + 0x73, 0x70, 0x61, 0x63, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x44, 0x65, 0x73, + 0x74, 0x4e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x44, 0x65, + 0x73, 0x74, 0x4c, 0x61, 0x62, 0x65, 0x6c, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x44, + 0x65, 0x73, 0x74, 0x4c, 0x61, 0x62, 0x65, 0x6c, 0x12, 0x1a, 0x0a, 0x08, 0x50, 0x72, 0x6f, 0x74, + 0x6f, 0x63, 0x6f, 0x6c, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x50, 0x72, 0x6f, 0x74, + 0x6f, 0x63, 0x6f, 0x6c, 0x12, 0x12, 0x0a, 0x04, 0x50, 0x6f, 0x72, 0x74, 0x18, 0x06, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x04, 0x50, 0x6f, 0x72, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x43, 0x6f, 0x75, 0x6e, + 0x74, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x20, + 0x0a, 0x0b, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x54, 0x69, 0x6d, 0x65, 0x18, 0x08, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x0b, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x54, 0x69, 0x6d, 0x65, + 0x12, 0x16, 0x0a, 0x06, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x09, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x06, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x22, 0x2b, 0x0a, 0x0f, 0x50, 0x6f, 0x64, 0x4e, + 0x61, 0x6d, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x50, + 0x6f, 0x64, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, 0x07, 0x50, 0x6f, + 0x64, 0x4e, 0x61, 0x6d, 0x65, 0x32, 0x9e, 0x01, 0x0a, 0x0d, 0x4f, 0x62, 0x73, 0x65, 0x72, 0x76, + 0x61, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x79, 0x12, 0x40, 0x0a, 0x07, 0x53, 0x75, 0x6d, 0x6d, 0x61, + 0x72, 0x79, 0x12, 0x19, 0x2e, 0x76, 0x31, 0x2e, 0x6f, 0x62, 0x73, 0x65, 0x72, 0x76, 0x61, 0x62, + 0x69, 0x6c, 0x69, 0x74, 0x79, 0x2e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1a, 0x2e, + 0x76, 0x31, 0x2e, 0x6f, 0x62, 0x73, 0x65, 0x72, 0x76, 0x61, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x79, + 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x4b, 0x0a, 0x0b, 0x47, 0x65, 0x74, + 0x50, 0x6f, 0x64, 0x4e, 0x61, 0x6d, 0x65, 0x73, 0x12, 0x19, 0x2e, 0x76, 0x31, 0x2e, 0x6f, 0x62, + 0x73, 0x65, 0x72, 0x76, 0x61, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x79, 0x2e, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x1a, 0x21, 0x2e, 0x76, 0x31, 0x2e, 0x6f, 0x62, 0x73, 0x65, 0x72, 0x76, 0x61, + 0x62, 0x69, 0x6c, 0x69, 0x74, 0x79, 0x2e, 0x50, 0x6f, 0x64, 0x4e, 0x61, 0x6d, 0x65, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x49, 0x5a, 0x47, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, + 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x61, 0x63, 0x63, 0x75, 0x6b, 0x6e, 0x6f, 0x78, 0x2f, 0x61, 0x75, + 0x74, 0x6f, 0x2d, 0x70, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x2d, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, + 0x65, 0x72, 0x79, 0x2f, 0x73, 0x72, 0x63, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, + 0x2f, 0x76, 0x31, 0x2f, 0x6f, 0x62, 0x73, 0x65, 0x72, 0x76, 0x61, 0x62, 0x69, 0x6c, 0x69, 0x74, + 0x79, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -655,16 +696,17 @@ var file_v1_observability_observability_proto_depIdxs = []int32{ 2, // 1: v1.observability.Response.FileData:type_name -> v1.observability.SysProcFileSummaryData 3, // 2: v1.observability.Response.InNwData:type_name -> v1.observability.SysNwSummaryData 3, // 3: v1.observability.Response.OutNwData:type_name -> v1.observability.SysNwSummaryData - 4, // 4: v1.observability.Response.IngressEgressData:type_name -> v1.observability.CiliumSummData - 0, // 5: v1.observability.Observability.Summary:input_type -> v1.observability.Request - 0, // 6: v1.observability.Observability.GetPodNames:input_type -> v1.observability.Request - 1, // 7: v1.observability.Observability.Summary:output_type -> v1.observability.Response - 5, // 8: v1.observability.Observability.GetPodNames:output_type -> v1.observability.PodNameResponse - 7, // [7:9] is the sub-list for method output_type - 5, // [5:7] is the sub-list for method input_type - 5, // [5:5] is the sub-list for extension type_name - 5, // [5:5] is the sub-list for extension extendee - 0, // [0:5] is the sub-list for field type_name + 4, // 4: v1.observability.Response.IngressData:type_name -> v1.observability.CiliumSummData + 4, // 5: v1.observability.Response.EgressData:type_name -> v1.observability.CiliumSummData + 0, // 6: v1.observability.Observability.Summary:input_type -> v1.observability.Request + 0, // 7: v1.observability.Observability.GetPodNames:input_type -> v1.observability.Request + 1, // 8: v1.observability.Observability.Summary:output_type -> v1.observability.Response + 5, // 9: v1.observability.Observability.GetPodNames:output_type -> v1.observability.PodNameResponse + 8, // [8:10] is the sub-list for method output_type + 6, // [6:8] is the sub-list for method input_type + 6, // [6:6] is the sub-list for extension type_name + 6, // [6:6] is the sub-list for extension extendee + 0, // [0:6] is the sub-list for field type_name } func init() { file_v1_observability_observability_proto_init() } diff --git a/src/protobuf/v1/observability/observability.proto b/src/protobuf/v1/observability/observability.proto index d21f6241..2f52f979 100644 --- a/src/protobuf/v1/observability/observability.proto +++ b/src/protobuf/v1/observability/observability.proto @@ -28,7 +28,8 @@ message Response{ repeated SysProcFileSummaryData FileData = 7; repeated SysNwSummaryData InNwData = 8; repeated SysNwSummaryData OutNwData = 9; - repeated CiliumSummData IngressEgressData = 10; + repeated CiliumSummData IngressData = 10; + repeated CiliumSummData EgressData = 11; } message SysProcFileSummaryData { @@ -49,12 +50,15 @@ message SysNwSummaryData { } message CiliumSummData { - string SrcDestPod = 1; - string Protocol = 2; - string Port = 3; - string Count = 4; - string UpdatedTime = 5; - string Status = 6; + string SrcPod = 1; + string DestPod = 2; + string DestNamespace = 3; + string DestLabel = 4; + string Protocol = 5; + string Port = 6; + string Count = 7; + string UpdatedTime = 8; + string Status = 9; } message PodNameResponse { diff --git a/src/types/observability.go b/src/types/observability.go index d0f86f14..88f5f020 100644 --- a/src/types/observability.go +++ b/src/types/observability.go @@ -160,21 +160,14 @@ type SysObsNwData struct { Labels string } -type NetObsData struct { - Protocol string - SrcDestPod string - Port string - Count string - UpdatedTime string - Status string -} - type NwObsIngressEgressData struct { - DestinationLabel string + SrcPodName string + DestPodName string DestinationNamespace string + DestinationLabel string Protocol string Port string Status string - Count int + Count string UpdatedTime string } From 7df54393c97ceebcb9e101d47c4e38860b038f4e Mon Sep 17 00:00:00 2001 From: Eswar Rajan Subramanian Date: Fri, 2 Sep 2022 20:22:50 +0530 Subject: [PATCH 2/4] Handling observability request type Signed-off-by: Eswar Rajan Subramanian --- src/observability/summary.go | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/observability/summary.go b/src/observability/summary.go index 491e5e46..15ef853c 100644 --- a/src/observability/summary.go +++ b/src/observability/summary.go @@ -12,8 +12,8 @@ func GetSummaryData(request *opb.Request) (*opb.Response, error) { resp := opb.Response{} var err error = nil - if strings.Contains(request.Type, "process") || strings.Contains(request.Type, "file") || - strings.Contains(request.Type, "network") || strings.Contains(request.Type, "all") { + if strings.Contains(request.Type, "process") || strings.Contains(request.Type, "file") || strings.Contains(request.Type, "network") { + proc, file, nw, podInfo := GetKubearmorSummaryData(request) if len(proc) <= 0 && len(file) <= 0 && len(nw) <= 0 { @@ -31,7 +31,7 @@ func GetSummaryData(request *opb.Request) (*opb.Response, error) { resp.Label = podInfo.Labels resp.ContainerName = podInfo.ContainerName - if len(proc) > 0 && (strings.Contains(request.Type, "process") || strings.Contains(request.Type, "all")) { + if len(proc) > 0 && strings.Contains(request.Type, "process") { for _, loc_proc := range proc { procResp = append(procResp, &opb.SysProcFileSummaryData{ ParentProcName: loc_proc.Source, @@ -43,7 +43,7 @@ func GetSummaryData(request *opb.Request) (*opb.Response, error) { } } - if len(file) > 0 && (strings.Contains(request.Type, "file") || strings.Contains(request.Type, "all")) { + if len(file) > 0 && strings.Contains(request.Type, "file") { for _, loc_file := range file { fileResp = append(fileResp, &opb.SysProcFileSummaryData{ ParentProcName: loc_file.Source, @@ -55,7 +55,7 @@ func GetSummaryData(request *opb.Request) (*opb.Response, error) { } } - if len(nw) > 0 && (strings.Contains(request.Type, "network") || strings.Contains(request.Type, "all")) { + if len(nw) > 0 && strings.Contains(request.Type, "network") { for _, loc_nw := range nw { if loc_nw.InOut == "IN" { inNwResp = append(inNwResp, &opb.SysNwSummaryData{ @@ -84,7 +84,8 @@ func GetSummaryData(request *opb.Request) (*opb.Response, error) { resp.OutNwData = outNwResp } - if strings.Contains(request.Type, "ingress") || strings.Contains(request.Type, "egress") || strings.Contains(request.Type, "all") { + if strings.Contains(request.Type, "ingress") || strings.Contains(request.Type, "egress") { + ingressData, egressData, podInfo := GetCiliumSummaryData(request) if len(ingressData) <= 0 && len(egressData) <= 0 && request.Type == "network" { @@ -94,7 +95,7 @@ func GetSummaryData(request *opb.Request) (*opb.Response, error) { ingressSummData := []*opb.CiliumSummData{} egressSummData := []*opb.CiliumSummData{} - if len(ingressData) > 0 && (strings.Contains(request.Type, "ingress") || strings.Contains(request.Type, "all")) { + if len(ingressData) > 0 && strings.Contains(request.Type, "ingress") { for _, locIngressData := range ingressData { ingressSummData = append(ingressSummData, &opb.CiliumSummData{ Protocol: locIngressData.Protocol, @@ -106,7 +107,7 @@ func GetSummaryData(request *opb.Request) (*opb.Response, error) { } } - if len(egressData) > 0 && (strings.Contains(request.Type, "egress") || strings.Contains(request.Type, "all")) { + if len(egressData) > 0 && strings.Contains(request.Type, "egress") { for _, locIngressData := range ingressData { egressSummData = append(egressSummData, &opb.CiliumSummData{ Protocol: locIngressData.Protocol, From 32371046762ecf9829ec8f266d7f81240400d214 Mon Sep 17 00:00:00 2001 From: Eswar Rajan Subramanian Date: Tue, 6 Sep 2022 15:26:45 +0530 Subject: [PATCH 3/4] Fixed linter errors Signed-off-by: Eswar Rajan Subramanian --- src/observability/cilium.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/observability/cilium.go b/src/observability/cilium.go index 162b7c7e..964ad41f 100644 --- a/src/observability/cilium.go +++ b/src/observability/cilium.go @@ -166,6 +166,7 @@ func convertFlowLogToCiliumLog(flowLog *flow.Flow) (types.CiliumLog, error) { return ciliumLog, nil } +// ProcessNetworkLogs : Process Incoming Network/Cilium logs func ProcessNetworkLogs() { if len(NetworkLogs) <= 0 { @@ -195,12 +196,14 @@ func ProcessNetworkLogs() { ObsMutex.Unlock() } +// ProcessCiliumFlow : Add cilium flow logs to global buffer func ProcessCiliumFlow(flowLog *flow.Flow) { NetworkLogsMutex.Lock() NetworkLogs = append(NetworkLogs, flowLog) NetworkLogsMutex.Unlock() } +// GetCiliumSummaryData : Fetch cilium summary data func GetCiliumSummaryData(req *opb.Request) ([]types.NwObsIngressEgressData, []types.NwObsIngressEgressData, types.ObsPodDetail) { var err error var ingressData, egressData []types.NwObsIngressEgressData From 7b47409c554ae78c0701ad0db2b515d90a26df19 Mon Sep 17 00:00:00 2001 From: Eswar Rajan Subramanian Date: Tue, 6 Sep 2022 15:30:01 +0530 Subject: [PATCH 4/4] Removed redundant code Signed-off-by: Eswar Rajan Subramanian --- src/observability/observability.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/observability/observability.go b/src/observability/observability.go index 4b1d2118..0df6e50d 100644 --- a/src/observability/observability.go +++ b/src/observability/observability.go @@ -5,7 +5,6 @@ import ( "sync" "github.com/accuknox/auto-policy-discovery/src/common" - "github.com/accuknox/auto-policy-discovery/src/config" cfg "github.com/accuknox/auto-policy-discovery/src/config" "github.com/accuknox/auto-policy-discovery/src/libs" logger "github.com/accuknox/auto-policy-discovery/src/logging" @@ -42,10 +41,10 @@ var ( func initMutex() { ObsMutex = &sync.Mutex{} - if config.GetCfgObservabilitySysObsStatus() { + if cfg.GetCfgObservabilitySysObsStatus() { SystemLogsMutex = &sync.Mutex{} } - if config.GetCfgObservabilitySysObsStatus() { + if cfg.GetCfgObservabilitySysObsStatus() { NetworkLogsMutex = &sync.Mutex{} } } @@ -77,10 +76,10 @@ func InitObservability() { } func ObservabilityCronJob() { - if config.GetCfgObservabilitySysObsStatus() { + if cfg.GetCfgObservabilitySysObsStatus() { ProcessSystemLogs() } - if config.GetCfgObservabilityNetObsStatus() { + if cfg.GetCfgObservabilityNetObsStatus() { ProcessNetworkLogs() } }