mirror of
https://github.com/distribution/distribution.git
synced 2025-09-17 07:40:38 +00:00
Add Prometheus Metrics
at the first iteration, only the following metrics are collected: - HTTP metrics of each API endpoint - cache counter for request/hit/miss - histogram of storage actions, including: GetContent, PutContent, Stat, List, Move, and Delete Signed-off-by: tifayuki <tifayuki@gmail.com>
This commit is contained in:
@@ -21,6 +21,7 @@ import (
|
||||
"github.com/docker/distribution/registry/listener"
|
||||
"github.com/docker/distribution/uuid"
|
||||
"github.com/docker/distribution/version"
|
||||
"github.com/docker/go-metrics"
|
||||
gorhandlers "github.com/gorilla/handlers"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"github.com/spf13/cobra"
|
||||
@@ -58,6 +59,15 @@ var ServeCmd = &cobra.Command{
|
||||
log.Fatalln(err)
|
||||
}
|
||||
|
||||
if config.HTTP.Debug.Prometheus.Enabled {
|
||||
path := config.HTTP.Debug.Prometheus.Path
|
||||
if path == "" {
|
||||
path = "/metrics"
|
||||
}
|
||||
log.Info("providing prometheus metrics on ", path)
|
||||
http.Handle(path, metrics.Handler())
|
||||
}
|
||||
|
||||
if err = registry.ListenAndServe(); err != nil {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
|
Reference in New Issue
Block a user