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

Add new field to ipfix exporter for flowRtt #603

Merged
merged 13 commits into from
Feb 26, 2024
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
4 changes: 3 additions & 1 deletion pkg/pipeline/write/testnorace/write_ipfix_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
15 changes: 13 additions & 2 deletions pkg/pipeline/write/write_ipfix.go
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -77,7 +77,7 @@ var (
"destinationNodeName",
}
CustomNetworkFields = []string{
// TODO
"timeFlowRttNs",
}
)

Expand Down Expand Up @@ -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
}

Expand Down Expand Up @@ -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
}
Expand Down
Loading