Skip to content

Commit 0343148

Browse files
authored
Merge pull request #6688 from ipfs/ipfs-info-prometheus-metric
feat: add ipfs version info to prometheus metrics
2 parents 208a340 + bbe2f50 commit 0343148

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

cmd/ipfs/daemon.go

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ import (
3333
goprocess "github.com/jbenet/goprocess"
3434
ma "github.com/multiformats/go-multiaddr"
3535
manet "github.com/multiformats/go-multiaddr-net"
36-
"github.com/prometheus/client_golang/prometheus"
36+
prometheus "github.com/prometheus/client_golang/prometheus"
37+
promauto "github.com/prometheus/client_golang/prometheus/promauto"
3738
)
3839

3940
const (
@@ -414,6 +415,18 @@ func daemonFunc(req *cmds.Request, re cmds.ResponseEmitter, env cmds.Environment
414415
}
415416
}
416417

418+
// Add ipfs version info to prometheous metrics
419+
var ipfsInfoMetric = promauto.NewGaugeVec(prometheus.GaugeOpts{
420+
Name: "ipfs_info",
421+
Help: "IPFS version information.",
422+
}, []string{"version", "commit"})
423+
424+
// Setting to 1 lets us multiply it with other stats to add the version labels
425+
ipfsInfoMetric.With(prometheus.Labels{
426+
"version": version.CurrentVersionNumber,
427+
"commit": version.CurrentCommit,
428+
}).Set(1)
429+
417430
// initialize metrics collector
418431
prometheus.MustRegister(&corehttp.IpfsNodeCollector{Node: node})
419432

0 commit comments

Comments
 (0)