Pim van Pelt 4ab3096c8b Add Prometheus metrics endpoint; containerize integration tests
Prometheus metrics (internal/metrics/, cmd/maglevd/)
- New --metrics-addr flag (default :9091, env MAGLEV_METRICS_ADDR)
  serving /metrics via promhttp.
- Gauge metrics scraped on demand via a custom prometheus.Collector:
  maglev_backend_state, maglev_backend_health, maglev_backend_enabled,
  maglev_frontend_pool_backend_weight.
- Inline counter/histogram metrics updated per probe:
  maglev_probe_total (by backend, type, result, code),
  maglev_probe_duration_seconds (by backend, type),
  maglev_backend_transitions_total (by backend, from, to).
- StateSource interface in metrics package breaks the import cycle
  with checker; checker.Checker satisfies it via GetBackendInfo.

Integration tests
- Run maglevd inside a containerlab node (debian:trixie-slim with
  build/ bind-mounted) instead of on the host. Eliminates port
  collisions with any host maglevd.
- maglevc commands run via docker exec into the maglevd container.
- Add 6 Prometheus test cases: endpoint reachable, all backends
  report state=up, probe counters non-zero, duration histogram
  populated, pool weights correct, transition counters present.
2026-04-11 20:50:59 +02:00
2026-04-10 22:22:56 +02:00

maglevd

Health checker and gRPC control plane for VPP Maglev load balancing.

Build and Install

make          # builds build/<arch>/maglevd and build/<arch>/maglevc
make test     # runs all tests
make pkg-deb  # Creates a debian package for arm64 and amd64

Requires Go 1.25+ and (for make proto) protoc with protoc-gen-go and protoc-gen-go-grpc.

Produces vpp-maglev_<version>_amd64.deb and vpp-maglev_<version>_arm64.deb in the build/ directory by cross-compiling with GOOS=linux GOARCH=<arch>. Requires dpkg-deb (available on any Debian/Ubuntu host).

Running

After installing, the unit is enabled but not started automatically:

# edit /etc/vpp-maglev/maglev.yaml, then:
systemctl enable --now vpp-maglevd

Or run the server and client by hand:

maglevd --config /etc/vpp-maglev/maglev.yaml --grpc-addr :9090
maglevd --version                        # print version and exit

maglevc --server localhost:9090          # interactive shell
maglevc show frontends                   # one-shot
maglevc -color=false show backends       # one-shot, no ANSI color
maglevc set backend nginx0-ams pause

Send SIGHUP to maglevd to reload config without restarting. maglevd requires CAP_NET_RAW for ICMP health checks.

Check out a minimal configuration file in [debian/maglev.yaml]. See docs/user-guide.md for flags, signals, and maglevc usage. See docs/config-guide.md for the full configuration reference. See docs/healthchecks.md for health state machine details.

Docker

docker build -t maglevd .
docker run --cap-add NET_RAW -v /etc/vpp-maglev:/etc/vpp-maglev maglevd
Description
A health-checking maglev controlplane for VPP
Readme Apache-2.0 1.6 MiB
Languages
Go 79%
TypeScript 12.8%
CSS 2.9%
Makefile 2.2%
RobotFramework 2.2%
Other 0.8%