From b163084a5f9da096084fc1969acada2bd2d1bfbb Mon Sep 17 00:00:00 2001 From: Joe Betz Date: Fri, 1 Dec 2017 15:13:21 -0800 Subject: [PATCH] metrics: Add server_version metric --- etcdserver/metrics.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/etcdserver/metrics.go b/etcdserver/metrics.go index 17135010441..980e3ebaf4e 100644 --- a/etcdserver/metrics.go +++ b/etcdserver/metrics.go @@ -18,6 +18,7 @@ import ( "time" "github.com/coreos/etcd/pkg/runtime" + "github.com/coreos/etcd/version" "github.com/prometheus/client_golang/prometheus" ) @@ -70,6 +71,13 @@ var ( Name: "lease_expired_total", Help: "The total number of expired leases.", }) + 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() { @@ -81,6 +89,11 @@ func init() { prometheus.MustRegister(proposalsPending) prometheus.MustRegister(proposalsFailed) prometheus.MustRegister(leaseExpired) + prometheus.MustRegister(currentVersion) + + currentVersion.With(prometheus.Labels{ + "server_version": version.Version, + }).Set(1) } func monitorFileDescriptor(done <-chan struct{}) {