Skip to content

Commit

Permalink
Add ArgoCD version metric (argoproj#18852)
Browse files Browse the repository at this point in the history
Signed-off-by: Omer Aplatony <omerap12@gmail.com>
  • Loading branch information
omerap12 committed Jun 30, 2024
1 parent e6a0349 commit d171d05
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions server/metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promhttp"

"github.com/argoproj/argo-cd/v2/common"
"github.com/argoproj/argo-cd/v2/util/profile"
)

Expand All @@ -18,6 +19,7 @@ type MetricsServer struct {
redisRequestHistogram *prometheus.HistogramVec
extensionRequestCounter *prometheus.CounterVec
extensionRequestDuration *prometheus.HistogramVec
argoVersion *prometheus.GaugeVec
}

var (
Expand Down Expand Up @@ -51,6 +53,13 @@ var (
},
[]string{"extension"},
)
argoVersion = prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Name: "argocd_info",
Help: "ArgoCD version information",
},
[]string{"version"},
)
)

// NewMetricsServer returns a new prometheus server which collects api server metrics
Expand All @@ -61,12 +70,15 @@ func NewMetricsServer(host string, port int) *MetricsServer {
registry,
prometheus.DefaultGatherer,
}, promhttp.HandlerOpts{}))
argoVersion.WithLabelValues(common.GetVersion().Version).Set(1)

profile.RegisterProfiler(mux)

registry.MustRegister(redisRequestCounter)
registry.MustRegister(redisRequestHistogram)
registry.MustRegister(extensionRequestCounter)
registry.MustRegister(extensionRequestDuration)
registry.MustRegister(argoVersion)

return &MetricsServer{
Server: &http.Server{
Expand All @@ -77,6 +89,7 @@ func NewMetricsServer(host string, port int) *MetricsServer {
redisRequestHistogram: redisRequestHistogram,
extensionRequestCounter: extensionRequestCounter,
extensionRequestDuration: extensionRequestDuration,
argoVersion: argoVersion,
}
}

Expand Down

0 comments on commit d171d05

Please sign in to comment.