-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
NETOBSERV-1275: Introduce new "INNER" direction for inner-node traffic (
#378) * Introduce new "INNER" direction for inner-node traffic Related PR: netobserv/flowlogs-pipeline#483 The flows (and duplicates) generated for inner-node traffic differs compared to node-to-node traffic, and reinterpret direction isn't able to decide between ingress or egress. This is causing discrepancies with the dedup mechanism that filters out flows where Duplicate=true and also favors ingress over egress, since the Duplicate flag can be set randomly on ingress or on egress. To fix that, the proposed solution is to create this new INNER direction specifically for this kind of traffic. Deduping this INNER traffic can then rely solely on the Duplicate flag, since that flag was set from a single Agent (single node) there will always be only one Duplicate=false. * fix fmt * Fix test * Update texts & API for doc * fix linter
- Loading branch information
Showing
12 changed files
with
48 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,21 @@ | ||
import * as _ from 'lodash'; | ||
import { FlowDirection, Record } from '../api/ipfix'; | ||
import { Record } from '../api/ipfix'; | ||
import { get5Tuple } from './ids'; | ||
|
||
export const mergeFlowReporters = (flows: Record[]): Record[] => { | ||
// The purpose of this function is to determine if, for a given 5 tuple, we'll look at INGRESS or EGRESS reporter | ||
// The assumption is that INGRESS alone, or EGRESS alone always provide a complete visiblity however | ||
// Ingress traffic will also contains pktDrop and DNS responses | ||
// The logic is to index flows by 5 tuples, then for each indexed set, keep only the INGRESS if present, otherwise EGRESS | ||
// The purpose of this function is to determine if, for a given 5 tuple, we'll look at INGRESS, EGRESS or INNER reporter | ||
// The assumption is that INGRESS alone, EGRESS alone or INNER alone always provide a complete visiblity | ||
// Favor whichever contains pktDrop and/or DNS responses | ||
const grouped = _.groupBy(flows, get5Tuple); | ||
const filtersIndex = _.mapValues( | ||
grouped, | ||
(recs: Record[]) => | ||
(recs.find(r => r.labels.FlowDirection === FlowDirection.Ingress) || recs[0]).labels.FlowDirection | ||
( | ||
recs.find( | ||
r => | ||
r.fields.DnsId !== undefined || r.fields.PktDropBytes !== undefined || r.fields.PktDropPackets !== undefined | ||
) || recs[0] | ||
).labels.FlowDirection | ||
); | ||
return flows.filter((r: Record) => r.labels.FlowDirection === filtersIndex[get5Tuple(r)]); | ||
}; |