diff --git a/cmd/metrics.go b/cmd/metrics.go index befde30a4..802800d16 100644 --- a/cmd/metrics.go +++ b/cmd/metrics.go @@ -34,11 +34,25 @@ var ( }, []string{"request_type"}, ) + minioVersionInfo = prometheus.NewGaugeVec( + prometheus.GaugeOpts{ + Namespace: "minio", + Name: "version_info", + Help: "Version of current MinIO server instance", + }, + []string{ + // current version + "version", + // commit-id of the current version + "commit", + }, + ) ) func init() { prometheus.MustRegister(httpRequestsDuration) prometheus.MustRegister(newMinioCollector()) + prometheus.MustRegister(minioVersionInfo) } // newMinioCollector describes the collector @@ -64,6 +78,9 @@ func (c *minioCollector) Describe(ch chan<- *prometheus.Desc) { // Collect is called by the Prometheus registry when collecting metrics. func (c *minioCollector) Collect(ch chan<- prometheus.Metric) { + // Expose MinIO's version information + minioVersionInfo.WithLabelValues(Version, CommitID).Add(1) + // Always expose network stats // Network Sent/Received Bytes @@ -184,7 +201,10 @@ func (c *minioCollector) Collect(ch chan<- prometheus.Metric) { func metricsHandler() http.Handler { registry := prometheus.NewRegistry() - err := registry.Register(httpRequestsDuration) + err := registry.Register(minioVersionInfo) + logger.LogIf(context.Background(), err) + + err = registry.Register(httpRequestsDuration) logger.LogIf(context.Background(), err) err = registry.Register(newMinioCollector())