mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2025-09-01 22:59:22 +00:00
Add /api/metrics/prometheus endpoint
This commit is contained in:
@@ -11,6 +11,7 @@ import (
|
|||||||
"github.com/drone/drone/router/middleware/token"
|
"github.com/drone/drone/router/middleware/token"
|
||||||
"github.com/drone/drone/server"
|
"github.com/drone/drone/server"
|
||||||
"github.com/drone/drone/server/debug"
|
"github.com/drone/drone/server/debug"
|
||||||
|
"github.com/drone/drone/server/metrics"
|
||||||
"github.com/drone/drone/server/template"
|
"github.com/drone/drone/server/template"
|
||||||
|
|
||||||
"github.com/drone/drone-ui/dist"
|
"github.com/drone/drone-ui/dist"
|
||||||
@@ -171,6 +172,14 @@ func Load(middleware ...gin.HandlerFunc) http.Handler {
|
|||||||
debugger.GET("/pprof/trace", debug.TraceHandler())
|
debugger.GET("/pprof/trace", debug.TraceHandler())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
monitor := e.Group("/api/metrics")
|
||||||
|
{
|
||||||
|
monitor.GET("/prometheus",
|
||||||
|
session.MustAdmin(),
|
||||||
|
metrics.PromHandler(),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
return e
|
return e
|
||||||
}
|
}
|
||||||
|
|
||||||
|
14
server/metrics/prometheus.go
Normal file
14
server/metrics/prometheus.go
Normal 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)
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user