diff --git a/controller/metrics/clustercollector.go b/controller/metrics/clustercollector.go index e61f433f35..2d52a111a9 100644 --- a/controller/metrics/clustercollector.go +++ b/controller/metrics/clustercollector.go @@ -43,7 +43,6 @@ var ( type ClusterInfo struct { Server string - Clustername string K8SVersion string ResourcesCount int APIsCount int @@ -88,7 +87,7 @@ func (c *clusterCollector) Collect(ch chan<- prometheus.Metric) { now := time.Now() for _, c := range c.info { defaultValues := []string{c.Server} - ch <- prometheus.MustNewConstMetric(descClusterInfo, prometheus.GaugeValue, 1, append(defaultValues, c.K8SVersion, c.Clustername)...) + ch <- prometheus.MustNewConstMetric(descClusterInfo, prometheus.GaugeValue, 1, append(defaultValues, c.K8SVersion)...) ch <- prometheus.MustNewConstMetric(descClusterCacheResources, prometheus.GaugeValue, float64(c.ResourcesCount), defaultValues...) ch <- prometheus.MustNewConstMetric(descClusterAPIs, prometheus.GaugeValue, float64(c.APIsCount), defaultValues...) cacheAgeSeconds := -1 @@ -98,4 +97,3 @@ func (c *clusterCollector) Collect(ch chan<- prometheus.Metric) { ch <- prometheus.MustNewConstMetric(descClusterCacheAgeSeconds, prometheus.GaugeValue, float64(cacheAgeSeconds), defaultValues...) } } - diff --git a/controller/metrics/metrics.go b/controller/metrics/metrics.go index c978fad8f5..67cad2f83c 100644 --- a/controller/metrics/metrics.go +++ b/controller/metrics/metrics.go @@ -43,7 +43,7 @@ var ( descAppInfo = prometheus.NewDesc( "argocd_app_info", "Information about application.", - append(descAppDefaultLabels, "repo", "dest_server", "dest_namespace", "sync_status", "health_status", "operation", "sync_automated", "sync_prune", "sync_selfheal"), + append(descAppDefaultLabels, "repo", "dest_server", "dest_namespace", "sync_status", "health_status", "operation"), nil, ) // DEPRECATED @@ -238,28 +238,6 @@ func boolFloat64(b bool) float64 { return 0 } -func getsync(app *argoappv1.Application) (automated string, prune string, selfheal string) { - automated = "false" - prune = "false" - selfheal = "false" - - if app.Spec.SyncPolicy == nil || app.Spec.SyncPolicy.Automated == nil { - return - } else { - automated = "true" - } - - if app.Spec.SyncPolicy.Automated.Prune { - prune = "true" - } - - if app.Spec.SyncPolicy.Automated.SelfHeal { - selfheal = "true" - } - - return -} - func collectApps(ch chan<- prometheus.Metric, app *argoappv1.Application) { addConstMetric := func(desc *prometheus.Desc, t prometheus.ValueType, v float64, lv ...string) { project := app.Spec.GetProject() @@ -270,7 +248,6 @@ func collectApps(ch chan<- prometheus.Metric, app *argoappv1.Application) { addConstMetric(desc, prometheus.GaugeValue, v, lv...) } - var sync_automated, sync_prune, sync_selfheal = getsync(app) var operation string if app.DeletionTimestamp != nil { operation = "delete" @@ -286,7 +263,7 @@ func collectApps(ch chan<- prometheus.Metric, app *argoappv1.Application) { healthStatus = argoappv1.HealthStatusUnknown } - addGauge(descAppInfo, 1, git.NormalizeGitURL(app.Spec.Source.RepoURL), app.Spec.Destination.Server, app.Spec.Destination.Namespace, string(syncStatus), healthStatus, operation, sync_automated, sync_prune, sync_selfheal) + addGauge(descAppInfo, 1, git.NormalizeGitURL(app.Spec.Source.RepoURL), app.Spec.Destination.Server, app.Spec.Destination.Namespace, string(syncStatus), healthStatus, operation) // Deprecated controller metrics if os.Getenv(EnvVarLegacyControllerMetrics) == "true" { @@ -304,4 +281,3 @@ func collectApps(ch chan<- prometheus.Metric, app *argoappv1.Application) { addGauge(descAppHealthStatus, boolFloat64(healthStatus == argoappv1.HealthStatusMissing), argoappv1.HealthStatusMissing) } } - diff --git a/controller/metrics/metrics_test.go b/controller/metrics/metrics_test.go index 85c11e6426..d673f638ca 100644 --- a/controller/metrics/metrics_test.go +++ b/controller/metrics/metrics_test.go @@ -36,10 +36,6 @@ spec: source: path: some/path repoURL: https://github.com/argoproj/argocd-example-apps.git - syncPolicy: - automated: - prune: true - selfHeal: true status: sync: status: Synced @@ -61,8 +57,6 @@ spec: source: path: some/path repoURL: https://github.com/argoproj/argocd-example-apps.git - syncPolicy: - automated: {} status: sync: status: Synced @@ -110,10 +104,6 @@ spec: source: path: some/path repoURL: https://github.com/argoproj/argocd-example-apps.git - syncPolicy: - automated: - prune: true - selfHeal: true status: sync: status: Synced @@ -178,9 +168,9 @@ func TestMetrics(t *testing.T) { expectedResponse: ` # HELP argocd_app_info Information about application. # TYPE argocd_app_info gauge -argocd_app_info{dest_namespace="dummy-namespace",dest_server="https://localhost:6443",health_status="Degraded",name="my-app-3",namespace="argocd",operation="delete",project="important-project",repo="https://github.com/argoproj/argocd-example-apps",sync_automated="false",sync_prune="false",sync_selfheal="false",sync_status="OutOfSync"} 1 -argocd_app_info{dest_namespace="dummy-namespace",dest_server="https://localhost:6443",health_status="Healthy",name="my-app",namespace="argocd",operation="",project="important-project",repo="https://github.com/argoproj/argocd-example-apps",sync_automated="true",sync_prune="true",sync_selfheal="true",sync_status="Synced"} 1 -argocd_app_info{dest_namespace="dummy-namespace",dest_server="https://localhost:6443",health_status="Healthy",name="my-app-2",namespace="argocd",operation="sync",project="important-project",repo="https://github.com/argoproj/argocd-example-apps",sync_automated="true",sync_prune="false",sync_selfheal="false",sync_status="Synced"} 1 +argocd_app_info{dest_namespace="dummy-namespace",dest_server="https://localhost:6443",health_status="Degraded",name="my-app-3",namespace="argocd",operation="delete",project="important-project",repo="https://github.com/argoproj/argocd-example-apps",sync_status="OutOfSync"} 1 +argocd_app_info{dest_namespace="dummy-namespace",dest_server="https://localhost:6443",health_status="Healthy",name="my-app",namespace="argocd",operation="",project="important-project",repo="https://github.com/argoproj/argocd-example-apps",sync_status="Synced"} 1 +argocd_app_info{dest_namespace="dummy-namespace",dest_server="https://localhost:6443",health_status="Healthy",name="my-app-2",namespace="argocd",operation="sync",project="important-project",repo="https://github.com/argoproj/argocd-example-apps",sync_status="Synced"} 1 `, }, { @@ -188,7 +178,7 @@ argocd_app_info{dest_namespace="dummy-namespace",dest_server="https://localhost: expectedResponse: ` # HELP argocd_app_info Information about application. # TYPE argocd_app_info gauge -argocd_app_info{dest_namespace="dummy-namespace",dest_server="https://localhost:6443",health_status="Healthy",name="my-app",namespace="argocd",operation="",project="default",repo="https://github.com/argoproj/argocd-example-apps",sync_automated="true",sync_prune="true",sync_selfheal="true",sync_status="Synced"} 1 +argocd_app_info{dest_namespace="dummy-namespace",dest_server="https://localhost:6443",health_status="Healthy",name="my-app",namespace="argocd",operation="",project="default",repo="https://github.com/argoproj/argocd-example-apps",sync_status="Synced"} 1 `, }, } @@ -293,4 +283,3 @@ argocd_app_reconcile_count{dest_server="https://localhost:6443",namespace="argoc log.Println(body) assertMetricsPrinted(t, appReconcileMetrics, body) } -