From 4e08b8dee6ce10bbaceed4fdfbc2704f35e73cc8 Mon Sep 17 00:00:00 2001 From: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com> Date: Wed, 29 Jan 2025 00:02:00 -0500 Subject: [PATCH] chore(metrics)!: remove deprecated metrics (#21697) Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com> --- controller/metrics/metrics.go | 43 ---------------------- controller/metrics/metrics_test.go | 24 ------------ docs/operator-manual/upgrading/2.14-3.0.md | 16 ++++++++ 3 files changed, 16 insertions(+), 67 deletions(-) diff --git a/controller/metrics/metrics.go b/controller/metrics/metrics.go index 0913763b271fd..cdbdefb6f49ad 100644 --- a/controller/metrics/metrics.go +++ b/controller/metrics/metrics.go @@ -49,8 +49,6 @@ type MetricsServer struct { const ( // MetricsPath is the endpoint to collect application metrics MetricsPath = "/metrics" - // EnvVarLegacyControllerMetrics is a env var to re-enable deprecated prometheus metrics - EnvVarLegacyControllerMetrics = "ARGOCD_LEGACY_CONTROLLER_METRICS" ) // Follow Prometheus naming practices @@ -68,28 +66,6 @@ var ( nil, ) - // Deprecated - descAppCreated = prometheus.NewDesc( - "argocd_app_created_time", - "Creation time in unix timestamp for an application.", - descAppDefaultLabels, - nil, - ) - // Deprecated: superseded by sync_status label in argocd_app_info - descAppSyncStatusCode = prometheus.NewDesc( - "argocd_app_sync_status", - "The application current sync status.", - append(descAppDefaultLabels, "sync_status"), - nil, - ) - // Deprecated: superseded by health_status label in argocd_app_info - descAppHealthStatus = prometheus.NewDesc( - "argocd_app_health_status", - "The application current health status.", - append(descAppDefaultLabels, "health_status"), - nil, - ) - syncCounter = prometheus.NewCounterVec( prometheus.CounterOpts{ Name: "argocd_app_sync_total", @@ -381,8 +357,6 @@ func (c *appCollector) Describe(ch chan<- *prometheus.Desc) { ch <- descAppConditions } ch <- descAppInfo - ch <- descAppSyncStatusCode - ch <- descAppHealthStatus } // Collect implements the prometheus.Collector interface @@ -456,21 +430,4 @@ func (c *appCollector) collectApps(ch chan<- prometheus.Metric, app *argoappv1.A addGauge(descAppConditions, float64(count), conditionType) } } - - // Deprecated controller metrics - if os.Getenv(EnvVarLegacyControllerMetrics) == "true" { - addGauge(descAppCreated, float64(app.CreationTimestamp.Unix())) - - addGauge(descAppSyncStatusCode, boolFloat64(syncStatus == argoappv1.SyncStatusCodeSynced), string(argoappv1.SyncStatusCodeSynced)) - addGauge(descAppSyncStatusCode, boolFloat64(syncStatus == argoappv1.SyncStatusCodeOutOfSync), string(argoappv1.SyncStatusCodeOutOfSync)) - addGauge(descAppSyncStatusCode, boolFloat64(syncStatus == argoappv1.SyncStatusCodeUnknown || syncStatus == ""), string(argoappv1.SyncStatusCodeUnknown)) - - healthStatus := app.Status.Health.Status - addGauge(descAppHealthStatus, boolFloat64(healthStatus == health.HealthStatusUnknown || healthStatus == ""), string(health.HealthStatusUnknown)) - addGauge(descAppHealthStatus, boolFloat64(healthStatus == health.HealthStatusProgressing), string(health.HealthStatusProgressing)) - addGauge(descAppHealthStatus, boolFloat64(healthStatus == health.HealthStatusSuspended), string(health.HealthStatusSuspended)) - addGauge(descAppHealthStatus, boolFloat64(healthStatus == health.HealthStatusHealthy), string(health.HealthStatusHealthy)) - addGauge(descAppHealthStatus, boolFloat64(healthStatus == health.HealthStatusDegraded), string(health.HealthStatusDegraded)) - addGauge(descAppHealthStatus, boolFloat64(healthStatus == health.HealthStatusMissing), string(health.HealthStatusMissing)) - } } diff --git a/controller/metrics/metrics_test.go b/controller/metrics/metrics_test.go index 41eac978c4111..f091ebfd3f0b0 100644 --- a/controller/metrics/metrics_test.go +++ b/controller/metrics/metrics_test.go @@ -399,30 +399,6 @@ argocd_app_condition{condition="ExcludedResourceWarning",name="my-app-4",namespa } } -func TestLegacyMetrics(t *testing.T) { - t.Setenv(EnvVarLegacyControllerMetrics, "true") - - expectedResponse := ` -# HELP argocd_app_created_time Creation time in unix timestamp for an application. -# TYPE argocd_app_created_time gauge -argocd_app_created_time{name="my-app",namespace="argocd",project="important-project"} -6.21355968e+10 -# HELP argocd_app_health_status The application current health status. -# TYPE argocd_app_health_status gauge -argocd_app_health_status{health_status="Degraded",name="my-app",namespace="argocd",project="important-project"} 0 -argocd_app_health_status{health_status="Healthy",name="my-app",namespace="argocd",project="important-project"} 1 -argocd_app_health_status{health_status="Missing",name="my-app",namespace="argocd",project="important-project"} 0 -argocd_app_health_status{health_status="Progressing",name="my-app",namespace="argocd",project="important-project"} 0 -argocd_app_health_status{health_status="Suspended",name="my-app",namespace="argocd",project="important-project"} 0 -argocd_app_health_status{health_status="Unknown",name="my-app",namespace="argocd",project="important-project"} 0 -# HELP argocd_app_sync_status The application current sync status. -# TYPE argocd_app_sync_status gauge -argocd_app_sync_status{name="my-app",namespace="argocd",project="important-project",sync_status="OutOfSync"} 0 -argocd_app_sync_status{name="my-app",namespace="argocd",project="important-project",sync_status="Synced"} 1 -argocd_app_sync_status{name="my-app",namespace="argocd",project="important-project",sync_status="Unknown"} 0 -` - testApp(t, []string{fakeApp}, expectedResponse) -} - func TestMetricsSyncCounter(t *testing.T) { cancel, appLister := newFakeLister() defer cancel() diff --git a/docs/operator-manual/upgrading/2.14-3.0.md b/docs/operator-manual/upgrading/2.14-3.0.md index 0c377228423fa..34a7b7ae032b1 100644 --- a/docs/operator-manual/upgrading/2.14-3.0.md +++ b/docs/operator-manual/upgrading/2.14-3.0.md @@ -23,6 +23,22 @@ to `false` in the Argo CD ConfigMap `argocd-cm`. Read the [RBAC documentation](../rbac.md#fine-grained-permissions-for-updatedelete-action) for more detailed inforamtion. +### Removal of `argocd_app_sync_status`, `argocd_app_health_status` and `argocd_app_created_time` Metrics + +The `argocd_app_sync_status`, `argocd_app_health_status` and `argocd_app_created_time`, deprecated and disabled by +default since 1.5.0, have been removed. The information previously provided by these metrics is now available as labels +on the `argocd_app_info` metric. + +#### Detection + +Starting with 1.5.0, these metrics are only available if `ARGOCD_LEGACY_CONTROLLER_METRICS` is explicitly set to `true`. +If it is not set to true, you can safely upgrade with no changes. + +#### Migration + +If you are using these metrics, you will need to update your monitoring dashboards and alerts to use the new metric and +labels before upgrading. + ## Other changes ### Using `cluster.inClusterEnabled: "false"`