Skip to content

Commit 5442201

Browse files
authored
NETOBSERV-1692: Add FLP-based filters & deduper options (#591)
* NETOBSERV-1692: Add FLP-based deduper options FLP-based dedup allows to decrease Loki CPU / memory / storage a lot (~50%) at the cost of minimal loss in data accuracy (e.g. loosing interfaces involved in egress traffic) * Add filters API * FLP-based filters - Switch using new "keep" api on FLP filters - Support sampling - Support regexes - Add tests * update sample config * bump flp, mention dev preview * fix rebase issue
1 parent 15494c8 commit 5442201

21 files changed

+1804
-337
lines changed

apis/flowcollector/v1beta1/flowcollector_types.go

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -604,13 +604,95 @@ type FlowCollectorFLP struct {
604604
// When a subnet matches the source or destination IP of a flow, a corresponding field is added: `SrcSubnetLabel` or `DstSubnetLabel`.
605605
SubnetLabels SubnetLabels `json:"subnetLabels,omitempty"`
606606

607+
//+optional
608+
// `deduper` allows to sample or drop flows identified as duplicates, in order to save on resource usage.
609+
Deduper *FLPDeduper `json:"deduper,omitempty"`
610+
611+
// `filters` let you define custom filters to limit the amount of generated flows.
612+
// +optional
613+
Filters []FLPFilterSet `json:"filters"`
614+
607615
// `debug` allows setting some aspects of the internal configuration of the flow processor.
608616
// This section is aimed exclusively for debugging and fine-grained performance optimizations,
609617
// such as `GOGC` and `GOMAXPROCS` env vars. Set these values at your own risk.
610618
// +optional
611619
Debug DebugConfig `json:"debug,omitempty"`
612620
}
613621

622+
type FLPDeduperMode string
623+
624+
const (
625+
FLPDeduperDisabled FLPDeduperMode = "Disabled"
626+
FLPDeduperDrop FLPDeduperMode = "Drop"
627+
FLPDeduperSample FLPDeduperMode = "Sample"
628+
)
629+
630+
// `FLPDeduper` defines the desired configuration for FLP-based deduper
631+
type FLPDeduper struct {
632+
// Set the Processor deduper mode (de-duplication). It comes in addition to the Agent deduper because the Agent cannot de-duplicate same flows reported from different nodes.<br>
633+
// - Use `Drop` to drop every flow considered as duplicates, allowing saving more on resource usage but potentially loosing some information such as the network interfaces used from peer.<br>
634+
// - Use `Sample` to randomly keep only 1 flow on 50 (by default) among the ones considered as duplicates. This is a compromise between dropping every duplicates or keeping every duplicates. This sampling action comes in addition to the Agent-based sampling. If both Agent and Processor sampling are 50, the combined sampling is 1:2500.<br>
635+
// - Use `Disabled` to turn off Processor-based de-duplication.<br>
636+
// +kubebuilder:validation:Enum:="Disabled";"Drop";"Sample"
637+
// +kubebuilder:default:=Disabled
638+
Mode FLPDeduperMode `json:"mode,omitempty"`
639+
640+
// `sampling` is the sampling rate when deduper `mode` is `Sample`.
641+
//+kubebuilder:validation:Minimum=0
642+
//+kubebuilder:default:=50
643+
Sampling int32 `json:"sampling,omitempty"`
644+
}
645+
646+
type FLPFilterMatch string
647+
type FLPFilterTarget string
648+
649+
const (
650+
FLPFilterEqual FLPFilterMatch = "Equal"
651+
FLPFilterNotEqual FLPFilterMatch = "NotEqual"
652+
FLPFilterPresence FLPFilterMatch = "Presence"
653+
FLPFilterAbsence FLPFilterMatch = "Absence"
654+
FLPFilterRegex FLPFilterMatch = "MatchRegex"
655+
FLPFilterNotRegex FLPFilterMatch = "NotMatchRegex"
656+
FLPFilterTargetAll FLPFilterTarget = ""
657+
FLPFilterTargetLoki FLPFilterTarget = "Loki"
658+
FLPFilterTargetMetrics FLPFilterTarget = "Metrics"
659+
FLPFilterTargetExporters FLPFilterTarget = "Exporters"
660+
)
661+
662+
// `FLPFilterSet` defines the desired configuration for FLP-based filtering satisfying all conditions
663+
type FLPFilterSet struct {
664+
// `filters` is a list of matches that must be all satisfied in order to remove a flow.
665+
// +optional
666+
AllOf []FLPSingleFilter `json:"allOf"`
667+
668+
// If specified, this filters only target a single output: `Loki`, `Metrics` or `Exporters`. By default, all outputs are targeted.
669+
// +optional
670+
// +kubebuilder:validation:Enum:="";"Loki";"Metrics";"Exporters"
671+
OutputTarget FLPFilterTarget `json:"outputTarget,omitempty"`
672+
673+
// `sampling` is an optional sampling rate to apply to this filter.
674+
//+kubebuilder:validation:Minimum=0
675+
// +optional
676+
Sampling int32 `json:"sampling,omitempty"`
677+
}
678+
679+
// `FLPSingleFilter` defines the desired configuration for a single FLP-based filter
680+
type FLPSingleFilter struct {
681+
// Type of matching to apply
682+
// +kubebuilder:validation:Enum:="Equal";"NotEqual";"Presence";"Absence";"MatchRegex";"NotMatchRegex"
683+
// +kubebuilder:default:="Equal"
684+
MatchType FLPFilterMatch `json:"matchType"`
685+
686+
// Name of the field to filter on
687+
// Refer to the documentation for the list of available fields: https://docs.openshift.com/container-platform/latest/observability/network_observability/json-flows-format-reference.html.
688+
// +required
689+
Field string `json:"field"`
690+
691+
// Value to filter on. When `matchType` is `Equal` or `NotEqual`, you can use field injection with `$(SomeField)` to refer to any other field of the flow.
692+
// +optional
693+
Value string `json:"value"`
694+
}
695+
614696
const (
615697
HPAStatusDisabled = "DISABLED"
616698
HPAStatusEnabled = "ENABLED"

apis/flowcollector/v1beta1/zz_generated.conversion.go

Lines changed: 104 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apis/flowcollector/v1beta1/zz_generated.deepcopy.go

Lines changed: 62 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)