Skip to content

Commit 27fa748

Browse files
authored
NETOBSERV-2118 add missing sampling and exclude interfaces options (#209)
* add missing sampling and exclude interfaces options * update sampling descripton * fix rebase * fix spacing * rebase fixes
1 parent f3bd130 commit 27fa748

File tree

4 files changed

+161
-133
lines changed

4 files changed

+161
-133
lines changed

docs/netobserv_cli.adoc

Lines changed: 98 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -55,42 +55,44 @@ $ oc netobserv flows [<feature_option>] [<command_options>]
5555
[cols="1,1,1",options="header"]
5656
|===
5757
| Option | Description | Default
58-
|--enable_all| enable all eBPF features | false
59-
|--enable_dns| enable DNS tracking | false
60-
|--enable_ipsec| enable IPsec tracking | false
61-
|--enable_network_events| enable network events monitoring | false
62-
|--enable_pkt_translation| enable packet translation | false
63-
|--enable_pkt_drop| enable packet drop | false
64-
|--enable_rtt| enable RTT tracking | false
65-
|--get-subnets| get subnets information | false
66-
|--enable_udn_mapping| enable User Defined Network mapping | false
67-
|--background| run in background | false
68-
|--copy| copy the output files locally | prompt
69-
|--log-level| components logs | info
70-
|--max-time| maximum capture time | 5m
71-
|--max-bytes| maximum capture bytes | 50000000 = 50MB
72-
|--action| filter action | Accept
73-
|--cidr| filter CIDR | 0.0.0.0/0
74-
|--direction| filter direction | -
75-
|--dport| filter destination port | -
76-
|--dport_range| filter destination port range | -
77-
|--dports| filter on either of two destination ports | -
78-
|--drops| filter flows with only dropped packets | false
79-
|--icmp_code| filter ICMP code | -
80-
|--icmp_type| filter ICMP type | -
81-
|--node-selector| capture on specific nodes | -
82-
|--peer_ip| filter peer IP | -
83-
|--peer_cidr| filter peer CIDR | -
84-
|--port_range| filter port range | -
85-
|--port| filter port | -
86-
|--ports| filter on either of two ports | -
87-
|--protocol| filter protocol | -
88-
|--query| filter flows using a custom query | -
89-
|--sport_range| filter source port range | -
90-
|--sport| filter source port | -
91-
|--sports| filter on either of two source ports | -
92-
|--tcp_flags| filter TCP flags | -
93-
|--interfaces| interfaces to monitor | -
58+
|--enable_all| enable all eBPF features | false
59+
|--enable_dns| enable DNS tracking | false
60+
|--enable_ipsec| enable IPsec tracking | false
61+
|--enable_network_events| enable network events monitoring | false
62+
|--enable_pkt_translation| enable packet translation | false
63+
|--enable_pkt_drop| enable packet drop | false
64+
|--enable_rtt| enable RTT tracking | false
65+
|--enable_udn_mapping| enable User Defined Network mapping | false
66+
|--get-subnets| get subnets information | false
67+
|--sampling| value that defines the ratio of packets being sampled | 1
68+
|--background| run in background | false
69+
|--copy| copy the output files locally | prompt
70+
|--log-level| components logs | info
71+
|--max-time| maximum capture time | 5m
72+
|--max-bytes| maximum capture bytes | 50000000 = 50MB
73+
|--action| filter action | Accept
74+
|--cidr| filter CIDR | 0.0.0.0/0
75+
|--direction| filter direction | -
76+
|--dport| filter destination port | -
77+
|--dport_range| filter destination port range | -
78+
|--dports| filter on either of two destination ports | -
79+
|--drops| filter flows with only dropped packets | false
80+
|--icmp_code| filter ICMP code | -
81+
|--icmp_type| filter ICMP type | -
82+
|--node-selector| capture on specific nodes | -
83+
|--peer_ip| filter peer IP | -
84+
|--peer_cidr| filter peer CIDR | -
85+
|--port_range| filter port range | -
86+
|--port| filter port | -
87+
|--ports| filter on either of two ports | -
88+
|--protocol| filter protocol | -
89+
|--query| filter flows using a custom query | -
90+
|--sport_range| filter source port range | -
91+
|--sport| filter source port | -
92+
|--sports| filter on either of two source ports | -
93+
|--tcp_flags| filter TCP flags | -
94+
|--interfaces| interfaces to monitor, comma separated | -
95+
|--exclude_interfaces| interfaces to exclude, comma separated | lo
9496
|===
9597

9698
.Example running flows capture on TCP protocol and port 49051 with PacketDrop and RTT features enabled:
@@ -111,32 +113,32 @@ $ oc netobserv packets [<option>]
111113
[cols="1,1,1",options="header"]
112114
|===
113115
| Option | Description | Default
114-
|--background| run in background | false
115-
|--copy| copy the output files locally | prompt
116-
|--log-level| components logs | info
117-
|--max-time| maximum capture time | 5m
118-
|--max-bytes| maximum capture bytes | 50000000 = 50MB
119-
|--action| filter action | Accept
120-
|--cidr| filter CIDR | 0.0.0.0/0
121-
|--direction| filter direction | -
122-
|--dport| filter destination port | -
123-
|--dport_range| filter destination port range | -
124-
|--dports| filter on either of two destination ports | -
125-
|--drops| filter flows with only dropped packets | false
126-
|--icmp_code| filter ICMP code | -
127-
|--icmp_type| filter ICMP type | -
128-
|--node-selector| capture on specific nodes | -
129-
|--peer_ip| filter peer IP | -
130-
|--peer_cidr| filter peer CIDR | -
131-
|--port_range| filter port range | -
132-
|--port| filter port | -
133-
|--ports| filter on either of two ports | -
134-
|--protocol| filter protocol | -
135-
|--query| filter flows using a custom query | -
136-
|--sport_range| filter source port range | -
137-
|--sport| filter source port | -
138-
|--sports| filter on either of two source ports | -
139-
|--tcp_flags| filter TCP flags | -
116+
|--background| run in background | false
117+
|--copy| copy the output files locally | prompt
118+
|--log-level| components logs | info
119+
|--max-time| maximum capture time | 5m
120+
|--max-bytes| maximum capture bytes | 50000000 = 50MB
121+
|--action| filter action | Accept
122+
|--cidr| filter CIDR | 0.0.0.0/0
123+
|--direction| filter direction | -
124+
|--dport| filter destination port | -
125+
|--dport_range| filter destination port range | -
126+
|--dports| filter on either of two destination ports | -
127+
|--drops| filter flows with only dropped packets | false
128+
|--icmp_code| filter ICMP code | -
129+
|--icmp_type| filter ICMP type | -
130+
|--node-selector| capture on specific nodes | -
131+
|--peer_ip| filter peer IP | -
132+
|--peer_cidr| filter peer CIDR | -
133+
|--port_range| filter port range | -
134+
|--port| filter port | -
135+
|--ports| filter on either of two ports | -
136+
|--protocol| filter protocol | -
137+
|--query| filter flows using a custom query | -
138+
|--sport_range| filter source port range | -
139+
|--sport| filter source port | -
140+
|--sports| filter on either of two source ports | -
141+
|--tcp_flags| filter TCP flags | -
140142
|===
141143

142144
.Example running packets capture on TCP protocol and port 49051:
@@ -156,38 +158,40 @@ $ oc netobserv metrics [<option>]
156158
[cols="1,1,1",options="header"]
157159
|===
158160
| Option | Description | Default
159-
|--enable_all| enable all eBPF features | false
160-
|--enable_dns| enable DNS tracking | false
161-
|--enable_ipsec| enable IPsec tracking | false
162-
|--enable_network_events| enable network events monitoring | false
163-
|--enable_pkt_translation| enable packet translation | false
164-
|--enable_pkt_drop| enable packet drop | false
165-
|--enable_rtt| enable RTT tracking | false
166-
|--get-subnets| get subnets information | false
167-
|--enable_udn_mapping| enable User Defined Network mapping | false
168-
|--action| filter action | Accept
169-
|--cidr| filter CIDR | 0.0.0.0/0
170-
|--direction| filter direction | -
171-
|--dport| filter destination port | -
172-
|--dport_range| filter destination port range | -
173-
|--dports| filter on either of two destination ports | -
174-
|--drops| filter flows with only dropped packets | false
175-
|--icmp_code| filter ICMP code | -
176-
|--icmp_type| filter ICMP type | -
177-
|--node-selector| capture on specific nodes | -
178-
|--peer_ip| filter peer IP | -
179-
|--peer_cidr| filter peer CIDR | -
180-
|--port_range| filter port range | -
181-
|--port| filter port | -
182-
|--ports| filter on either of two ports | -
183-
|--protocol| filter protocol | -
184-
|--query| filter flows using a custom query | -
185-
|--sport_range| filter source port range | -
186-
|--sport| filter source port | -
187-
|--sports| filter on either of two source ports | -
188-
|--tcp_flags| filter TCP flags | -
189-
|--interfaces| interfaces to monitor | -
190-
|--include_list| list of metric names to generate | namespace_flows_total,node_ingress_bytes_total,node_egress_bytes_total,workload_ingress_bytes_total
161+
|--enable_all| enable all eBPF features | false
162+
|--enable_dns| enable DNS tracking | false
163+
|--enable_ipsec| enable IPsec tracking | false
164+
|--enable_network_events| enable network events monitoring | false
165+
|--enable_pkt_translation| enable packet translation | false
166+
|--enable_pkt_drop| enable packet drop | false
167+
|--enable_rtt| enable RTT tracking | false
168+
|--enable_udn_mapping| enable User Defined Network mapping | false
169+
|--get-subnets| get subnets information | false
170+
|--sampling| value that defines the ratio of packets being sampled | 1
171+
|--action| filter action | Accept
172+
|--cidr| filter CIDR | 0.0.0.0/0
173+
|--direction| filter direction | -
174+
|--dport| filter destination port | -
175+
|--dport_range| filter destination port range | -
176+
|--dports| filter on either of two destination ports | -
177+
|--drops| filter flows with only dropped packets | false
178+
|--icmp_code| filter ICMP code | -
179+
|--icmp_type| filter ICMP type | -
180+
|--node-selector| capture on specific nodes | -
181+
|--peer_ip| filter peer IP | -
182+
|--peer_cidr| filter peer CIDR | -
183+
|--port_range| filter port range | -
184+
|--port| filter port | -
185+
|--ports| filter on either of two ports | -
186+
|--protocol| filter protocol | -
187+
|--query| filter flows using a custom query | -
188+
|--sport_range| filter source port range | -
189+
|--sport| filter source port | -
190+
|--sports| filter on either of two source ports | -
191+
|--tcp_flags| filter TCP flags | -
192+
|--include_list| list of metric names to generate | namespace_flows_total,node_ingress_bytes_total,node_egress_bytes_total,workload_ingress_bytes_total
193+
|--interfaces| interfaces to monitor, comma separated | -
194+
|--exclude_interfaces| interfaces to exclude, comma separated | lo
191195
|===
192196

193197
.Example running metrics capture for TCP drops

scripts/functions.sh

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -488,9 +488,15 @@ function edit_manifest() {
488488
fi
489489

490490
case "$1" in
491+
"sampling")
492+
"$YQ_BIN" e --inplace ".spec.template.spec.containers[0].env[] |= select(.name==\"SAMPLING\").value|=\"$2\"" "$manifest"
493+
;;
491494
"interfaces")
492495
"$YQ_BIN" e --inplace ".spec.template.spec.containers[0].env[] |= select(.name==\"INTERFACES\").value|=\"$2\"" "$manifest"
493496
;;
497+
"exclude_interfaces")
498+
"$YQ_BIN" e --inplace ".spec.template.spec.containers[0].env[] |= select(.name==\"EXCLUDE_INTERFACES\").value|=\"$2\"" "$manifest"
499+
;;
494500
"pkt_drop_enable")
495501
"$YQ_BIN" e --inplace ".spec.template.spec.containers[0].env[] |= select(.name==\"ENABLE_PKT_DROPS\").value|=\"$2\"" "$manifest"
496502
;;
@@ -724,6 +730,22 @@ function check_args_and_apply() {
724730
echo "invalid value for --copy"
725731
fi
726732
;;
733+
*sampling) # ebpf sampling
734+
if [[ "$command" == "flows" || "$command" == "metrics" ]]; then
735+
edit_manifest "sampling" "$value"
736+
else
737+
echo "--sampling is invalid option for packets"
738+
exit 1
739+
fi
740+
;;
741+
*exclude_interfaces) # ebpf exclude interfaces
742+
if [[ "$command" == "flows" || "$command" == "metrics" ]]; then
743+
edit_manifest "exclude_interfaces" "$value"
744+
else
745+
echo "--exclude_interfaces is invalid option for packets"
746+
exit 1
747+
fi
748+
;;
727749
*interfaces) # Interfaces
728750
edit_manifest "interfaces" "$value"
729751
;;

scripts/generate-doc.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,8 @@ $ oc netobserv metrics [<option>]
118118
| Option | Description | Default"
119119
features_usage
120120
filters_usage
121-
flowsAndMetrics_filters_usage
122121
metrics_options
122+
flowsAndMetrics_filters_usage
123123
echo -e "|==="
124124
# Metrics example
125125
echo "

0 commit comments

Comments
 (0)