diff --git a/pkg/pipeline/write/testnorace/write_ipfix_test.go b/pkg/pipeline/write/testnorace/write_ipfix_test.go index f67ca993b..075764d4e 100644 --- a/pkg/pipeline/write/testnorace/write_ipfix_test.go +++ b/pkg/pipeline/write/testnorace/write_ipfix_test.go @@ -119,7 +119,7 @@ func TestEnrichedIPFIXFlow(t *testing.T) { assert.Equal(t, uint16(10), tplv4Msg.GetVersion()) templateSet := tplv4Msg.GetSet() templateElements := templateSet.GetRecords()[0].GetOrderedElementList() - assert.Len(t, templateElements, 20) + assert.Len(t, templateElements, 21) assert.Equal(t, uint32(0), templateElements[0].GetInfoElement().EnterpriseId) // Check data @@ -176,6 +176,8 @@ func matchElement(t *testing.T, element entities.InfoElementWithValue, flow conf assert.Equal(t, flow["SrcK8S_HostName"], element.GetStringValue()) case "destinationNodeName": assert.Equal(t, flow["DstK8S_HostName"], element.GetStringValue()) + case "timeFlowRttNs": + assert.Equal(t, uint64(flow["TimeFlowRttNs"].(int64)), element.GetUnsigned64Value()) case "sourceMacAddress": case "destinationMacAddress": // Getting some discrepancies here, need to figure out why diff --git a/pkg/pipeline/write/write_ipfix.go b/pkg/pipeline/write/write_ipfix.go index 5cf78f8b5..e76bb9e11 100644 --- a/pkg/pipeline/write/write_ipfix.go +++ b/pkg/pipeline/write/write_ipfix.go @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022 IBM, Inc. + * Copyright (C) 2024 IBM, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -77,7 +77,7 @@ var ( "destinationNodeName", } CustomNetworkFields = []string{ - // TODO + "timeFlowRttNs", } ) @@ -150,6 +150,11 @@ func loadCustomRegistry(EnterpriseID uint32) error { ilog.WithError(err).Errorf("Failed to register element") return err } + err = registry.PutInfoElement((*entities.NewInfoElement("timeFlowRttNs", 7740, entities.Unsigned64, EnterpriseID, 8)), EnterpriseID) + if err != nil { + ilog.WithError(err).Errorf("Failed to register element") + return err + } return nil } @@ -336,6 +341,12 @@ func setStandardIEValue(record config.GenericMap, ieValPtr *entities.InfoElement } else { return fmt.Errorf("unable to find interface in record") } + case "timeFlowRttNs": + if record["TimeFlowRttNs"] != nil { + ieVal.SetUnsigned64Value(uint64(record["TimeFlowRttNs"].(int64))) + } else { + return fmt.Errorf("unable to find timeflowrtt in record") + } } return nil }