Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[karmor summary] Added Time Stamps and Count for Ingress and Egress Connections #561

Merged
merged 1 commit into from
Oct 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/conf/local-file.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ application:
namespace-filter:
- "!kube-system"
system:
operation-mode: 1 # 1: cronjob | 2: one-time-job
operation-mode: 1 # 1: cronjob | 2: one-time-job
operation-trigger: 5
cron-job-time-interval: "0h0m10s" # format: XhYmZs
system-log-from: "kubearmor" # db|kubearmor|feed-consumer
Expand Down
5 changes: 5 additions & 0 deletions src/observability/kubearmor.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,12 @@ func fetchSysServerConnDetail(log types.KubeArmorLog) (types.SysObsNwData, error
// get Syscall
if strings.Contains(log.Data, "tcp_connect") || strings.Contains(log.Data, "SYS_CONNECT") {
conn.InOut = "OUT"
conn.Count++
conn.UpdatedTime = time.UnixDate
} else if strings.Contains(log.Data, "tcp_accept") || strings.Contains(log.Data, "SYS_ACCEPT") {
conn.InOut = "IN"
conn.Count++
conn.UpdatedTime = time.UnixDate
} else {
return types.SysObsNwData{}, err
}
Expand Down Expand Up @@ -339,6 +343,7 @@ func GetKubearmorSummaryData(req *opb.Request) ([]types.SysObsProcFileData, []ty
Count: systemTotal[sysindex],
UpdatedTime: t.Format(time.UnixDate),
})

} else if locSysLog.Operation == "Network" {
//ExtractNwData
nwobsdata, err := fetchSysServerConnDetail(locSysLog)
Expand Down
30 changes: 17 additions & 13 deletions src/observability/summary.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ func GetSummaryData(request *opb.Request) (*opb.Response, error) {
proc, file, nw, podInfo := GetKubearmorSummaryData(request)

if len(proc) <= 0 && len(file) <= 0 && len(nw) <= 0 {
return nil, errors.New("no system summary info present for the requested pod")
return nil, errors.New("no system summary info present for the requested pod name")
}

procResp := []*opb.SysProcFileSummaryData{}
Expand Down Expand Up @@ -59,21 +59,25 @@ func GetSummaryData(request *opb.Request) (*opb.Response, error) {
for _, loc_nw := range nw {
if loc_nw.InOut == "IN" {
inNwResp = append(inNwResp, &opb.SysNwSummaryData{
Protocol: loc_nw.Protocol,
Command: loc_nw.Command,
IP: loc_nw.PodSvcIP,
Port: loc_nw.ServerPort,
Labels: loc_nw.Labels,
Namespace: loc_nw.Namespace,
Protocol: loc_nw.Protocol,
Command: loc_nw.Command,
IP: loc_nw.PodSvcIP,
Port: loc_nw.ServerPort,
Labels: loc_nw.Labels,
Namespace: loc_nw.Namespace,
Count: strconv.Itoa(int(loc_nw.Count)),
UpdatedTime: loc_nw.UpdatedTime,
})
} else if loc_nw.InOut == "OUT" {
outNwResp = append(outNwResp, &opb.SysNwSummaryData{
Protocol: loc_nw.Protocol,
Command: loc_nw.Command,
IP: loc_nw.PodSvcIP,
Port: loc_nw.ServerPort,
Labels: loc_nw.Labels,
Namespace: loc_nw.Namespace,
Protocol: loc_nw.Protocol,
Command: loc_nw.Command,
IP: loc_nw.PodSvcIP,
Port: loc_nw.ServerPort,
Labels: loc_nw.Labels,
Namespace: loc_nw.Namespace,
Count: strconv.Itoa(int(loc_nw.Count)),
UpdatedTime: loc_nw.UpdatedTime,
})
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/protobuf/v1/analyzer/analyzer.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/protobuf/v1/analyzer/analyzer_grpc.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/protobuf/v1/config/config.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/protobuf/v1/config/config_grpc.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/protobuf/v1/consumer/consumer.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/protobuf/v1/consumer/consumer_grpc.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/protobuf/v1/discovery/discovery.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/protobuf/v1/insight/insight.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/protobuf/v1/insight/insight_grpc.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

107 changes: 63 additions & 44 deletions src/protobuf/v1/observability/observability.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions src/protobuf/v1/observability/observability.proto
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ message SysNwSummaryData {
string Port = 4;
string Labels = 5;
string Namespace = 6;
string Count = 7;
string UpdatedTime = 8;
}

message CiliumSummData {
Expand Down
2 changes: 1 addition & 1 deletion src/protobuf/v1/worker/worker.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/protobuf/v1/worker/worker_grpc.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/types/logData.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ type KnoxNetworkLog struct {
DstIP string `json:"dst_ip,omitempty" bson:"dst_ip"`
SrcPort int `json:"src_port,omitempty" bson:"src_port"`
DstPort int `json:"dst_port,omitempty" bson:"dst_port"`
ICMPType int `json:"icmp_type, omitempty" bson:"icmp_type"`
ICMPType int `json:"icmp_type,omitempty" bson:"icmp_type"`

SynFlag bool `json:"syn_flag,omitempty" bson:"syn_flag"` // for tcp
IsReply bool `json:"is_reply,omitempty" bson:"is_reply"` // is_reply
Expand Down
16 changes: 9 additions & 7 deletions src/types/observability.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,13 +151,15 @@ type SysObsProcFileData struct {
}

type SysObsNwData struct {
InOut string
Protocol string
Command string
PodSvcIP string
ServerPort string
Namespace string
Labels string
InOut string
Protocol string
Command string
PodSvcIP string
ServerPort string
Namespace string
Labels string
Count uint32
UpdatedTime string
}

type NwObsIngressEgressData struct {
Expand Down