Skip to content
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
38 changes: 25 additions & 13 deletions controllers/consoleplugin/config/static-frontend-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1049,7 +1049,7 @@ scopes:
name: Node
shortName: Node
description: Node on which the resources are running
labels:
labels:
- SrcK8S_HostName
- DstK8S_HostName
groups:
Expand All @@ -1064,7 +1064,7 @@ scopes:
name: Namespace
shortName: NS
description: Resource namespace
labels:
labels:
- SrcK8S_Namespace
- DstK8S_Namespace
groups:
Expand All @@ -1082,7 +1082,7 @@ scopes:
name: Owner
shortName: Own
description: Controller owner, such as a Deployment
labels:
labels:
- SrcK8S_OwnerName
- SrcK8S_OwnerType
- DstK8S_OwnerName
Expand All @@ -1108,7 +1108,7 @@ scopes:
name: Resource
shortName: Res
description: Base resource, such as a Pod, a Service or a Node
labels:
labels:
- SrcK8S_Name
- SrcK8S_Type
- SrcK8S_OwnerName
Expand Down Expand Up @@ -1170,6 +1170,7 @@ fields:
description: Source namespace
- name: SrcAddr
type: string
format: IP
description: Source IP address (ipv4 or ipv6)
- name: SrcPort
type: number
Expand All @@ -1179,6 +1180,7 @@ fields:
description: Source MAC address
- name: SrcK8S_HostIP
type: string
format: IP
description: Source node IP
- name: SrcK8S_HostName
type: string
Expand Down Expand Up @@ -1206,6 +1208,7 @@ fields:
description: Destination namespace
- name: DstAddr
type: string
format: IP
description: Destination IP address (ipv4 or ipv6)
- name: DstPort
type: number
Expand All @@ -1215,6 +1218,7 @@ fields:
description: Destination MAC address
- name: DstK8S_HostIP
type: string
format: IP
description: Destination node IP
- name: DstK8S_HostName
type: string
Expand Down Expand Up @@ -1254,21 +1258,21 @@ fields:
- 1: Egress (outgoing traffic, from the node observation point) +
- 2: Inner (with the same source and destination node)
- name: IfDirections
type: number
type: number[]
description: |
Flow directions from the network interface observation point. Can be one of: +
- 0: Ingress (interface incoming traffic) +
- 1: Egress (interface outgoing traffic)
- name: Interfaces
type: string
type: string[]
description: Network interfaces
- name: Flags
type: string
type: string[]
description: |
Logical OR combination of unique TCP flags comprised in the flow, as per RFC-9293, with additional custom flags to represent the following per-packet combinations: +
- SYN+ACK (0x100) +
- FIN+ACK (0x200) +
- RST+ACK (0x400)
List of TCP flags comprised in the flow, as per RFC-9293, with additional custom flags to represent the following per-packet combinations: +
- SYN_ACK +
- FIN_ACK +
- RST_ACK
- name: Bytes
type: number
description: Number of bytes
Expand Down Expand Up @@ -1311,8 +1315,16 @@ fields:
type: number
description: TCP Smoothed Round Trip Time (SRTT), in nanoseconds
- name: NetworkEvents
type: string
description: Network events flow monitoring
type: string[]
docType: object[]
description: |
Network events, such as network policy actions, composed of nested fields: +
- Feature (such as "acl" for network policies) +
- Type (such as an "AdminNetworkPolicy") +
- Namespace (namespace where the event applies, if any) +
- Name (name of the resource that triggered the event) +
- Action (such as "allow" or "drop") +
- Direction (Ingress or Egress)
- name: ZoneId
type: number
description: packet translation zone id
Expand Down
31 changes: 30 additions & 1 deletion controllers/flp/flp_controller_flowmetrics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,24 @@ func ControllerFlowMetricsSpecs() {
Labels: []string{"DstAddr"},
},
}
metric3 := metricslatest.FlowMetric{ // With nested labels
ObjectMeta: metav1.ObjectMeta{
Name: "metric-3",
Namespace: operatorNamespace,
},
Spec: metricslatest.FlowMetricSpec{
MetricName: "m_3",
Type: metricslatest.CounterMetric,
Labels: []string{"NetworkEvents>Type", "NetworkEvents>Name"},
},
}
metricUnwatched := metricslatest.FlowMetric{
ObjectMeta: metav1.ObjectMeta{
Name: "metric-unwatched",
Namespace: otherNamespace,
},
Spec: metricslatest.FlowMetricSpec{
MetricName: "m_3",
MetricName: "m_unwatched",
Type: metricslatest.CounterMetric,
},
}
Expand Down Expand Up @@ -121,6 +132,7 @@ func ControllerFlowMetricsSpecs() {
Expect(k8sClient.Create(ctx, &metric1)).Should(Succeed())
Expect(k8sClient.Create(ctx, &metricUnwatched)).Should(Succeed())
Expect(k8sClient.Create(ctx, &metric2)).Should(Succeed())
Expect(k8sClient.Create(ctx, &metric3)).Should(Succeed())
})

