Skip to content

Commit

Permalink
Merge pull request #6688 from ipfs/ipfs-info-prometheus-metric
Browse files Browse the repository at this point in the history
feat: add ipfs version info to prometheus metrics
  • Loading branch information
Stebalien authored Sep 30, 2019
2 parents 208a340 + bbe2f50 commit 0343148
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion cmd/ipfs/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ import (
goprocess "github.com/jbenet/goprocess"
ma "github.com/multiformats/go-multiaddr"
manet "github.com/multiformats/go-multiaddr-net"
"github.com/prometheus/client_golang/prometheus"
prometheus "github.com/prometheus/client_golang/prometheus"
promauto "github.com/prometheus/client_golang/prometheus/promauto"
)

const (
Expand Down Expand Up @@ -414,6 +415,18 @@ func daemonFunc(req *cmds.Request, re cmds.ResponseEmitter, env cmds.Environment
}
}

// Add ipfs version info to prometheous metrics
var ipfsInfoMetric = promauto.NewGaugeVec(prometheus.GaugeOpts{
Name: "ipfs_info",
Help: "IPFS version information.",
}, []string{"version", "commit"})

// Setting to 1 lets us multiply it with other stats to add the version labels
ipfsInfoMetric.With(prometheus.Labels{
"version": version.CurrentVersionNumber,
"commit": version.CurrentCommit,
}).Set(1)

// initialize metrics collector
prometheus.MustRegister(&corehttp.IpfsNodeCollector{Node: node})

Expand Down

0 comments on commit 0343148

Please sign in to comment.