bumblebee
bumblebee copied to clipboard
Adds histogram prometheus metrics
Adds histogram prometheus metrics.
Users can specify histogram metrics using map type ringbuf by using the prefix hist_
struct event {
char fname[255];
// by convention struct member 'le' will be the measurement
u64 le;
};
struct {
__uint(type, BPF_MAP_TYPE_RINGBUF);
__uint(max_entries, 1 << 24);
__type(value, struct event);
} hist_file_read SEC(".maps");
Histogram buckets, as well as the field containing the measurment value, can be provided as flags -b/--hist-buckets
and -k/--hist-value-key
for example:
go run ./bee run --no-tty -b "hist_file_read,[1000,2000,5000,10000,20000]" myprog:latest
output:
curl -XGET -s localhost:9091/metrics | grep ebpf
# HELP ebpf_solo_io_hist_file_read
# TYPE ebpf_solo_io_hist_file_read histogram
ebpf_solo_io_hist_file_read_bucket{fname="test.txt",le="1000"} 7
ebpf_solo_io_hist_file_read_bucket{fname="test.txt",le="2000"} 8
ebpf_solo_io_hist_file_read_bucket{fname="test.txt",le="5000"} 14
ebpf_solo_io_hist_file_read_bucket{fname="test.txt",le="10000"} 16
ebpf_solo_io_hist_file_read_bucket{fname="test.txt",le="20000"} 19
ebpf_solo_io_hist_file_read_bucket{fname="test.txt",le="+Inf"} 20
ebpf_solo_io_hist_file_read_sum{fname="test.txt"} 107008
Also fixes bug where chars would get decoded as ints