Skip to content

Include build info on Prometheus metrics

João Pereira requested to merge include-build-info-on-metrics into release/2.7-gitlab

Problem

The build info attributes are not exposed through Prometheus.

Solution

Expose build info using a labeled gauge, named registry_build_info, with a fixed value of 1. This gauge has three attributes: version, revision and package (all exposed by the version package and defined in the Makefile).

This strategy (labeled gauge with a fixed value of 1) is the same as the one used by Prometheus itself (for prometheus_build_info) and by other Docker related projects (e.g. moby/moby).

How to Use

Add the following to the container registry config file:

http:
  # ...
  debug:
    addr: :5001
    prometheus:
      enabled: true
      path: /metrics

Invoke the /metrics path:

curl localhost:5001/metrics
...
# HELP registry_build_info Information about the registry.
# TYPE registry_build_info gauge
registry_build_info{package="github.com/docker/distribution",revision="7a3d88e28cf3701fc263a4b136307ab65baa25cf.m",version="v2.7.6-gitlab-34-g7a3d88e2.m"} 1
...
Edited by João Pereira

Merge request reports