It("Should update configmap with custom metrics", func() {
Expand All @@ -139,6 +151,7 @@ func ControllerFlowMetricsSpecs() {
names := getSortedMetricsNames(metrics)
return slices.Contains(names, metric1.Spec.MetricName) &&
slices.Contains(names, metric2.Spec.MetricName) &&
slices.Contains(names, metric3.Spec.MetricName) &&
!slices.Contains(names, metricUnwatched.Spec.MetricName)
}))
})
Expand All @@ -153,6 +166,7 @@ func ControllerFlowMetricsSpecs() {
}, timeout, interval).Should(Satisfy(func(conds []metav1.Condition) bool {
ready := meta.FindStatusCondition(conds, fmstatus.ConditionReady)
card := meta.FindStatusCondition(conds, fmstatus.ConditionCardinalityOK)
// Metrics 1 has cardinality FINE (no label)
return ready != nil && card != nil && ready.Status == metav1.ConditionTrue && card.Status == metav1.ConditionTrue &&
ready.Reason == "Ready" && card.Reason == string(cardinality.WarnFine)
}))
Expand All @@ -164,11 +178,26 @@ func ControllerFlowMetricsSpecs() {
}
return metric2.Status.Conditions
}, timeout, interval).Should(Satisfy(func(conds []metav1.Condition) bool {
// Metrics 2 has cardinality AVOID (Addr label)
ready := meta.FindStatusCondition(conds, fmstatus.ConditionReady)
card := meta.FindStatusCondition(conds, fmstatus.ConditionCardinalityOK)
return ready != nil && card != nil && ready.Status == metav1.ConditionTrue && card.Status == metav1.ConditionFalse &&
ready.Reason == "Ready" && card.Reason == string(cardinality.WarnAvoid)
}))

Eventually(func() interface{} {
err := k8sClient.Get(ctx, helper.NamespacedName(&metric3), &metric3)
if err != nil {
return err
}
return metric3.Status.Conditions
}, timeout, interval).Should(Satisfy(func(conds []metav1.Condition) bool {
// Metrics 3 has cardinality FINE (NetworkEvents nested labels)
ready := meta.FindStatusCondition(conds, fmstatus.ConditionReady)
card := meta.FindStatusCondition(conds, fmstatus.ConditionCardinalityOK)
return ready != nil && card != nil && ready.Status == metav1.ConditionTrue && card.Status == metav1.ConditionTrue &&
ready.Reason == "Ready" && card.Reason == string(cardinality.WarnFine)
}))
})
})

Expand Down
14 changes: 11 additions & 3 deletions hack/asciidoc-flows-gen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,15 @@ nbfields=$(yq '.fields | length' $FE_SOURCE)
lokiLabels=$(cat $LOKI_LABEL_SOURCE)
cardinalityMap=$(cat $CARDINALITY_SOURCE)
otelMap=$(cat $OTEL_SOURCE)
errors=""

for i in $(seq 0 $(( $nbfields-1 )) ); do
frontEntry=$(yq ".fields | sort_by(.name) | .[$i]" $FE_SOURCE)
name=$(printf "$frontEntry" | yq ".name")
type=$(printf "$frontEntry" | yq ".type")
type=$(printf "$frontEntry" | yq ".docType")
if [[ "$type" == "null" ]]; then
type=$(printf "$frontEntry" | yq ".type")
fi
desc=$(printf "$frontEntry" | yq ".description")
filter=$(printf "$frontEntry" | yq ".filter")
if [[ "$filter" == "null" ]]; then
Expand All @@ -44,8 +48,7 @@ for i in $(seq 0 $(( $nbfields-1 )) ); do
fi
cardWarn=$(printf "$cardinalityMap" | jq -r ".$name")
if [[ "$cardWarn" == "null" ]]; then
echo "missing cardinality for field $name"
exit 1
errors="$errors\nmissing cardinality for field $name"
fi
otel=$(printf "$otelMap" | jq -r ".$name")
if [[ "$otel" == "null" ]]; then
Expand All @@ -60,4 +63,9 @@ for i in $(seq 0 $(( $nbfields-1 )) ); do
echo -e "| $otel" >> $ADOC
done

if [[ $errors != "" ]]; then
echo -e $errors
exit 1
fi

echo -e '|===' >> $ADOC
15 changes: 14 additions & 1 deletion pkg/helper/cardinality/cardinality.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,20 @@
"DnsErrno": "fine",
"TimeFlowRttNs": "avoid",
"NetworkEvents": "avoid",
"NetworkEvents>Feature": "fine",
"NetworkEvents>Type": "fine",
"NetworkEvents>Namespace": "fine",
"NetworkEvents>Name": "fine",
"NetworkEvents>Action": "fine",
"NetworkEvents>Direction": "fine",
"K8S_ClusterName": "fine",
"Sampling": "fine",
"ZoneId": "avoid",
"XlatSrcPort": "careful",
"XlatSrcAddr": "avoid",
"XlatIcmpId": "avoid",
"XlatDstPort": "careful",
"XlatDstAddr": "avoid",
Comment on lines +53 to +66
Copy link
Member

@memodi memodi Jan 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jotak cardinality levels here LGTM, I am thinking to verify this based on code review, let me know if you think e2e test for the feature is required.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @memodi - I think it's fine as is - I just added an integration test (c8f3f11) to add on verification

"_RecordType": "fine",
"_HashId": "avoid"
}
}
Loading