A lightweight Build Event Service (BES) server that receives Bazel build events over gRPC and exports Prometheus metrics.
Bazel publishes a stream of build events (test results, action summaries, build metrics, etc.) to a BES backend. This server consumes that stream, logs the events, and records key data points as Prometheus metrics on a separate HTTP endpoint.
The project currently provides the following prometheus metrics for use:
| Metric | Type | Extra Labels | Description |
|---|---|---|---|
bazel_builds_total |
Counter | command, exit_code_name |
Total number of completed builds |
bazel_build_duration_seconds |
Histogram | command, exit_code_name |
Build duration from start to finish |
bazel_cache_hit_ratio |
Gauge | Ratio of cache hits (1 - executed/created) | |
bazel_test_runs_total |
Counter | status, cached_locally |
Total individual test runs |
bazel_test_attempts_total |
Counter | overall_status |
Total test attempts across all tests |
bazel_test_flaky_total |
Counter | label |
Tests where attempts exceeded run count |
bazel_action_failures_total |
Counter | action_type |
Failed build actions |
make build
cd build && ./bes-serverOr with Docker:
make container-runThe gRPC server listens on :8082 and the Prometheus metrics endpoint on :9090.
Add the following to your project's .bazelrc (or ~/.bazelrc for all projects):
build --bes_backend=grpc://localhost:8082
build --bes_timeout=5s
build --bes_upload_mode=fully_async
bazel build //...
# or
bazel test //...curl -s localhost:9090/metrics | grep bazel_