From 4416fe013280188a3e4e1ffa133a244137a7fdfe Mon Sep 17 00:00:00 2001 From: Dmitriy Alekseev <1865999+dragoangel@users.noreply.github.com> Date: Mon, 26 Aug 2024 20:32:25 +0200 Subject: [PATCH] Remove dependency of having kube_pod_labels Only one query is requires kube_pod_labels - operator ready replicas. This metric by default on most of setups is not available. This PR implement: - other way to achieve same result without relying on turned-off by default metric - more targeted operatorNamespace selector which is limited by webhook that unique to CloudNative-PG Signed-off-by: Dmitriy Alekseev <1865999+dragoangel@users.noreply.github.com> --- charts/cluster/grafana-dashboard.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/charts/cluster/grafana-dashboard.json b/charts/cluster/grafana-dashboard.json index 3791d44..50722a6 100644 --- a/charts/cluster/grafana-dashboard.json +++ b/charts/cluster/grafana-dashboard.json @@ -2235,7 +2235,7 @@ "uid": "${DS_PROMETHEUS}" }, "editorMode": "code", - "expr": "sum by (label_app_kubernetes_io_name) (kube_pod_status_ready{namespace=\"$operatorNamespace\"} * on (pod) group_left( label_app_kubernetes_io_name ) kube_pod_labels{label_app_kubernetes_io_name=~\"cloudnative-pg\"})", + "expr": "count(\r\n sum(kube_pod_status_ready{namespace=\"$operatorNamespace\"} == 1)\r\n by (pod,namespace)\r\n * on (pod) group_left()\r\n count(controller_runtime_webhook_requests_total{namespace=\"$operatorNamespace\",webhook=\"/mutate-postgresql-cnpg-io-v1-cluster\"}) by (pod)\r\n) or vector(0)", "hide": false, "instant": false, "legendFormat": "Operator Status", @@ -7995,7 +7995,7 @@ }, "editorMode": "code", "exemplar": false, - "expr": "sum(kube_pod_status_ready{namespace=\"$operatorNamespace\"} * on (pod) group_left( label_app_kubernetes_io_name ) kube_pod_labels{label_app_kubernetes_io_name=~\"cloudnative-pg\"})", + "expr": "count(\r\n sum(kube_pod_status_ready{namespace=\"$operatorNamespace\"} == 1)\r\n by (pod,namespace)\r\n * on (pod) group_left()\r\n count(controller_runtime_webhook_requests_total{namespace=\"$operatorNamespace\",webhook=\"/mutate-postgresql-cnpg-io-v1-cluster\"}) by (pod)\r\n) or vector(0)", "hide": false, "instant": true, "legendFormat": "Ready Operator Pods", @@ -8516,7 +8516,7 @@ "uid": "${DS_PROMETHEUS}" }, "editorMode": "code", - "expr": "sum(kube_pod_status_ready{namespace=\"$operatorNamespace\"} * on (pod) group_left( label_app_kubernetes_io_name ) kube_pod_labels{label_app_kubernetes_io_name=~\"cloudnative-pg\"})", + "expr": "count(\r\n sum(kube_pod_status_ready{namespace=\"$operatorNamespace\"} == 1)\r\n by (pod,namespace)\r\n * on (pod) group_left()\r\n count(controller_runtime_webhook_requests_total{namespace=\"$operatorNamespace\",webhook=\"/mutate-postgresql-cnpg-io-v1-cluster\"}) by (pod)\r\n) or vector(0)", "hide": false, "instant": false, "legendFormat": "Ready Operator Pods", @@ -9079,7 +9079,7 @@ "type": "prometheus", "uid": "${DS_PROMETHEUS}" }, - "definition": "label_values(controller_runtime_active_workers,namespace)", + "definition": "label_values(controller_runtime_webhook_requests_total{webhook=\"/mutate-postgresql-cnpg-io-v1-cluster\"},namespace)", "description": "Namespace where the CNPG operator is located", "hide": 0, "includeAll": false, @@ -9089,7 +9089,7 @@ "options": [], "query": { "qryType": 1, - "query": "label_values(controller_runtime_active_workers,namespace)", + "query": "label_values(controller_runtime_webhook_requests_total{webhook=\"/mutate-postgresql-cnpg-io-v1-cluster\"},namespace)", "refId": "PrometheusVariableQueryEditor-VariableQuery" }, "refresh": 2,