metrics: Add server_version metric

This commit is contained in:
Joe Betz 2017-12-01 15:13:21 -08:00 committed by Wenjia Zhang
parent 06da6cf983
commit b3ee996629

View File

@ -18,6 +18,7 @@ import (
"time"
"github.com/coreos/etcd/pkg/runtime"
"github.com/coreos/etcd/version"
"github.com/prometheus/client_golang/prometheus"
)
@ -64,6 +65,13 @@ var (
Name: "proposals_failed_total",
Help: "The total number of failed proposals seen.",
})
currentVersion = prometheus.NewGaugeVec(prometheus.GaugeOpts{
Namespace: "etcd",
Subsystem: "server",
Name: "version",
Help: "Which version is running. 1 for 'server_version' label with current version.",
},
[]string{"server_version"})
)
func init() {
@ -74,6 +82,11 @@ func init() {
prometheus.MustRegister(proposalsApplied)
prometheus.MustRegister(proposalsPending)
prometheus.MustRegister(proposalsFailed)
prometheus.MustRegister(currentVersion)
currentVersion.With(prometheus.Labels{
"server_version": version.Version,
}).Set(1)
}
func monitorFileDescriptor(done <-chan struct{}) {