kubernetes监控--Prometheus

时间:2025-05-13 07:25:27
  • {
  • "annotations": {
  • "list": []
  • },
  • "editable": true,
  • "gnetId": null,
  • "graphTooltip": 0,
  • "hideControls": false,
  • "id": 21,
  • "links": [],
  • "refresh": false,
  • "rows": [
  • {
  • "collapse": false,
  • "height": 282,
  • "panels": [
  • {
  • "aliasColors": {},
  • "bars": false,
  • "dashLength": 10,
  • "dashes": false,
  • "datasource": null,
  • "fill": 0,
  • "height": "",
  • "hideTimeOverride": false,
  • "id": 1,
  • "legend": {
  • "alignAsTable": true,
  • "avg": false,
  • "current": true,
  • "hideEmpty": false,
  • "hideZero": false,
  • "max": true,
  • "min": false,
  • "rightSide": true,
  • "show": true,
  • "sideWidth": null,
  • "total": false,
  • "values": true
  • },
  • "lines": true,
  • "linewidth": 2,
  • "links": [],
  • "minSpan": null,
  • "nullPointMode": "null",
  • "percentage": false,
  • "pointradius": 5,
  • "points": false,
  • "renderer": "flot",
  • "repeat": null,
  • "seriesOverrides": [],
  • "spaceLength": 10,
  • "span": 6,
  • "stack": false,
  • "steppedLine": false,
  • "targets": [
  • {
  • "expr": "sum(container_memory_usage_bytes{pod_name=\"$pod\", namespace=\"$namespace\"}) by (namespace,pod_name)",
  • "format": "time_series",
  • "interval": "30s",
  • "intervalFactor": 1,
  • "legendFormat": "total",
  • "refId": "B",
  • "step": 30
  • },
  • {
  • "expr": "sum(container_memory_rss{namespace=\"$namespace\",pod_name=\"$pod\"}) by (namespace,pod_name)",
  • "format": "time_series",
  • "hide": false,
  • "interval": "30s",
  • "intervalFactor": 1,
  • "legendFormat": "rss",
  • "metric": "",
  • "refId": "A",
  • "step": 30
  • },
  • {
  • "expr": "sum(container_memory_cache{namespace=\"$namespace\",pod_name=\"$pod\"}) by (namespace,pod_name)",
  • "format": "time_series",
  • "interval": "30s",
  • "intervalFactor": 1,
  • "legendFormat": "cache",
  • "refId": "D",
  • "step": 30
  • },
  • {
  • "expr": "sum(container_memory_swap{namespace=\"$namespace\",pod_name=\"$pod\"}) by (namespace,pod_name)",
  • "format": "time_series",
  • "interval": "30s",
  • "intervalFactor": 1,
  • "legendFormat": "swap",
  • "refId": "C",
  • "step": 30
  • },
  • {
  • "expr": "sum(container_memory_failures_total{namespace=\"$namespace\",pod_name=\"$pod\"}) by (namespace,pod_name)",
  • "format": "time_series",
  • "hide": true,
  • "intervalFactor": 2,
  • "legendFormat": "failures_total",
  • "refId": "E",
  • "step": 20
  • },
  • {
  • "expr": "sum(container_memory_failcnt{namespace=\"$namespace\",pod_name=\"$pod\"}) by (namespace,pod_name)",
  • "format": "time_series",
  • "hide": true,
  • "intervalFactor": 2,
  • "legendFormat": "failcnt",
  • "refId": "F",
  • "step": 20
  • },
  • {
  • "expr": "sum(container_memory_working_set_bytes{namespace=\"$namespace\",pod_name=\"$pod\"}) by (namespace,pod_name)",
  • "format": "time_series",
  • "hide": true,
  • "intervalFactor": 2,
  • "legendFormat": "working_set",
  • "refId": "G",
  • "step": 20
  • }
  • ],
  • "thresholds": [],
  • "timeFrom": null,
  • "timeShift": null,
  • "title": "内存使用量",
  • "tooltip": {
  • "shared": false,
  • "sort": 0,
  • "value_type": "individual"
  • },
  • "transparent": false,
  • "type": "graph",
  • "xaxis": {
  • "buckets": null,
  • "mode": "time",
  • "name": null,
  • "show": true,
  • "values": [
  • "total"
  • ]
  • },
  • "yaxes": [
  • {
  • "format": "bytes",
  • "label": null,
  • "logBase": 1,
  • "max": null,
  • "min": null,
  • "show": true
  • },
  • {
  • "format": "bytes",
  • "label": null,
  • "logBase": 1,
  • "max": null,
  • "min": null,
  • "show": true
  • }
  • ]
  • },
  • {
  • "aliasColors": {},
  • "bars": false,
  • "dashLength": 10,
  • "dashes": false,
  • "datasource": null,
  • "decimals": null,
  • "description": "获取CPU资源使用情况,判断方式现在时刻和一分钟前的数据进行对比。",
  • "fill": 0,
  • "id": 2,
  • "legend": {
  • "alignAsTable": true,
  • "avg": false,
  • "current": true,
  • "hideEmpty": false,
  • "hideZero": false,
  • "max": true,
  • "min": false,
  • "rightSide": true,
  • "show": true,
  • "sideWidth": null,
  • "total": false,
  • "values": true
  • },
  • "lines": true,
  • "linewidth": 2,
  • "links": [],
  • "minSpan": null,
  • "nullPointMode": "null",
  • "percentage": false,
  • "pointradius": 5,
  • "points": false,
  • "renderer": "flot",
  • "repeat": null,
  • "seriesOverrides": [],
  • "spaceLength": 10,
  • "span": 6,
  • "stack": true,
  • "steppedLine": false,
  • "targets": [
  • {
  • "expr": "sum(rate(container_cpu_system_seconds_total{namespace=\"$namespace\",pod_name=\"$pod\"}[1m])) by (namespace,pod_name)",
  • "format": "time_series",
  • "hide": false,
  • "interval": "30s",
  • "intervalFactor": 1,
  • "legendFormat": "system",
  • "metric": "",
  • "refId": "A",
  • "step": 30
  • },
  • {
  • "expr": "sum(rate(container_cpu_user_seconds_total{namespace=\"$namespace\",pod_name=\"$pod\"}[1m])) by (namespace,pod_name)",
  • "format": "time_series",
  • "interval": "30s",
  • "intervalFactor": 1,
  • "legendFormat": "user",
  • "refId": "C",
  • "step": 30
  • },
  • {
  • "expr": "sum(rate(container_cpu_usage_seconds_total{namespace=\"$namespace\",pod_name=\"$pod\"}[1m])) by (namespace,pod_name)",
  • "format": "time_series",
  • "interval": "30s",
  • "intervalFactor": 1,
  • "legendFormat": "total",
  • "refId": "B",
  • "step": 30
  • }
  • ],
  • "thresholds": [],
  • "timeFrom": null,
  • "timeShift": null,
  • "title": "CPU使用量(核)",
  • "tooltip": {
  • "shared": true,
  • "sort": 0,
  • "value_type": "individual"
  • },
  • "transparent": false,
  • "type": "graph",
  • "xaxis": {
  • "buckets": null,
  • "mode": "time",
  • "name": null,
  • "show": true,
  • "values": [
  • "total"
  • ]
  • },
  • "yaxes": [
  • {
  • "format": "short",
  • "label": "",
  • "logBase": 1,
  • "max": null,
  • "min": null,
  • "show": true
  • },
  • {
  • "format": "short",
  • "label": null,
  • "logBase": 1,
  • "max": null,
  • "min": null,
  • "show": true
  • }
  • ]
  • }
  • ],
  • "repeat": null,
  • "repeatIteration": null,
  • "repeatRowId": null,
  • "showTitle": false,
  • "title": "所有pod",
  • "titleSize": "h6"
  • },
  • {
  • "collapse": false,
  • "height": 199,
  • "panels": [
  • {
  • "aliasColors": {},
  • "bars": false,
  • "dashLength": 10,
  • "dashes": false,
  • "datasource": null,
  • "fill": 1,
  • "id": 6,
  • "legend": {
  • "alignAsTable": true,
  • "avg": false,
  • "current": false,
  • "max": false,
  • "min": false,
  • "rightSide": true,
  • "show": true,
  • "total": false,
  • "values": false
  • },
  • "lines": true,
  • "linewidth": 1,
  • "links": [],
  • "nullPointMode": "null",
  • "percentage": false,
  • "pointradius": 5,
  • "points": false,
  • "renderer": "flot",
  • "seriesOverrides": [],
  • "spaceLength": 10,
  • "span": 6,
  • "stack": false,
  • "steppedLine": false,
  • "targets": [
  • {
  • "expr": "sum(rate(container_network_receive_packets_total{namespace=\"$namespace\",pod_name=\"$pod\"}[1m])) by (namespace,pod_name)",
  • "format": "time_series",
  • "interval": "1m",
  • "intervalFactor": 2,
  • "legendFormat": "in",
  • "refId": "A",
  • "step": 120
  • },
  • {
  • "expr": "sum(rate(container_network_transmit_packets_total{namespace=\"$namespace\",pod_name=\"$pod\"}[1m])) by (namespace,pod_name)",
  • "format": "time_series",
  • "interval": "1m",
  • "intervalFactor": 2,
  • "legendFormat": "out",
  • "refId": "B",
  • "step": 120
  • },
  • {
  • "expr": "sum(rate(container_network_receive_errors_total{namespace=\"$namespace\",pod_name=\"$pod\"}[1m])) by (namespace,pod_name) + sum(rate(container_network_transmit_errors_total{namespace=\"$namespace\",pod_name=\"$pod\"}[1m])) by (namespace,pod_name) + sum(rate(container_network_receive_packets_dropped_total{namespace=\"$namespace\",pod_name=\"$pod\"}[1m])) by (namespace,pod_name) + sum(rate(container_network_transmit_packets_dropped_total{namespace=\"$namespace\",pod_name=\"$pod\"}[1m])) by (namespace,pod_name)",
  • "format": "time_series",
  • "interval": "1m",
  • "intervalFactor": 1,
  • "legendFormat": "error",
  • "refId": "C",
  • "step": 60
  • }
  • ],
  • "thresholds": [],
  • "timeFrom": null,
  • "timeShift": null,
  • "title": "数据包",
  • "tooltip": {
  • "shared": true,
  • "sort": 0,
  • "value_type": "individual"
  • },
  • "type": "graph",
  • "xaxis": {
  • "buckets": null,
  • "mode": "time",
  • "name": null,
  • "show": true,
  • "values": []
  • },
  • "yaxes": [
  • {
  • "format": "pps",
  • "label": null,
  • "logBase": 1,
  • "max": null,
  • "min": null,
  • "show": true
  • },
  • {
  • "format": "pps",
  • "label": null,
  • "logBase": 1,
  • "max": null,
  • "min": null,
  • "show": true
  • }
  • ]
  • },
  • {
  • "aliasColors": {},
  • "bars": false,
  • "dashLength": 10,
  • "dashes": false,
  • "datasource": null,
  • "fill": 0,
  • "id": 5,
  • "legend": {
  • "alignAsTable": true,
  • "avg": false,
  • "current": false,
  • "max": false,
  • "min": false,
  • "rightSide": true,
  • "show": true,
  • "total": false,
  • "values": false
  • },
  • "lines": true,
  • "linewidth": 2,
  • "links": [],
  • "nullPointMode": "null",
  • "percentage": false,
  • "pointradius": 5,
  • "points": false,
  • "renderer": "flot",
  • "seriesOverrides": [],
  • "spaceLength": 10,
  • "span": 6,
  • "stack": false,
  • "steppedLine": false,
  • "targets": [
  • {
  • "expr": "sum(rate(container_network_receive_bytes_total{pod_name=\"$pod\", namespace=\"$namespace\"}[1m])*1) by (namespace,container_name)",
  • "format": "time_series",
  • "interval": "1m",
  • "intervalFactor": 1,
  • "legendFormat": "in",
  • "metric": "",
  • "refId": "A",
  • "step": 60
  • },
  • {
  • "expr": "sum(rate(container_network_transmit_bytes_total{pod_name=\"$pod\", namespace=\"$namespace\"}[1m])*1) by (namespace,container_name)",
  • "format": "time_series",
  • "interval": "1m",
  • "intervalFactor": 1,
  • "legendFormat": "out",
  • "refId": "B",
  • "step": 60
  • }
  • ],
  • "thresholds": [],
  • "timeFrom": null,
  • "timeShift": null,
  • "title": "网络流量",
  • "tooltip": {
  • "shared": true,
  • "sort": 0,
  • "value_type": "individual"
  • },
  • "type": "graph",
  • "xaxis": {
  • "buckets": null,
  • "mode": "time",
  • "name": null,
  • "show": true,
  • "values": []
  • },
  • "yaxes": [
  • {
  • "format": "bps",
  • "label": null,
  • "logBase": 1,
  • "max": null,
  • "min": null,
  • "show": true
  • },
  • {
  • "format": "bps",
  • "label": null,
  • "logBase": 1,
  • "max": null,
  • "min": null,
  • "show": true
  • }
  • ]
  • }
  • ],
  • "repeat": null,
  • "repeatIteration": null,
  • "repeatRowId": null,
  • "showTitle": false,
  • "title": "Dashboard Row",
  • "titleSize": "h6"
  • },
  • {
  • "collapse": false,
  • "height": 163,
  • "panels": [
  • {
  • "aliasColors": {},
  • "bars": false,
  • "dashLength": 10,
  • "dashes": false,
  • "datasource": null,
  • "fill": 0,
  • "hideTimeOverride": false,
  • "id": 3,
  • "legend": {
  • "alignAsTable": true,
  • "avg": false,
  • "current": false,
  • "max": false,
  • "min": false,
  • "rightSide": true,
  • "show": true,
  • "sortDesc": true,
  • "total": false,
  • "values": false
  • },
  • "lines": true,
  • "linewidth": 2,
  • "links": [],
  • "nullPointMode": "null",
  • "percentage": false,
  • "pointradius": 5,
  • "points": false,
  • "renderer": "flot",
  • "repeat": null,
  • "seriesOverrides": [],
  • "spaceLength": 10,
  • "span": 6,
  • "stack": false,
  • "steppedLine": false,
  • "targets": [
  • {
  • "expr": "sum(container_fs_limit_bytes{namespace=\"$namespace\",pod_name=\"$pod\"}) by (namespace,pod_name)",
  • "format": "time_series",
  • "intervalFactor": 2,
  • "legendFormat": "total",
  • "refId": "A",
  • "step": 4
  • },
  • {
  • "expr": "sum(container_fs_usage_bytes{namespace=\"$namespace\",pod_name=\"$pod\"}) by (namespace,pod_name)",
  • "format": "time_series",
  • "intervalFactor": 2,
  • "legendFormat": "usage",
  • "refId": "B",
  • "step": 4
  • }
  • ],
  • "thresholds": [],
  • "timeFrom": null,
  • "timeShift": null,
  • "title": "硬盘使用量",
  • "tooltip": {
  • "shared": false,
  • "sort": 0,
  • "value_type": "individual"
  • },
  • "type": "graph",
  • "xaxis": {
  • "buckets": null,
  • "mode": "time",
  • "name": null,
  • "show": true,
  • "values": []
  • },
  • "yaxes": [
  • {
  • "format": "decbytes",
  • "label": null,
  • "logBase": 1,
  • "max": null,
  • "min": null,
  • "show": true
  • },
  • {
  • "format": "short",
  • "label": null,
  • "logBase": 1,
  • "max": null,
  • "min": null,
  • "show": true
  • }
  • ]
  • },
  • {
  • "aliasColors": {},
  • "bars": false,
  • "dashLength": 10,
  • "dashes": false,
  • "datasource": null,
  • "fill": 0,
  • "id": 4,
  • "legend": {
  • "alignAsTable": true,
  • "avg": false,
  • "current": false,
  • "max": false,
  • "min": false,
  • "rightSide": true,
  • "show": true,
  • "total": false,
  • "values": false
  • },
  • "lines": true,
  • "linewidth": 2,
  • "links": [],
  • "nullPointMode": "null",
  • "percentage": false,
  • "pointradius": 5,
  • "points": false,
  • "renderer": "flot",
  • "seriesOverrides": [],
  • "spaceLength": 10,
  • "span": 6,
  • "stack": false,
  • "steppedLine": false,
  • "targets": [
  • {
  • "expr": "sum(container_fs_reads_total{namespace=\"$namespace\",pod_name=\"$pod\"}) by (namespace,pod_name)",
  • "format": "time_series",
  • "interval": "30s",
  • "intervalFactor": 1,
  • "legendFormat": "read",
  • "refId": "A",
  • "step": 30
  • },
  • {
  • "expr": "sum(container_fs_writes_total{namespace=\"$namespace\",pod_name=\"$pod\"}) by (namespace,pod_name)",
  • "format": "time_series",
  • "interval": "30s",
  • "intervalFactor": 1,
  • "legendFormat": "write",
  • "refId": "B",
  • "step": 30
  • },
  • {
  • "expr": "sum(container_fs_io_current{namespace=\"$namespace\",pod_name=\"$pod\"}) by (namespace,pod_name)",
  • "format": "time_series",
  • "intervalFactor": 2,
  • "legendFormat": "current",
  • "refId": "C",
  • "step": 4
  • }
  • ],
  • "thresholds": [],
  • "timeFrom": null,
  • "timeShift": null,
  • "title": "IO",
  • "tooltip": {
  • "shared": true,
  • "sort": 0,
  • "value_type": "individual"
  • },
  • "type": "graph",
  • "xaxis": {
  • "buckets": null,
  • "mode": "time",
  • "name": null,
  • "show": true,
  • "values": []
  • },
  • "yaxes": [
  • {
  • "format": "short",
  • "label": null,
  • "logBase": 1,
  • "max": null,
  • "min": null,
  • "show": true
  • },
  • {
  • "format": "short",
  • "label": null,
  • "logBase": 1,
  • "max": null,
  • "min": null,
  • "show": true
  • }
  • ]
  • }
  • ],
  • "repeat": null,
  • "repeatIteration": null,
  • "repeatRowId": null,
  • "showTitle": false,
  • "title": "Dashboard Row",
  • "titleSize": "h6"
  • }
  • ],
  • "schemaVersion": 14,
  • "style": "dark",
  • "tags": [],
  • "templating": {
  • "list": [
  • {
  • "allValue": null,
  • "current": {
  • "selected": true,
  • "text": "monitoring",
  • "value": "monitoring"
  • },
  • "datasource": "prometheus",
  • "hide": 0,
  • "includeAll": false,
  • "label": "namespace",
  • "multi": false,
  • "name": "namespace",
  • "options": [],
  • "query": "label_values(kube_pod_info{namespace=~\".+\"},namespace)",
  • "refresh": 1,
  • "regex": "",
  • "sort": 0,
  • "tagValuesQuery": "",
  • "tags": [],
  • "tagsQuery": "",
  • "type": "query",
  • "useTags": false
  • },
  • {
  • "allValue": null,
  • "current": {
  • "selected": true,
  • "text": "kube-state-metrics-2802505745",
  • "value": "kube-state-metrics-2802505745"
  • },
  • "datasource": "prometheus",
  • "hide": 0,
  • "includeAll": false,
  • "label": "创建者",
  • "multi": false,
  • "name": "created_by_name",
  • "options": [],
  • "query": "label_values(kube_pod_info{created_by_name=~\".+\",namespace=\"$namespace\"} ,created_by_name)",
  • "refresh": 1,
  • "regex": "",
  • "sort": 0,
  • "tagValuesQuery": "",
  • "tags": [],
  • "tagsQuery": "",
  • "type": "query",
  • "useTags": false
  • },
  • {
  • "allValue": null,
  • "current": {
  • "selected": true,
  • "text": "kube-state-metrics-2802505745-k24zk",
  • "value": "kube-state-metrics-2802505745-k24zk"
  • },
  • "datasource": "prometheus",
  • "hide": 0,
  • "includeAll": false,
  • "label": "pod",
  • "multi": false,
  • "name": "pod",
  • "options": [],
  • "query": "label_values(kube_pod_info{created_by_name=\"$created_by_name\",namespace=\"$namespace\",pod=~\".+\"} ,pod)",
  • "refresh": 1,
  • "regex": "",
  • "sort": 0,
  • "tagValuesQuery": "",
  • "tags": [],
  • "tagsQuery": "",
  • "type": "query",
  • "useTags": false
  • }
  • ]
  • },
  • "time": {
  • "from": "now-30m",
  • "to": "now"
  • },
  • "timepicker": {
  • "refresh_intervals": [
  • "5s",
  • "10s",
  • "30s",
  • "1m",
  • "5m",
  • "15m",
  • "30m",
  • "1h",
  • "2h",
  • "1d"
  • ],
  • "time_options": [
  • "5m",
  • "15m",
  • "1h",
  • "6h",
  • "12h",
  • "24h",
  • "2d",
  • "7d",
  • "30d"
  • ]
  • },
  • "timezone": "",
  • "title": "基于资源对象对pod进行监控",
  • "version": 5
  • }