Fix v5 inByte/inPackets handling#155
Conversation
|
@TheSynus would be great if you could sign your commit please. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #155 +/- ##
=====================================
Coverage 0.00% 0.00%
=====================================
Files 7 7
Lines 656 668 +12
=====================================
- Misses 656 668 +12
Continue to review full report in Codecov by Harness.
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR fixes missing bandwidth/accounting data for NetFlow v5 exports by falling back to FlowMessage.Bytes / FlowMessage.Packets when the custom remapped ExtendedFlowMessage IN fields are zero (which occurs when the v9/IPFIX mapping.yaml remapping is not applied).
Changes:
- Add fallback logic for
in_bytes/in_packetsto usebaseFlow.Bytes/baseFlow.Packetswhen remapped fields are unpopulated. - Apply the same fix in both ntopng output formats (TLV and JSON), with clarifying inline comments.
- Normalize OUT byte/packet values to
uint64in both formatters for consistent numeric handling.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| formatter/ntopng_tlv.go | Adds v5-safe fallback for IN bytes/packets when remapped fields are zero. |
| formatter/ntopng_json.go | Mirrors the same fallback logic for JSON output to keep behavior consistent across formats. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@synfinatic I amended the commit as requested |
NetFlow v5 was already working since the goflow2 library does support it. Testing with v5 sources I noticed that no bandwidth information was populating in ntopng.
There was a error in Handling in the formatter, byte and packet counts were read from the custom ExtendedFlowMessage fields, which are only populated for v9/IPFIX via the mapping.yaml field remapping. I just added a check if the fields are 0, in which case FlowMessage.Bytes/FlowMessage.Packets is used instead.
I have only tested this with NetFlow v5 since I don't have devices with v9 support.