From 2ed753232fcd246a4e42720f6c9b310bd1228c43 Mon Sep 17 00:00:00 2001 From: bergquist Date: Tue, 26 Sep 2017 15:25:44 +0200 Subject: [PATCH] internal metrics: add grafana version --- pkg/cmd/grafana-server/main.go | 5 ++++- pkg/metrics/metrics.go | 11 ++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/pkg/cmd/grafana-server/main.go b/pkg/cmd/grafana-server/main.go index 96fb3f2e9a1..8f90da93177 100644 --- a/pkg/cmd/grafana-server/main.go +++ b/pkg/cmd/grafana-server/main.go @@ -14,6 +14,7 @@ import ( "net/http" _ "net/http/pprof" + "github.com/grafana/grafana/pkg/metrics" "github.com/grafana/grafana/pkg/models" "github.com/grafana/grafana/pkg/services/sqlstore" "github.com/grafana/grafana/pkg/setting" @@ -29,7 +30,7 @@ import ( _ "github.com/grafana/grafana/pkg/tsdb/testdata" ) -var version = "4.1.0" +var version = "4.6.0" var commit = "NA" var buildstamp string var build_date string @@ -80,6 +81,8 @@ func main() { setting.BuildCommit = commit setting.BuildStamp = buildstampInt64 + metrics.M_Grafana_Version.WithLabelValues(version).Set(1) + server := NewGrafanaServer() server.Start() } diff --git a/pkg/metrics/metrics.go b/pkg/metrics/metrics.go index fef1fe26f6c..4b155ae3208 100644 --- a/pkg/metrics/metrics.go +++ b/pkg/metrics/metrics.go @@ -56,6 +56,7 @@ var ( M_StatTotal_Users prometheus.Gauge M_StatTotal_Orgs prometheus.Gauge M_StatTotal_Playlists prometheus.Gauge + M_Grafana_Version *prometheus.GaugeVec ) func init() { @@ -263,6 +264,13 @@ func init() { Help: "total amount of playlists", Namespace: exporterName, }) + + M_Grafana_Version = prometheus.NewGaugeVec(prometheus.GaugeOpts{ + Name: "info", + Help: "Information about the Grafana", + Namespace: exporterName, + }, []string{"version"}) + } func initMetricVars(settings *MetricSettings) { @@ -298,7 +306,8 @@ func initMetricVars(settings *MetricSettings) { M_StatTotal_Dashboards, M_StatTotal_Users, M_StatTotal_Orgs, - M_StatTotal_Playlists) + M_StatTotal_Playlists, + M_Grafana_Version) go instrumentationLoop(settings) }