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

Fix naming of k8s entries to ipfix export #427

Merged
merged 1 commit into from
May 30, 2023
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
5 changes: 5 additions & 0 deletions hack/examples/ipfix-collector/ipfix-dump.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@ func loadSevoneRegistry() error {
fmt.Printf("Failed to register sourceNodeName")
return err
}
err = registry.PutInfoElement((*entities.NewInfoElement("destinationNodeName", 7738, 13, SevoneEnterpriseID, 65535)), SevoneEnterpriseID)
if err != nil {
fmt.Printf("Failed to register destinationNodeName")
return err
}
return nil
}
func printIPFIXMessage(msg *entities.Message) {
Expand Down
32 changes: 23 additions & 9 deletions pkg/pipeline/write/write_ipfix.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ func addKubeContextToTemplate(elements *[]entities.InfoElementWithValue, registr
if err != nil {
return err
}
err = addElementToTemplate("destinationNodeName", nil, elements, registryID)
if err != nil {
return err
}
return nil
}

Expand Down Expand Up @@ -115,6 +119,11 @@ func loadCustomRegistry(EnterpriseID uint32) error {
ilog.WithError(err).Errorf("Failed to register element")
return err
}
err = registry.PutInfoElement((*entities.NewInfoElement("destinationNodeName", 7738, 13, EnterpriseID, 65535)), EnterpriseID)
if err != nil {
ilog.WithError(err).Errorf("Failed to register element")
return err
}
return nil
}

Expand Down Expand Up @@ -407,30 +416,35 @@ func setKubeIEValue(record config.GenericMap, ieValPtr *entities.InfoElementWith
ieVal.SetStringValue("none")
}
case "sourcePodName":
if record["sourcePodName"] != nil {
ieVal.SetStringValue(record["sourcePodName"].(string))
if record["SrcK8S_Name"] != nil {
ieVal.SetStringValue(record["SrcK8S_Name"].(string))
} else {
ieVal.SetStringValue("none")
}
case "destinationPodNamespace":
if record["destinationPodNamespace"] != nil {
ieVal.SetStringValue(record["destinationPodNamespace"].(string))
if record["DstK8S_Namespace"] != nil {
ieVal.SetStringValue(record["DstK8S_Namespace"].(string))
} else {
ieVal.SetStringValue("none")
}
case "destinationPodName":
if record["destinationPodName"] != nil {
ieVal.SetStringValue(record["destinationPodName"].(string))
if record["DstK8S_Name"] != nil {
ieVal.SetStringValue(record["DstK8S_Name"].(string))
} else {
ieVal.SetStringValue("none")
}
case "sourceNodeName":
if record["sourceNodeName"] != nil {
ieVal.SetStringValue(record["sourceNodeName"].(string))
if record["SrcK8S_HostName"] != nil {
ieVal.SetStringValue(record["SrcK8S_HostName"].(string))
} else {
ieVal.SetStringValue("none")
}
case "destinationNodeName":
if record["DstK8S_HostName"] != nil {
ieVal.SetStringValue(record["DstK8S_HostName"].(string))
} else {
ieVal.SetStringValue("none")
}

}
}
func setEntities(record config.GenericMap, enrichEnterpriseID uint32, elements *[]entities.InfoElementWithValue) error {
Expand Down