Skip to content

Commit

Permalink
api: add /metrics endpoint for prometheus
Browse files Browse the repository at this point in the history
License: MIT
Signed-off-by: Lars Gierth <[email protected]>
  • Loading branch information
Lars Gierth committed Jun 29, 2015
1 parent 2d6b787 commit ed8d3ae
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions cmd/ipfs/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
16 changes: 16 additions & 0 deletions core/corehttp/prometheus.go
Original file line number Diff line number Diff line change
@@ -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
}
}

0 comments on commit ed8d3ae

Please sign in to comment.