Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: added Argo version info in /metrics endpoint #1662

Merged
merged 2 commits into from
Nov 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions controller/metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ func NewMetricsServer(cfg ServerConfig, isPrimary bool) *MetricsServer {
reg.MustRegister(MetricExperimentReconcileError)
reg.MustRegister(MetricAnalysisRunReconcile)
reg.MustRegister(MetricAnalysisRunReconcileError)
reg.MustRegister(MetricVersionGauge)

mux.Handle(MetricsPath, promhttp.HandlerFor(prometheus.Gatherers{
// contains app controller specific metrics
Expand Down
7 changes: 7 additions & 0 deletions controller/metrics/metrics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,13 @@ rollout_reconcile_error{name="name",namespace="ns"} 1`
testHttpResponse(t, metricsServ.Handler, expectedResponse)
}

func TestVersionInfo(t *testing.T) {
expectedResponse := `# HELP argo_rollouts_controller_info Running Argo-rollouts version
# TYPE argo_rollouts_controller_info gauge`
metricsServ := NewMetricsServer(newFakeServerConfig(), true)
testHttpResponse(t, metricsServ.Handler, expectedResponse)
}

func TestSecondaryMetricsServer(t *testing.T) {
expectedResponse := ``

Expand Down
19 changes: 18 additions & 1 deletion controller/metrics/prommetrics.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package metrics

import "github.com/prometheus/client_golang/prometheus"
import (
"github.com/argoproj/argo-rollouts/utils/version"
"github.com/prometheus/client_golang/prometheus"
)

// Follow Prometheus naming practices
// https://prometheus.io/docs/practices/naming/
Expand Down Expand Up @@ -184,3 +187,17 @@ var (
[]string{"kind", "namespace", "name", "verb", "status_code"},
)
)

// MetricVersionGauge version info
var (
MetricVersionGauge = prometheus.NewGaugeFunc(
prometheus.GaugeOpts{
Name: "argo_rollouts_controller_info",
Help: "Running Argo-rollouts version",
ConstLabels: prometheus.Labels{"version": version.GetVersion().Version},
},
func() float64 {
return float64(1)
},
)
)