Helm chart and Dockerfile to support running ebpf_exporter on Kubernetes.
This project is:
- Maintained by Teachers Pay Teachers.
- Used in production by Teachers Pay Teachers.
- Docker image tags match ebpf_exporter releases.
- The
apiVersion
of the Helm chart matches ebpf_exporter releases. - Helm
version
follows semantic versioning and increments when there are changes tovalues.yaml
.
- GitHub releases are published with either a
ebpf-exporter-helm-
orebpf-exporter-docker-
prefix, depending on whhat was changed. - Docker images are published to Dockerhub.
- Helm charts are published to teacherspayteachers.github.io/helm-charts/..
- Docker is required to build Docker images.
- Helm is required to lint and template the Helm chart.
- Helm releases require hosts to have Linux kernel source code or headers.
- Helm releases require elevated security privileges.
Cloudflare's ebpf_exporter makes it easy to extract Prometheus metrics from eBPF programs. However, it does not contain production-ready Docker images.
ebpf_exporter_helm is a community Helm chart for ebpf_exporter. However, the author has told us over email that it is not maintained.
This repository contains a production-ready Docker image based on ebpf_exporter_dockerfile, and a maintained Helm chart based on ebpf_exporter_helm.
First, define a set of eBPF programs. See
ebpf_exporter
for the configuration format. Optionally, override any default values in
values.yaml
. For example:
config:
- programs:
- name: cachestat
metrics:
counters:
- name: page_cache_ops_total
help: Page cache operation counters by type
table: counts
labels:
- name: op
size: 8
decoders:
- name: ksym
- name: command
size: 128
decoders:
- name: string
- name: regexp
regexps:
- ^systemd-journal$
- ^syslog-ng$
kprobes:
add_to_page_cache_lru: do_count
mark_page_accessed: do_count
account_page_dirtied: do_count
mark_buffer_dirty: do_count
code: |
#include <uapi/linux/ptrace.h>
struct key_t {
u64 ip;
char command[128];
};
BPF_HASH(counts, struct key_t);
int do_count(struct pt_regs *ctx) {
struct key_t key = { .ip = PT_REGS_IP(ctx) - 1 };
bpf_get_current_comm(&key.command, sizeof(key.command));
counts.increment(key);
return 0;
}
Next, supply the programs to the Helm install command.
$ helm repo helm repo add tpt https://teacherspayteachers.github.io/helm-charts
$ helm install ebpf-exporter tpt/ebpf-exporter -f values.yaml
See ebpf_exporter to understand how exported Prometheus metrics work.
- Cloudflare deploys ebpf_exporter directly on hosts in order to avoid having to bind-mount kernel sources and headers into Docker containers.
- Helm chart that this repository's Helm chart is based on.
- Alternative Dockerfile.
Contributions are very welcome! Please see CONTRIBUTING.md.