Add /api/metrics/prometheus endpoint

This commit is contained in:
Jason Riddle 2017-04-27 16:49:28 -04:00
parent d35fe4c7e2
commit 3a255230ec
2 changed files with 23 additions and 0 deletions

View file

@ -11,6 +11,7 @@ import (
"github.com/drone/drone/router/middleware/token"
"github.com/drone/drone/server"
"github.com/drone/drone/server/debug"
"github.com/drone/drone/server/metrics"
"github.com/drone/drone/server/template"
"github.com/drone/drone-ui/dist"
@ -171,6 +172,14 @@ func Load(middleware ...gin.HandlerFunc) http.Handler {
debugger.GET("/pprof/trace", debug.TraceHandler())
}
monitor := e.Group("/api/metrics")
{
monitor.GET("/prometheus",
session.MustAdmin(),
metrics.PromHandler(),
)
}
return e
}

View file

@ -0,0 +1,14 @@
package metrics
import (
"github.com/gin-gonic/gin"
"github.com/prometheus/client_golang/prometheus/promhttp"
)
// PromHandler will pass the call from /api/metrics/prometheus to prometheus
func PromHandler() gin.HandlerFunc {
return func(c *gin.Context) {
promhttp.Handler().ServeHTTP(c.Writer, c.Request)
}
}