Skip to content

darthfork/bazel-build-events-prometheus

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

bazel-build-events-prometheus

A lightweight Build Event Service (BES) server that receives Bazel build events over gRPC and exports Prometheus metrics.

How it works

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.

Metrics

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

Local Development Setup

1. Start the server

make build
cd build && ./bes-server

Or with Docker:

make container-run

The gRPC server listens on :8082 and the Prometheus metrics endpoint on :9090.

2. Configure your .bazelrc

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

3. Run a build

bazel build //...
# or
bazel test //...

4. Test metrics collection

curl -s localhost:9090/metrics | grep bazel_

About

Generate prometheus metrics from bazel-build-events

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published