From 816d45126a7a2c5d4bcae5e3c0e7d9442b6d6150 Mon Sep 17 00:00:00 2001 From: hoangphuocbk Date: Fri, 15 Nov 2024 01:30:02 +0700 Subject: [PATCH] support multiple cluster grafana dashboard --- .../grafana/ephemeral-storage-namespaces.json | 56 +++++++++++++++--- .../grafana/ephemeral-storage-nodes.json | 58 +++++++++++++++---- 2 files changed, 95 insertions(+), 19 deletions(-) diff --git a/dashboards/grafana/ephemeral-storage-namespaces.json b/dashboards/grafana/ephemeral-storage-namespaces.json index b229ee3..fc4bc92 100644 --- a/dashboards/grafana/ephemeral-storage-namespaces.json +++ b/dashboards/grafana/ephemeral-storage-namespaces.json @@ -1,4 +1,14 @@ { + "__inputs": [ + { + "name": "DS_PROMETHEUS", + "label": "Prometheus", + "description": "", + "type": "datasource", + "pluginId": "prometheus", + "pluginName": "Prometheus" + } + ], "annotations": { "list": [ { @@ -24,7 +34,7 @@ { "datasource": { "type": "prometheus", - "uid": "prometheus" + "uid": "${datasource}" }, "description": "Current ephemeral byte usage of a pod", "fieldConfig": { @@ -105,10 +115,10 @@ { "datasource": { "type": "prometheus", - "uid": "prometheus" + "uid": "${datasource}" }, "editorMode": "code", - "expr": "sum(ephemeral_storage_pod_usage{pod_namespace=~\"${namespace}\"})", + "expr": "sum(ephemeral_storage_pod_usage{cluster=~\"$cluster\", pod_namespace=~\"${namespace}\"})", "format": "time_series", "hide": false, "instant": false, @@ -124,7 +134,7 @@ { "datasource": { "type": "prometheus", - "uid": "prometheus" + "uid": "${datasource}" }, "description": "Current ephemeral byte usage of a pod", "fieldConfig": { @@ -205,10 +215,10 @@ { "datasource": { "type": "prometheus", - "uid": "prometheus" + "uid": "${datasource}" }, "editorMode": "code", - "expr": "ephemeral_storage_pod_usage{pod_namespace=~\"${namespace}\"}", + "expr": "ephemeral_storage_pod_usage{cluster=~\"$cluster\", pod_namespace=~\"${namespace}\"}", "format": "time_series", "hide": false, "instant": false, @@ -245,6 +255,34 @@ "skipUrlSync": false, "type": "datasource" }, + { + "current": { + "isNone": true, + "selected": false, + "text": "None", + "value": "" + }, + "datasource": { + "type": "prometheus", + "uid": "${datasource}" + }, + "definition": "label_values(ephemeral_storage_container_volume_usage,cluster)", + "hide": 0, + "includeAll": false, + "multi": false, + "name": "cluster", + "options": [], + "query": { + "qryType": 1, + "query": "label_values(ephemeral_storage_container_volume_usage,cluster)", + "refId": "PrometheusVariableQueryEditor-VariableQuery" + }, + "refresh": 1, + "regex": "", + "skipUrlSync": false, + "sort": 1, + "type": "query" + }, { "current": { "selected": true, @@ -255,7 +293,7 @@ "type": "prometheus", "uid": "${datasource}" }, - "definition": "label_values(ephemeral_storage_container_volume_usage,pod_namespace)", + "definition": "label_values(ephemeral_storage_container_volume_usage{cluster=~\"$cluster\"},pod_namespace)", "hide": 0, "includeAll": false, "label": "Namespace", @@ -264,7 +302,7 @@ "options": [], "query": { "qryType": 1, - "query": "label_values(ephemeral_storage_container_volume_usage,pod_namespace)", + "query": "label_values(ephemeral_storage_container_volume_usage{cluster=~\"$cluster\"},pod_namespace)", "refId": "PrometheusVariableQueryEditor-VariableQuery" }, "refresh": 2, @@ -280,7 +318,7 @@ "to": "now" }, "timepicker": {}, - "timezone": "utc", + "timezone": "", "title": "Kubernetes / Ephemeral Storage Namespaces", "version": 1, "weekStart": "" diff --git a/dashboards/grafana/ephemeral-storage-nodes.json b/dashboards/grafana/ephemeral-storage-nodes.json index 7c4da77..638a8e4 100644 --- a/dashboards/grafana/ephemeral-storage-nodes.json +++ b/dashboards/grafana/ephemeral-storage-nodes.json @@ -1,4 +1,14 @@ { + "__inputs": [ + { + "name": "DS_PROMETHEUS", + "label": "Prometheus", + "description": "", + "type": "datasource", + "pluginId": "prometheus", + "pluginName": "Prometheus" + } + ], "annotations": { "list": [ { @@ -24,7 +34,7 @@ { "datasource": { "type": "prometheus", - "uid": "prometheus" + "uid": "${datasource}" }, "description": "Storage usage in bytes by namespaces on the Kubernetes cluster", "fieldConfig": { @@ -105,7 +115,7 @@ { "datasource": { "type": "prometheus", - "uid": "prometheus" + "uid": "${datasource}" }, "editorMode": "code", "expr": "sum by (pod_namespace) (ephemeral_storage_pod_usage{node_name=~\"${node}\"})", @@ -124,7 +134,7 @@ { "datasource": { "type": "prometheus", - "uid": "prometheus" + "uid": "${datasource}" }, "description": "Total capacity of the ephemeral storage for nodes with their usage bytes", "fieldConfig": { @@ -205,7 +215,7 @@ { "datasource": { "type": "prometheus", - "uid": "prometheus" + "uid": "${datasource}" }, "editorMode": "code", "expr": "ephemeral_storage_node_capacity{node_name=~\"${node}\"}", @@ -220,7 +230,7 @@ { "datasource": { "type": "prometheus", - "uid": "prometheus" + "uid": "${datasource}" }, "editorMode": "code", "expr": "ephemeral_storage_node_capacity{node_name=~\"${node}\"} - ephemeral_storage_node_available{node_name=~\"${node}\"}", @@ -239,7 +249,7 @@ { "datasource": { "type": "prometheus", - "uid": "prometheus" + "uid": "${datasource}" }, "description": "Percentage of ephemeral storage used on nodes", "fieldConfig": { @@ -320,7 +330,7 @@ { "datasource": { "type": "prometheus", - "uid": "prometheus" + "uid": "${datasource}" }, "editorMode": "code", "expr": "ephemeral_storage_node_percentage{node_name=~\"${node}\"}\r\n", @@ -360,6 +370,34 @@ "skipUrlSync": false, "type": "datasource" }, + { + "current": { + "isNone": true, + "selected": false, + "text": "None", + "value": "" + }, + "datasource": { + "type": "prometheus", + "uid": "${datasource}" + }, + "definition": "label_values(ephemeral_storage_node_capacity,cluster)", + "hide": 0, + "includeAll": false, + "multi": false, + "name": "cluster", + "options": [], + "query": { + "qryType": 1, + "query": "label_values(ephemeral_storage_node_capacity,cluster)", + "refId": "PrometheusVariableQueryEditor-VariableQuery" + }, + "refresh": 1, + "regex": "", + "skipUrlSync": false, + "sort": 1, + "type": "query" + }, { "allValue": ".*", "current": { @@ -383,7 +421,7 @@ "type": "prometheus", "uid": "${datasource}" }, - "definition": "label_values(ephemeral_storage_node_capacity,node_name)", + "definition": "label_values(ephemeral_storage_node_capacity{cluster=~\"$cluster\"},node_name)", "hide": 0, "includeAll": false, "label": "node", @@ -392,7 +430,7 @@ "options": [], "query": { "qryType": 1, - "query": "label_values(ephemeral_storage_node_capacity,node_name)", + "query": "label_values(ephemeral_storage_node_capacity{cluster=~\"$cluster\"},node_name)", "refId": "PrometheusVariableQueryEditor-VariableQuery" }, "refresh": 2, @@ -408,7 +446,7 @@ "to": "now" }, "timepicker": {}, - "timezone": "utc", + "timezone": "", "title": "Kubernetes / Ephemeral Storage Nodes", "version": 1, "weekStart": ""