1
0
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:
Lars Gierth
2015-06-20 00:59:54 +02:00
parent 2d6b787c99
commit ed8d3ae388
2 changed files with 17 additions and 0 deletions

View File

@ -300,6 +300,7 @@ func serveHTTPApi(req cmds.Request) (error, <-chan error) {
defaultMux("/debug/vars"),
defaultMux("/debug/pprof/"),
corehttp.LogOption(),
corehttp.PrometheusOption("/debug/metrics/prometheus"),
}
if len(cfg.Gateway.RootRedirect) > 0 {

View 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
}
}