Grafana dashboard: Kubernetes Pod Resource Overview
Description: Kubernetes 集群节点Pod资源使用分配统计

November 8th 2021, 5:44 PM

Dashboard介绍Kubernetes集群环境中的Pod资源分配统计使用情况（CPU/MEM/DISK）

{
  "__inputs": [],
  "__requires": [
    {
      "type": "grafana",
      "id": "grafana",
      "name": "Grafana",
      "version": "7.5.11"
    },
    {
      "type": "datasource",
      "id": "prometheus",
      "name": "Prometheus",
      "version": "1.0.0"
    },
    {
      "type": "panel",
      "id": "table",
      "name": "Table",
      "version": ""
    },
    {
      "type": "panel",
      "id": "text",
      "name": "Text",
      "version": ""
    }
  ],
  "annotations": {
    "list": [
      {
        "builtIn": 1,
        "datasource": "-- Grafana --",
        "enable": true,
        "hide": true,
        "iconColor": "rgba(0, 211, 255, 1)",
        "name": "Annotations & Alerts",
        "type": "dashboard"
      }
    ]
  },
  "editable": true,
  "gnetId": 15207,
  "graphTooltip": 0,
  "id": null,
  "iteration": 1636364661401,
  "links": [],
  "panels": [
    {
      "datasource": null,
      "fieldConfig": {
        "defaults": {},
        "overrides": []
      },
      "gridPos": {
        "h": 1,
        "w": 24,
        "x": 0,
        "y": 0
      },
      "id": 10,
      "options": {
        "content": "# Title\n\nFor markdown syntax help: [commonmark.org/help](https://commonmark.org/help/)\n         ",
        "mode": "markdown"
      },
      "pluginVersion": "7.5.11",
      "targets": [
        {
          "queryType": "randomWalk",
          "refId": "A"
        }
      ],
      "timeFrom": null,
      "timeShift": null,
      "title": "[ $Node ]  资源分配统计",
      "type": "text"
    },
    {
      "datasource": "$DataSource",
      "description": "",
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "palette-classic"
          },
          "custom": {
            "align": "center",
            "displayMode": "color-text",
            "filterable": false
          },
          "mappings": [
            {
              "from": "",
              "id": 1,
              "text": "Kubernetes_node_capacity_memory_bytes",
              "to": "",
              "type": 1,
              "value": "kube_node_status_capacity_memory_bytes"
            },
            {
              "from": "",
              "id": 2,
              "text": "Kubernetes_node_allocatable_memory_bytes",
              "to": "",
              "type": 1,
              "value": "kube_node_status_allocatable_memory_bytes"
            },
            {
              "from": "",
              "id": 3,
              "text": "Kubernetes_pod_resource_requests_memory_bytes",
              "to": "",
              "type": 1,
              "value": "kube_pod_container_resource_requests_memory_bytes"
            },
            {
              "from": "",
              "id": 4,
              "text": "Kubernetes_pod_resource_limits_memory_bytes",
              "to": "",
              "type": 1,
              "value": "kube_pod_container_resource_limits_memory_bytes"
            }
          ],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              },
              {
                "color": "red",
                "value": 80
              }
            ]
          },
          "unit": "bytes"
        },
        "overrides": [
          {
            "matcher": {
              "id": "byName",
              "options": "Capacity CPU"
            },
            "properties": [
              {
                "id": "unit",
                "value": "none"
              }
            ]
          },
          {
            "matcher": {
              "id": "byName",
              "options": "Allocatable CPU"
            },
            "properties": [
              {
                "id": "unit",
                "value": "none"
              }
            ]
          },
          {
            "matcher": {
              "id": "byName",
              "options": "Requests CPU"
            },
            "properties": [
              {
                "id": "unit",
                "value": "none"
              }
            ]
          },
          {
            "matcher": {
              "id": "byName",
              "options": "Limits CPU"
            },
            "properties": [
              {
                "id": "unit",
                "value": "none"
              },
              {
                "id": "custom.displayMode",
                "value": "color-background"
              },
              {
                "id": "color",
                "value": {
                  "fixedColor": "rgba(35, 134, 162, 0.62)",
                  "mode": "fixed"
                }
              }
            ]
          },
          {
            "matcher": {
              "id": "byName",
              "options": "Limits MEM"
            },
            "properties": [
              {
                "id": "custom.displayMode",
                "value": "color-background"
              },
              {
                "id": "color",
                "value": {
                  "fixedColor": "rgba(35, 134, 162, 0.62)",
                  "mode": "fixed"
                }
              }
            ]
          }
        ]
      },
      "gridPos": {
        "h": 3,
        "w": 24,
        "x": 0,
        "y": 1
      },
      "id": 8,
      "links": [],
      "options": {
        "frameIndex": 2,
        "showHeader": true,
        "sortBy": []
      },
      "pluginVersion": "7.5.11",
      "targets": [
        {
          "expr": "sum(kube_node_status_capacity_cpu_cores{node=\"$Node\"})by(__name__,node)",
          "format": "table",
          "hide": false,
          "instant": true,
          "interval": "",
          "legendFormat": "file descriptior",
          "refId": "A"
        },
        {
          "expr": "sum(kube_node_status_allocatable_cpu_cores{node=~\"$Node\"})by(__name__,node)",
          "format": "table",
          "hide": false,
          "instant": true,
          "interval": "",
          "legendFormat": "file descriptior",
          "refId": "B"
        },
        {
          "expr": "sum(kube_pod_container_resource_requests_cpu_cores{node=~\"$Node\"})by(__name__,node)",
          "format": "table",
          "hide": false,
          "instant": true,
          "interval": "",
          "legendFormat": "file descriptior",
          "refId": "C"
        },
        {
          "expr": "sum(kube_pod_container_resource_limits_cpu_cores{node=~\"$Node\"})by(__name__,node)",
          "format": "table",
          "hide": false,
          "instant": true,
          "interval": "",
          "legendFormat": "file descriptior",
          "refId": "D"
        },
        {
          "expr": "sum(kube_node_status_capacity_memory_bytes{node=\"$Node\"})by(__name__,node)",
          "format": "table",
          "instant": true,
          "interval": "",
          "legendFormat": "",
          "refId": "E"
        },
        {
          "expr": "sum(kube_node_status_allocatable_memory_bytes{node=~\"$Node\"})by(__name__,node)",
          "format": "table",
          "instant": true,
          "interval": "",
          "legendFormat": "",
          "refId": "F"
        },
        {
          "expr": "sum(kube_pod_container_resource_requests_memory_bytes{node=~\"$Node\"})by(__name__,node)",
          "format": "table",
          "instant": true,
          "interval": "",
          "legendFormat": "",
          "refId": "G"
        },
        {
          "expr": "sum(kube_pod_container_resource_limits_memory_bytes{node=~\"$Node\"})by(__name__,node)",
          "format": "table",
          "instant": true,
          "interval": "",
          "legendFormat": "",
          "refId": "H"
        },
        {
          "expr": "sum(kube_pod_container_resource_requests{node=\"$Node\",resource=\"ephemeral_storage\"})",
          "format": "table",
          "instant": true,
          "interval": "",
          "legendFormat": "",
          "refId": "I"
        },
        {
          "expr": "node_filesystem_size_bytes{kubernetes_node=\"$Node\",mountpoint=\"/\"}",
          "format": "table",
          "instant": true,
          "interval": "",
          "legendFormat": "",
          "refId": "J"
        }
      ],
      "timeFrom": null,
      "timeShift": null,
      "transformations": [
        {
          "id": "merge",
          "options": {}
        },
        {
          "id": "filterFieldsByName",
          "options": {
            "include": {
              "names": [
                "Time",
                "Value #A",
                "Value #B",
                "Value #C",
                "Value #D",
                "Value #E",
                "Value #F",
                "Value #G",
                "Value #H",
                "Value #J",
                "Value #I"
              ]
            }
          }
        },
        {
          "id": "reduce",
          "options": {
            "includeTimeField": false,
            "mode": "reduceFields",
            "reducers": [
              "lastNotNull"
            ]
          }
        },
        {
          "id": "organize",
          "options": {
            "excludeByName": {},
            "indexByName": {},
            "renameByName": {
              "Value #A": "Capacity CPU",
              "Value #B": "Allocatable CPU",
              "Value #C": "Requests CPU",
              "Value #D": "Limits CPU",
              "Value #E": "Capacity MEM",
              "Value #F": "Allocatable MEM",
              "Value #G": "Requests MEM",
              "Value #H": "Limits MEM",
              "Value #I": "Requests FS",
              "Value #J": "Capacity FS"
            }
          }
        }
      ],
      "type": "table"
    },
    {
      "datasource": "$DataSource",
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "palette-classic"
          },
          "custom": {
            "align": null,
            "displayMode": "color-text",
            "filterable": false
          },
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              }
            ]
          }
        },
        "overrides": [
          {
            "matcher": {
              "id": "byName",
              "options": "Memory Requests"
            },
            "properties": [
              {
                "id": "unit",
                "value": "bytes"
              },
              {
                "id": "custom.displayMode",
                "value": "color-background"
              },
              {
                "id": "decimals",
                "value": 1
              }
            ]
          },
          {
            "matcher": {
              "id": "byName",
              "options": "Mmeory Limits"
            },
            "properties": [
              {
                "id": "unit",
                "value": "bytes"
              },
              {
                "id": "custom.displayMode",
                "value": "color-background"
              },
              {
                "id": "color",
                "value": {
                  "fixedColor": "rgba(35, 134, 162, 0.62)",
                  "mode": "fixed"
                }
              },
              {
                "id": "decimals",
                "value": 1
              }
            ]
          },
          {
            "matcher": {
              "id": "byName",
              "options": "EphemeralStorage Requests "
            },
            "properties": [
              {
                "id": "unit",
                "value": "bytes"
              },
              {
                "id": "custom.displayMode",
                "value": "color-background"
              },
              {
                "id": "decimals",
                "value": 1
              }
            ]
          },
          {
            "matcher": {
              "id": "byName",
              "options": "EphemeralStorage Limits"
            },
            "properties": [
              {
                "id": "unit",
                "value": "bytes"
              },
              {
                "id": "custom.displayMode",
                "value": "color-background"
              },
              {
                "id": "color",
                "value": {
                  "fixedColor": "rgba(35, 134, 162, 0.62)",
                  "mode": "fixed"
                }
              },
              {
                "id": "decimals",
                "value": 1
              }
            ]
          },
          {
            "matcher": {
              "id": "byName",
              "options": "CPU Requests"
            },
            "properties": [
              {
                "id": "custom.displayMode",
                "value": "color-background"
              }
            ]
          },
          {
            "matcher": {
              "id": "byName",
              "options": "CPU Limits"
            },
            "properties": [
              {
                "id": "custom.displayMode",
                "value": "color-background"
              },
              {
                "id": "color",
                "value": {
                  "fixedColor": "rgba(35, 134, 162, 0.62)",
                  "mode": "fixed"
                }
              },
              {
                "id": "custom.width",
                "value": null
              }
            ]
          }
        ]
      },
      "gridPos": {
        "h": 23,
        "w": 24,
        "x": 0,
        "y": 4
      },
      "id": 2,
      "options": {
        "frameIndex": 4,
        "showHeader": true,
        "sortBy": []
      },
      "pluginVersion": "7.5.11",
      "targets": [
        {
          "expr": "kube_pod_container_resource_requests{node=\"$Node\",resource=\"cpu\"}",
          "format": "table",
          "instant": true,
          "interval": "",
          "legendFormat": "",
          "refId": "A"
        },
        {
          "expr": "kube_pod_container_resource_limits{node=\"$Node\",resource=\"cpu\"}",
          "format": "table",
          "instant": true,
          "interval": "",
          "legendFormat": "",
          "refId": "B"
        },
        {
          "expr": "kube_pod_container_resource_requests{node=\"$Node\",resource=\"memory\"}",
          "format": "table",
          "instant": true,
          "interval": "",
          "legendFormat": "",
          "refId": "C"
        },
        {
          "expr": "kube_pod_container_resource_limits{node=\"$Node\",resource=\"memory\"}",
          "format": "table",
          "instant": true,
          "interval": "",
          "legendFormat": "",
          "refId": "D"
        },
        {
          "expr": "kube_pod_container_resource_requests{node=\"$Node\",resource=\"ephemeral_storage\"}",
          "format": "table",
          "instant": true,
          "interval": "",
          "legendFormat": "",
          "refId": "E"
        },
        {
          "expr": "kube_pod_container_resource_limits{node=\"$Node\",resource=\"ephemeral_storage\"}",
          "format": "table",
          "instant": true,
          "interval": "",
          "legendFormat": "",
          "refId": "F"
        },
        {
          "expr": "kube_node_status_allocatable_cpu_cores{node=\"$Node\"}",
          "format": "table",
          "hide": true,
          "instant": true,
          "interval": "",
          "legendFormat": "",
          "refId": "G"
        }
      ],
      "timeFrom": null,
      "timeShift": null,
      "transformations": [
        {
          "id": "filterFieldsByName",
          "options": {
            "include": {
              "names": [
                "container",
                "pod",
                "Value #A",
                "Value #B",
                "Value #C",
                "Value #D",
                "Value #E",
                "Value #F"
              ]
            }
          }
        },
        {
          "id": "merge",
          "options": {}
        },
        {
          "id": "organize",
          "options": {
            "excludeByName": {},
            "indexByName": {},
            "renameByName": {
              "Value #A": "CPU Requests",
              "Value #B": "CPU Limits",
              "Value #C": "Memory Requests",
              "Value #D": "Mmeory Limits",
              "Value #E": "EphemeralStorage Requests ",
              "Value #F": "EphemeralStorage Limits",
              "Value #G": "Node CPU  Allocatable",
              "container": "Container",
              "pod": "Pod"
            }
          }
        }
      ],
      "type": "table"
    }
  ],
  "schemaVersion": 27,
  "style": "dark",
  "tags": [],
  "templating": {
    "list": [
      {
        "current": {
          "selected": false,
          "text": "生产环境",
          "value": "生产环境"
        },
        "description": null,
        "error": null,
        "hide": 0,
        "includeAll": false,
        "label": null,
        "multi": false,
        "name": "DataSource",
        "options": [],
        "query": "prometheus",
        "queryValue": "",
        "refresh": 1,
        "regex": "/[^Prometheus]/",
        "skipUrlSync": false,
        "type": "datasource"
      },
      {
        "allValue": null,
        "current": {},
        "datasource": "$DataSource",
        "definition": "label_values(kubernetes_build_info,instance)",
        "description": null,
        "error": null,
        "hide": 0,
        "includeAll": false,
        "label": null,
        "multi": false,
        "name": "Node",
        "options": [],
        "query": {
          "query": "label_values(kubernetes_build_info,instance)",
          "refId": "生产环境-Node-Variable-Query"
        },
        "refresh": 1,
        "regex": "",
        "skipUrlSync": false,
        "sort": 0,
        "tagValuesQuery": "",
        "tags": [],
        "tagsQuery": "",
        "type": "query",
        "useTags": false
      }
    ]
  },
  "time": {
    "from": "now-5m",
    "to": "now"
  },
  "timepicker": {},
  "timezone": "",
  "title": "Kubernetes Pod Resource Overview",
  "uid": "WomrHeVnk",
  "version": 24,
  "description": "Kubernetes 集群节点Pod资源使用分配统计"
}