10 releases

0.5.4 Oct 17, 2024
0.5.3 Oct 15, 2024
0.5.0 Jul 12, 2024
0.4.2 Jun 21, 2024
0.4.0 Apr 10, 2024

#301 in Unix APIs

Download history 4/week @ 2024-09-21 1/week @ 2024-09-28 145/week @ 2024-10-05 287/week @ 2024-10-12 36/week @ 2024-10-19 1/week @ 2024-10-26 24/week @ 2024-11-02 2/week @ 2024-11-09 49/week @ 2024-11-30

59 downloads per month

Apache-2.0

2MB
8K SLoC

bpf-metrics-exporter

Exports metrics from the kernel's BPF subsystem to OpenTelmetry. These can later be enriched with other metrics from the system, for example, to correlate process IDs -> containers -> k8s pods.

Usage

./bpf-metrics-exporter --otlp-grpc localhost:4317

Metrics

The following metrics are currently exported, this list will continue to expand:

Gauges

  • bpf_program_info: Information on each loaded BPF Program
    • Labels:
      • id: The ID of the BPF program
      • name: The name of the BPF program
      • type: The type of the BPF program as a readable string
      • tag: The tag of the BPF program
      • gpl_compatible: Whether the BPF program is GPL compatible
      • load_time: The time the BPF program was loaded
  • bpf_map_info: Information of each loaded BPF Map
    • Labels:
      • id: The ID of the BPF map
      • name: The name of the BPF map
      • type: The type of the BPF map as an u32 which corresponds to the following kernel enumeration
      • key_size: The key size in bytes for the BPF map
      • value_size: The value size for the BPF map
      • max_entries: The maximum number of entries for the BPF map.
      • flags: Loadtime specific flags for the BPF map
  • bpf_link_info: Information on each of the loaded BPF Link
    • Labels:
      • id: The ID of the bpf Link
      • prog_id: The Program ID of the BPF program which is using the Link.
      • type: The BPF Link type as a u32 which corresponds to the following kernel enumeration
  • bpf_program_load_time: The standard UTC time the program was loaded in seconds
    • Labels:
      • id: The ID of the BPF program
      • name: The name of the BPF program
      • type: The type of the BPF program as a readable string

Counters

Note: All counters will have the suffix _total appended.

  • bpf_program_size_jitted_bytes: The size in bytes of the program's JIT-compiled machine code.
    • Labels:
      • id: The ID of the BPF program
      • name: The name of the BPF program
      • type: The type of the BPF program as a readable string
  • bpf_program_size_translated_bytes: The size of the BPF program in bytes.
    • Labels:
      • id: The ID of the BPF program
      • name: The name of the BPF program
      • type: The type of the BPF program as a readable string
  • bpf_program_mem_bytes: The amount of memory used by the BPF program in bytes.
    • Labels:
      • id: The ID of the BPF program
      • name: The name of the BPF program
      • type: The type of the BPF program as a readable string
  • bpf_program_verified_instructions: The number of instructions in the BPF program.
    • Labels:
      • id: The ID of the BPF program
      • name: The name of the BPF program
      • type: The type of the BPF program as a readable string
  • bpf_map_key_size: The size of the BPF map key
    • Labels:
      • id: The ID of the BPF map
      • name: The name of the BPF map
      • type: The type of the BPF map as an u32 which corresponds to the following kernel enumeration
  • bpf_map_value_size: The size of the BPF map value
    • Labels:
      • id: The ID of the BPF map
      • name: The name of the BPF map
      • type: The type of the BPF map as an u32 which corresponds to the following kernel enumeration
  • bpf_map_max_entries: The maximum number of entries allowed for the BPF map
    • Labels:
      • id: The ID of the BPF map
      • name: The name of the BPF map
      • type: The type of the BPF map as an u32 which corresponds to the following kernel enumeration

Try it out

You'll need a Grafana stack set up. You can quickly deploy one using:

podman play kube metrics-stack.yaml

Then, you can deploy the exporter:

sudo ./target/debug/bpf-metrics-exporter

You can log into grafana at http://localhost:3000/ using the default user:password admin:admin.

From there simply select the default dashboard titled eBPF Subsystem Metrics:

eBPF Subsystem Metrics

In order to clean everything up simply exit the bpf-metrics-exporter process with ctrl+c and run:

podman kube down metrics-stack.yaml

Dependencies

~53–72MB
~1.5M SLoC