Skip to content

Commit e7a0450

Browse files
committed
Use EXT:, do not mention editing flowmetrics as that's done directly in the examples
1 parent cea21b9 commit e7a0450

File tree

1 file changed

+18
-38
lines changed
  • content/posts/2025-11-10-subnet-labels

1 file changed

+18
-38
lines changed

content/posts/2025-11-10-subnet-labels/index.md

Lines changed: 18 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,22 @@ kubectl apply -n netobserv -f https://raw.githubusercontent.com/netobserv/networ
8888

8989
(More examples available [here](https://github.com/netobserv/network-observability-operator/tree/main/config/samples/flowmetrics), including for external traffic latency)
9090

91-
These metrics leverage the absence of Subnet Labels in order to track external traffic. In Prometheus, you can query them with `promQL` such as:
91+
These metrics leverage the absence of Subnet Labels in order to track external traffic. They also consider Subnet Labels prefixed with `EXT:` as external traffic. If you look at their definition, you'll see these rules expressed as that:
92+
93+
```yaml
94+
filters:
95+
- field: DstSubnetLabel
96+
matchType: Absence
97+
- field: DstSubnetLabel
98+
matchType: MatchRegex
99+
value: "^EXT:.*"
100+
```
101+
102+
{#admon title="Info"}
103+
In `FlowMetrics`, when there are several filters for the same key, those filters are OR'ed, ie. the match is satisfied if one at least is satisfied. Filters on different keys are AND'ed.
104+
{/}
105+
106+
In Prometheus, you can query them with the following `promQL`:
92107

93108
```
94109
topk(10, sum(rate(netobserv_cluster_external_egress_bytes_total{ SrcK8S_Namespace!="" }[2m])) by (SrcK8S_Namespace, SrcK8S_OwnerName))
@@ -154,52 +169,17 @@ We can inject them in our `subnetLabels` config:
154169
- 3.5.224.0/22
155170
- 13.36.84.48/28
156171
- 13.36.84.64/28
157-
name: EXT-AWS_S3_eu-west-3
172+
name: EXT:AWS_S3_eu-west-3
158173
```
159174

160-
It is a good practice to use a common prefix for all labels on external traffic, such as "EXT-" here, in order to distinguish external and internal subnet labels.
175+
It is a good practice to use a common prefix for all labels on external traffic, such as "EXT:" here, in order to distinguish external and internal subnet labels. As we've seen before, this prefix is used in the sample metrics definitions for external traffic.
161176

162177
You can go ahead and mark all the known external traffic in a similar way: databases, VMs, web services, etc.
163178

164179
{#admon title="Info"}
165180
Granted, in the current release of NetObserv, going through every Subnet Labels configuration might be cumbersome. `FlowCollector` is a centralized API, typically managed by cluster admins, whereas knowing the various subnet dependencies might be more in the perimeter of application teams. We are currently working on a new feature that allows delegating that kind of configuration, so stay tuned!
166181
{/}
167182

168-
Once we've created that label, we need to update our `FlowMetric` examples that filter on subnet label absence.
169-
170-
```bash
171-
kubectl edit flowmetric flowmetric-cluster-external-egress-traffic -n netobserv
172-
```
173-
174-
So instead of:
175-
176-
```yaml
177-
labels: [SrcK8S_HostName,SrcK8S_Namespace,SrcK8S_OwnerName,SrcK8S_OwnerType]
178-
filters:
179-
- field: DstSubnetLabel
180-
matchType: Absence
181-
```
182-
183-
we would use now:
184-
185-
```yaml
186-
labels: [SrcK8S_HostName,SrcK8S_Namespace,SrcK8S_OwnerName,SrcK8S_OwnerType,DstSubnetLabel]
187-
filters:
188-
- field: DstSubnetLabel
189-
matchType: Absence
190-
- field: DstSubnetLabel
191-
matchType: MatchRegex
192-
value: "^EXT-.*"
193-
```
194-
195-
so that traffic to our new label is considered as external. We can also add `DstSubnetLabel` to the list of labels in the generated metric, for a finer granularity of the destinations.
196-
197-
A similar change can be done for the ingress traffic.
198-
199-
{#admon title="Info"}
200-
In `FlowMetrics`, when there are several filters for the same key, those filters are OR'ed, ie. the match is satisfied if one at least is satisfied. Filters on different keys are AND'ed.
201-
{/}
202-
203183
With this setup, we are finally able to understand where the traffic is flowing to:
204184

205185
![Prometheus/promql for external egress traffic, labelled](./external-promql-labelled.png)

0 commit comments

Comments
 (0)