Skip to content

Commit

Permalink
Fix naming of k8s entries to ipfix export (#427)
Browse files Browse the repository at this point in the history
  • Loading branch information
praveingk authored May 30, 2023
1 parent 3c3c1f3 commit 95910af
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 9 deletions.
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

0 comments on commit 95910af

Please sign in to comment.