internal metrics: add grafana version

This commit is contained in:
bergquist 2017-09-26 15:25:44 +02:00
parent 0778f31828
commit 2ed753232f
2 changed files with 14 additions and 2 deletions

View File

@ -14,6 +14,7 @@ import (
"net/http" "net/http"
_ "net/http/pprof" _ "net/http/pprof"
"github.com/grafana/grafana/pkg/metrics"
"github.com/grafana/grafana/pkg/models" "github.com/grafana/grafana/pkg/models"
"github.com/grafana/grafana/pkg/services/sqlstore" "github.com/grafana/grafana/pkg/services/sqlstore"
"github.com/grafana/grafana/pkg/setting" "github.com/grafana/grafana/pkg/setting"
@ -29,7 +30,7 @@ import (
_ "github.com/grafana/grafana/pkg/tsdb/testdata" _ "github.com/grafana/grafana/pkg/tsdb/testdata"
) )
var version = "4.1.0" var version = "4.6.0"
var commit = "NA" var commit = "NA"
var buildstamp string var buildstamp string
var build_date string var build_date string
@ -80,6 +81,8 @@ func main() {
setting.BuildCommit = commit setting.BuildCommit = commit
setting.BuildStamp = buildstampInt64 setting.BuildStamp = buildstampInt64
metrics.M_Grafana_Version.WithLabelValues(version).Set(1)
server := NewGrafanaServer() server := NewGrafanaServer()
server.Start() server.Start()
} }

View File

@ -56,6 +56,7 @@ var (
M_StatTotal_Users prometheus.Gauge M_StatTotal_Users prometheus.Gauge
M_StatTotal_Orgs prometheus.Gauge M_StatTotal_Orgs prometheus.Gauge
M_StatTotal_Playlists prometheus.Gauge M_StatTotal_Playlists prometheus.Gauge
M_Grafana_Version *prometheus.GaugeVec
) )
func init() { func init() {
@ -263,6 +264,13 @@ func init() {
Help: "total amount of playlists", Help: "total amount of playlists",
Namespace: exporterName, Namespace: exporterName,
}) })
M_Grafana_Version = prometheus.NewGaugeVec(prometheus.GaugeOpts{
Name: "info",
Help: "Information about the Grafana",
Namespace: exporterName,
}, []string{"version"})
} }
func initMetricVars(settings *MetricSettings) { func initMetricVars(settings *MetricSettings) {
@ -298,7 +306,8 @@ func initMetricVars(settings *MetricSettings) {
M_StatTotal_Dashboards, M_StatTotal_Dashboards,
M_StatTotal_Users, M_StatTotal_Users,
M_StatTotal_Orgs, M_StatTotal_Orgs,
M_StatTotal_Playlists) M_StatTotal_Playlists,
M_Grafana_Version)
go instrumentationLoop(settings) go instrumentationLoop(settings)
} }