mirror of
https://github.com/ipfs/kubo.git
synced 2025-09-09 23:42:20 +08:00
api: add /metrics endpoint for prometheus
License: MIT Signed-off-by: Lars Gierth <larsg@systemli.org>
This commit is contained in:
@ -300,6 +300,7 @@ func serveHTTPApi(req cmds.Request) (error, <-chan error) {
|
|||||||
defaultMux("/debug/vars"),
|
defaultMux("/debug/vars"),
|
||||||
defaultMux("/debug/pprof/"),
|
defaultMux("/debug/pprof/"),
|
||||||
corehttp.LogOption(),
|
corehttp.LogOption(),
|
||||||
|
corehttp.PrometheusOption("/debug/metrics/prometheus"),
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(cfg.Gateway.RootRedirect) > 0 {
|
if len(cfg.Gateway.RootRedirect) > 0 {
|
||||||
|
16
core/corehttp/prometheus.go
Normal file
16
core/corehttp/prometheus.go
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
package corehttp
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
prom "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/prometheus/client_golang/prometheus"
|
||||||
|
|
||||||
|
"github.com/ipfs/go-ipfs/core"
|
||||||
|
)
|
||||||
|
|
||||||
|
func PrometheusOption(path string) ServeOption {
|
||||||
|
return func(n *core.IpfsNode, mux *http.ServeMux) (*http.ServeMux, error) {
|
||||||
|
mux.Handle(path, prom.Handler())
|
||||||
|
return mux, nil
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user