From d136a6c4cd1cd238b442bd7c8cea7c483795fd92 Mon Sep 17 00:00:00 2001 From: Alex Jones Date: Fri, 12 May 2023 11:55:59 +0100 Subject: [PATCH] Chore/metrics data (#94) * fix: bug in the name matching of results Signed-off-by: Alex Jones * chore: fixing bad metric data Signed-off-by: Alex Jones * chore: fixing bad metric data Signed-off-by: Alex Jones --------- Signed-off-by: Alex Jones --- controllers/k8sgpt_controller.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/controllers/k8sgpt_controller.go b/controllers/k8sgpt_controller.go index edb2f0cf..80250e20 100644 --- a/controllers/k8sgpt_controller.go +++ b/controllers/k8sgpt_controller.go @@ -216,6 +216,7 @@ func (r *K8sGPTReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctr if len(resultList.Items) > 0 { // If the result does not exist in the map we will delete it for _, result := range resultList.Items { + fmt.Printf("Checking if %s is still relevant\n", result.Name) if _, ok := rawResults[result.Name]; !ok { err = r.Delete(ctx, &result) if err != nil { @@ -223,7 +224,7 @@ func (r *K8sGPTReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctr return r.finishReconcile(err, false) } else { k8sgptNumberOfResultsByType.With(prometheus.Labels{ - "kind": result.Kind, + "kind": result.Spec.Kind, "name": result.Name, }).Dec() } @@ -246,7 +247,7 @@ func (r *K8sGPTReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctr return r.finishReconcile(err, false) } else { k8sgptNumberOfResultsByType.With(prometheus.Labels{ - "kind": result.Kind, + "kind": result.Spec.Kind, "name": result.Name, }).Inc() }