mirror of
https://github.com/grafana/grafana.git
synced 2025-01-19 13:03:32 -06:00
Add new build info metrics that contains more info (#13876)
* Add new build info metrics that contains more info The goal was to add more information about Grafana. But rather than just adding those to the current metrics I created a new metric since its a common pattern in the prometheus community to expose that info in a metric named `*_build_info`. We keep the old metric to avoid introducing any breaking changes but we should be able to remove it the next breaking change
This commit is contained in:
parent
1dc8b898bb
commit
42d902b07d
@ -80,7 +80,7 @@ func main() {
|
||||
setting.BuildBranch = buildBranch
|
||||
setting.IsEnterprise = extensions.IsEnterprise
|
||||
|
||||
metrics.M_Grafana_Version.WithLabelValues(version).Set(1)
|
||||
metrics.SetBuildInformation(version, commit, buildBranch)
|
||||
|
||||
server := NewGrafanaServer()
|
||||
|
||||
|
@ -58,7 +58,14 @@ var (
|
||||
M_StatActive_Users prometheus.Gauge
|
||||
M_StatTotal_Orgs prometheus.Gauge
|
||||
M_StatTotal_Playlists prometheus.Gauge
|
||||
M_Grafana_Version *prometheus.GaugeVec
|
||||
|
||||
// M_Grafana_Version is a gauge that contains build info about this binary
|
||||
//
|
||||
// Deprecated: use M_Grafana_Build_Version instead.
|
||||
M_Grafana_Version *prometheus.GaugeVec
|
||||
|
||||
// grafanaBuildVersion is a gauge that contains build info about this binary
|
||||
grafanaBuildVersion *prometheus.GaugeVec
|
||||
)
|
||||
|
||||
func newCounterVecStartingAtZero(opts prometheus.CounterOpts, labels []string, labelValues ...string) *prometheus.CounterVec {
|
||||
@ -293,9 +300,25 @@ func init() {
|
||||
|
||||
M_Grafana_Version = prometheus.NewGaugeVec(prometheus.GaugeOpts{
|
||||
Name: "info",
|
||||
Help: "Information about the Grafana",
|
||||
Help: "Information about the Grafana. This metric is deprecated. please use `grafana_build_info`",
|
||||
Namespace: exporterName,
|
||||
}, []string{"version"})
|
||||
|
||||
grafanaBuildVersion = prometheus.NewGaugeVec(prometheus.GaugeOpts{
|
||||
Name: "build_info",
|
||||
Help: "A metric with a constant '1' value labeled by version, revision, branch, and goversion from which Grafana was built.",
|
||||
Namespace: exporterName,
|
||||
}, []string{"version", "revision", "branch", "goversion"})
|
||||
}
|
||||
|
||||
// SetBuildInformation sets the build information for this binary
|
||||
func SetBuildInformation(version, revision, branch string) {
|
||||
// We export this info twice for backwards compability.
|
||||
// Once this have been released for some time we should be able to remote `M_Grafana_Version`
|
||||
// The reason we added a new one is that its common practice in the prometheus community
|
||||
// to name this metric `*_build_info` so its easy to do aggregation on all programs.
|
||||
M_Grafana_Version.WithLabelValues(version).Set(1)
|
||||
grafanaBuildVersion.WithLabelValues(version, revision, branch, runtime.Version()).Set(1)
|
||||
}
|
||||
|
||||
func initMetricVars() {
|
||||
@ -334,7 +357,8 @@ func initMetricVars() {
|
||||
M_StatActive_Users,
|
||||
M_StatTotal_Orgs,
|
||||
M_StatTotal_Playlists,
|
||||
M_Grafana_Version)
|
||||
M_Grafana_Version,
|
||||
grafanaBuildVersion)
|
||||
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user