Skip to content

Commit 7c05bf1

Browse files
committed
netstacklat: Add ebpf-exporter config
Add a YAML configuration that ebpf-exporter can use to convert the BPF maps to Prometheus metrics. Convert the histogram map for each hook into the corresponding Prometheus histogram. Also update the README to explain how to use netstacklat together with ebpf-exporter. Signed-off-by: Simon Sundberg <[email protected]>
1 parent 2cd7c02 commit 7c05bf1

File tree

2 files changed

+58
-1
lines changed

2 files changed

+58
-1
lines changed

netstacklat/README.md

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,26 @@ sudo bpftrace -e '
3333
The eBPF part of the tool (`netstacklat.bpf.c`) is designed to be
3434
compatible with
3535
[ebpf_exporter](https://github.com/cloudflare/ebpf_exporter), so that
36-
the data can easily be exported to Prometheus.
36+
the data can easily be exported to Prometheus. The easiest way to use
37+
netstacklat together with ebpf-exporter is simply to point it to this
38+
directory, i.e.
39+
```console
40+
$ ebpf_exporter --config.dir=<path>/bpf-examples/netstacklat --config.names=netstacklat
41+
```
42+
43+
Alternatively, you can copy over the files to ebpf-exporter's example
44+
repository.
45+
```console
46+
$ cp netstacklat.{bpf.c,h,yaml} -t <path>/ebpf_exporter/examples/
47+
# Fix up some header includes (e.g. "vmlinux_local.h" -> <vmlinux.h>
48+
$ make -C <path>/ebpf_exporter/examples build
49+
$ ebpf_exporter --config.dir=<path>/ebpf_exporter/examples --config.names
50+
```
51+
52+
Note that when using together with ebpf-exporter, some of the
53+
functionality handled by netstacklat's userspace program will not be
54+
available. This includes setting the `TAI_OFFSET` constant in
55+
`netstacklat.bpf.c` to match your system's TAI offset (you can do this
56+
manually instead), and enabling RX timestamping by the kernel (see the
57+
`enable_sw_rx_tstamps()` function in `netstacklat.c` for an example of
58+
how to do this).

netstacklat/netstacklat.yaml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
metrics:
2+
histograms:
3+
- name: netstack_latency_tcp_v4_do_rcv_seconds
4+
help: Netstack latency up to the tcp_v4_do_rcv() function
5+
bucket_type: exp2
6+
bucket_min: 0
7+
bucket_max: 30
8+
bucket_multiplier: 0.000000001 # nanoseconds to seconds
9+
labels:
10+
- name: bucket
11+
size: 4
12+
decoders:
13+
- name: uint
14+
- name: netstack_latency_tcp_data_queue_seconds
15+
help: Netstack latency up to the tcp_data_queue() function
16+
bucket_type: exp2
17+
bucket_min: 0
18+
bucket_max: 30
19+
bucket_multiplier: 0.000000001 # nanoseconds to seconds
20+
labels:
21+
- name: bucket
22+
size: 4
23+
decoders:
24+
- name: uint
25+
- name: netstack_latency_udp_queue_rcv_seconds
26+
help: Netstack latency up to the udp_queue_rcv_one_skb() function
27+
bucket_type: exp2
28+
bucket_min: 0
29+
bucket_max: 30
30+
bucket_multiplier: 0.000000001 # nanoseconds to seconds
31+
labels:
32+
- name: bucket
33+
size: 4
34+
decoders:
35+
- name: uint

0 commit comments

Comments
 (0)