From 3344b1e5301f1a2f5daa1c040400bf6f120e3640 Mon Sep 17 00:00:00 2001 From: Haitao Pan Date: Sun, 21 Dec 2025 19:09:46 +0800 Subject: [PATCH] feat(ansible): extract playbooks and roles into standalone repository --- common_setup.yml | 6 + k3s-cluster.yaml | 6 + .../K8S-Dashboard-2025-01015.json | 6734 +++++++++++++++++ .../Node-Exporter-Dashboard-202501015.json | 5890 ++++++++++++++ roles/vhosts/common/defaults/main.yml | 18 + roles/vhosts/common/files/install-packages.sh | 5 + roles/vhosts/common/files/secure_ssh.sh | 11 + roles/vhosts/common/handlers/main.yml | 10 + .../common/tasks/configure_journald.yml | 7 + .../common/tasks/configure_logrotate.yaml | 7 + .../common/tasks/disable-systemd-resolved.yml | 27 + roles/vhosts/common/tasks/include_gpu.yaml | 17 + roles/vhosts/common/tasks/main.yml | 38 + roles/vhosts/common/tasks/set_hostname.yaml | 12 + roles/vhosts/common/tasks/set_timezone.yaml | 2 + roles/vhosts/common/tasks/setup-privoxy.yml | 24 + .../common/tasks/setup-systemd-resolved.yml | 36 + roles/vhosts/common/templates/authorized_keys | 3 + roles/vhosts/common/templates/hostname | 1 + roles/vhosts/common/templates/hosts | 26 + .../common/templates/journald_logrotate.j2 | 5 + .../common/templates/logrotate-monitor-agent | 8 + .../common/templates/rsyslog_logrotate.j2 | 23 + .../vhosts/k3s-cluster/files/set-registry.sh | 300 + roles/vhosts/k3s-cluster/files/setup_k3s.sh | 37 + roles/vhosts/k3s-cluster/tasks/main.yml | 44 + .../vpn-overlay/setup-dnat/defaults/main.yml | 6 + .../vpn-overlay/setup-dnat/tasks/main.yml | 40 + .../templates/dnat-rules.service.j2 | 12 + .../setup-dnat/templates/setup-dnat.sh.j2 | 26 + .../vpn-overlay/vxlan/hub/defaults/main.yml | 7 + .../vxlan/hub/files/setup_sit_vxlan.sh | 83 + .../vpn-overlay/vxlan/hub/tasks/main.yml | 50 + .../hub/templates/vxlan-setup.service.j2 | 12 + .../vpn-overlay/vxlan/site/defaults/main.yml | 7 + .../vxlan/site/files/setup_sit_vxlan.sh | 104 + .../vpn-overlay/vxlan/site/tasks/main.yml | 54 + .../vxlan/site/templates/vxlan-config.yaml.j2 | 12 + .../site/templates/vxlan-setup.service.j2 | 12 + .../wireguard/hub/defaults/main.yml | 4 + .../vpn-overlay/wireguard/hub/tasks/main.yml | 56 + .../wireguard/hub/templates/wg0.conf.j2 | 16 + .../wireguard/site/defaults/main.yml | 8 + .../vpn-overlay/wireguard/site/tasks/main.yml | 71 + .../wireguard/site/templates/wg0.conf.j2 | 24 + .../vpn-overlay/xray/hub/defaults/main.yml | 5 + .../vpn-overlay/xray/hub/handlers/main.yml | 6 + .../vpn-overlay/xray/hub/tasks/main.yml | 70 + .../xray/hub/templates/config.json.j2 | 84 + .../xray/hub/templates/xray.service.j2 | 18 + .../vpn-overlay/xray/site/defaults/main.yml | 6 + .../vpn-overlay/xray/site/handlers/main.yml | 6 + .../vpn-overlay/xray/site/tasks/main.yml | 70 + .../xray/site/templates/client-config.json.j2 | 94 + .../site/templates/xray-client.service.j2 | 18 + .../vpn-overlay/xray/tproxy/defaults/main.yml | 6 + .../vpn-overlay/xray/tproxy/handlers/main.yml | 6 + .../vpn-overlay/xray/tproxy/tasks/main.yml | 82 + .../tproxy/templates/tproxy-config.json.j2 | 58 + .../tproxy/templates/xray-tproxy.service.j2 | 18 + vpn-overlay-dnat.yaml | 8 + vpn-overlay-vxlan-hub.yaml | 8 + vpn-overlay-vxlan-site.yaml | 8 + vpn-wireguard-hub.yaml | 8 + vpn-wireguard-site.yaml | 8 + vpn-xray-client.yaml | 8 + vpn-xray-hub.yaml | 8 + vpn-xray-tproxy.yaml | 8 + 68 files changed, 14512 insertions(+) create mode 100644 common_setup.yml create mode 100644 k3s-cluster.yaml create mode 100644 roles/grafana-dashboard/K8S-Dashboard-2025-01015.json create mode 100644 roles/grafana-dashboard/Node-Exporter-Dashboard-202501015.json create mode 100644 roles/vhosts/common/defaults/main.yml create mode 100644 roles/vhosts/common/files/install-packages.sh create mode 100644 roles/vhosts/common/files/secure_ssh.sh create mode 100644 roles/vhosts/common/handlers/main.yml create mode 100644 roles/vhosts/common/tasks/configure_journald.yml create mode 100644 roles/vhosts/common/tasks/configure_logrotate.yaml create mode 100644 roles/vhosts/common/tasks/disable-systemd-resolved.yml create mode 100644 roles/vhosts/common/tasks/include_gpu.yaml create mode 100644 roles/vhosts/common/tasks/main.yml create mode 100644 roles/vhosts/common/tasks/set_hostname.yaml create mode 100644 roles/vhosts/common/tasks/set_timezone.yaml create mode 100644 roles/vhosts/common/tasks/setup-privoxy.yml create mode 100644 roles/vhosts/common/tasks/setup-systemd-resolved.yml create mode 100755 roles/vhosts/common/templates/authorized_keys create mode 100755 roles/vhosts/common/templates/hostname create mode 100644 roles/vhosts/common/templates/hosts create mode 100644 roles/vhosts/common/templates/journald_logrotate.j2 create mode 100644 roles/vhosts/common/templates/logrotate-monitor-agent create mode 100644 roles/vhosts/common/templates/rsyslog_logrotate.j2 create mode 100644 roles/vhosts/k3s-cluster/files/set-registry.sh create mode 100644 roles/vhosts/k3s-cluster/files/setup_k3s.sh create mode 100644 roles/vhosts/k3s-cluster/tasks/main.yml create mode 100644 roles/vhosts/vpn-overlay/setup-dnat/defaults/main.yml create mode 100644 roles/vhosts/vpn-overlay/setup-dnat/tasks/main.yml create mode 100644 roles/vhosts/vpn-overlay/setup-dnat/templates/dnat-rules.service.j2 create mode 100644 roles/vhosts/vpn-overlay/setup-dnat/templates/setup-dnat.sh.j2 create mode 100644 roles/vhosts/vpn-overlay/vxlan/hub/defaults/main.yml create mode 100644 roles/vhosts/vpn-overlay/vxlan/hub/files/setup_sit_vxlan.sh create mode 100644 roles/vhosts/vpn-overlay/vxlan/hub/tasks/main.yml create mode 100644 roles/vhosts/vpn-overlay/vxlan/hub/templates/vxlan-setup.service.j2 create mode 100644 roles/vhosts/vpn-overlay/vxlan/site/defaults/main.yml create mode 100644 roles/vhosts/vpn-overlay/vxlan/site/files/setup_sit_vxlan.sh create mode 100644 roles/vhosts/vpn-overlay/vxlan/site/tasks/main.yml create mode 100644 roles/vhosts/vpn-overlay/vxlan/site/templates/vxlan-config.yaml.j2 create mode 100644 roles/vhosts/vpn-overlay/vxlan/site/templates/vxlan-setup.service.j2 create mode 100644 roles/vhosts/vpn-overlay/wireguard/hub/defaults/main.yml create mode 100644 roles/vhosts/vpn-overlay/wireguard/hub/tasks/main.yml create mode 100644 roles/vhosts/vpn-overlay/wireguard/hub/templates/wg0.conf.j2 create mode 100644 roles/vhosts/vpn-overlay/wireguard/site/defaults/main.yml create mode 100644 roles/vhosts/vpn-overlay/wireguard/site/tasks/main.yml create mode 100644 roles/vhosts/vpn-overlay/wireguard/site/templates/wg0.conf.j2 create mode 100644 roles/vhosts/vpn-overlay/xray/hub/defaults/main.yml create mode 100644 roles/vhosts/vpn-overlay/xray/hub/handlers/main.yml create mode 100644 roles/vhosts/vpn-overlay/xray/hub/tasks/main.yml create mode 100644 roles/vhosts/vpn-overlay/xray/hub/templates/config.json.j2 create mode 100644 roles/vhosts/vpn-overlay/xray/hub/templates/xray.service.j2 create mode 100644 roles/vhosts/vpn-overlay/xray/site/defaults/main.yml create mode 100644 roles/vhosts/vpn-overlay/xray/site/handlers/main.yml create mode 100644 roles/vhosts/vpn-overlay/xray/site/tasks/main.yml create mode 100644 roles/vhosts/vpn-overlay/xray/site/templates/client-config.json.j2 create mode 100644 roles/vhosts/vpn-overlay/xray/site/templates/xray-client.service.j2 create mode 100644 roles/vhosts/vpn-overlay/xray/tproxy/defaults/main.yml create mode 100644 roles/vhosts/vpn-overlay/xray/tproxy/handlers/main.yml create mode 100644 roles/vhosts/vpn-overlay/xray/tproxy/tasks/main.yml create mode 100644 roles/vhosts/vpn-overlay/xray/tproxy/templates/tproxy-config.json.j2 create mode 100644 roles/vhosts/vpn-overlay/xray/tproxy/templates/xray-tproxy.service.j2 create mode 100644 vpn-overlay-dnat.yaml create mode 100644 vpn-overlay-vxlan-hub.yaml create mode 100644 vpn-overlay-vxlan-site.yaml create mode 100644 vpn-wireguard-hub.yaml create mode 100644 vpn-wireguard-site.yaml create mode 100644 vpn-xray-client.yaml create mode 100644 vpn-xray-hub.yaml create mode 100644 vpn-xray-tproxy.yaml diff --git a/common_setup.yml b/common_setup.yml new file mode 100644 index 0000000..932d513 --- /dev/null +++ b/common_setup.yml @@ -0,0 +1,6 @@ +- name: Run infrastructure setup + hosts: all + become: yes + gather_facts: yes + roles: + - vhosts/common diff --git a/k3s-cluster.yaml b/k3s-cluster.yaml new file mode 100644 index 0000000..de2c606 --- /dev/null +++ b/k3s-cluster.yaml @@ -0,0 +1,6 @@ +- name: Run K3S-cluster setup + hosts: all + become: yes + gather_facts: yes + roles: + - roles/vhosts/k3s-cluster diff --git a/roles/grafana-dashboard/K8S-Dashboard-2025-01015.json b/roles/grafana-dashboard/K8S-Dashboard-2025-01015.json new file mode 100644 index 0000000..d00c5e1 --- /dev/null +++ b/roles/grafana-dashboard/K8S-Dashboard-2025-01015.json @@ -0,0 +1,6734 @@ +{ + "__inputs": [ + { + "name": "DS_指标", + "label": "指标", + "description": "", + "type": "datasource", + "pluginId": "prometheus", + "pluginName": "Prometheus" + } + ], + "__elements": {}, + "__requires": [ + { + "type": "panel", + "id": "bargauge", + "name": "Bar gauge", + "version": "" + }, + { + "type": "grafana", + "id": "grafana", + "name": "Grafana", + "version": "11.5.0-80683" + }, + { + "type": "datasource", + "id": "prometheus", + "name": "Prometheus", + "version": "1.0.0" + }, + { + "type": "panel", + "id": "stat", + "name": "Stat", + "version": "" + }, + { + "type": "panel", + "id": "table", + "name": "Table", + "version": "" + }, + { + "type": "panel", + "id": "timeseries", + "name": "Time series", + "version": "" + } + ], + "annotations": { + "list": [ + { + "$$hashKey": "object:247", + "builtIn": 1, + "datasource": { + "type": "datasource", + "uid": "grafana" + }, + "enable": true, + "hide": true, + "iconColor": "rgba(0, 211, 255, 1)", + "name": "Annotations & Alerts", + "target": { + "limit": 100, + "matchAny": false, + "tags": [], + "type": "dashboard" + }, + "type": "dashboard" + } + ] + }, + "description": "【中文版本】2024.05.13更新,kubernetes资源全面展示!包含K8S整体资源总览、微服务资源明细、Pod资源明细及K8S网络带宽,优化重要指标展示。https://grafana.com/orgs/starsliao/dashboards", + "editable": true, + "fiscalYearStartMonth": 0, + "graphTooltip": 0, + "id": null, + "links": [ + { + "icon": "bolt", + "tags": [], + "targetBlank": true, + "title": "Update", + "tooltip": "查看更多仪表板", + "type": "link", + "url": "https://grafana.com/orgs/starsliao/dashboards" + }, + { + "$$hashKey": "object:831", + "icon": "question", + "tags": [ + "node_exporter" + ], + "targetBlank": true, + "title": "GitHub", + "tooltip": "查看更多仪表板", + "type": "link", + "url": "https://github.com/starsliao" + } + ], + "panels": [ + { + "collapsed": false, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 0 + }, + "id": 54, + "panels": [], + "title": "节点资源总览:所选节点:【$Node】", + "type": "row" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "fieldConfig": { + "defaults": { + "decimals": 1, + "mappings": [], + "max": 1, + "min": 0, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "orange", + "value": 0.8 + }, + { + "color": "red", + "value": 0.9 + } + ] + }, + "unit": "percentunit" + }, + "overrides": [] + }, + "gridPos": { + "h": 4, + "w": 4, + "x": 0, + "y": 1 + }, + "id": 44, + "options": { + "displayMode": "basic", + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": false + }, + "maxVizHeight": 300, + "minVizHeight": 10, + "minVizWidth": 0, + "namePlacement": "auto", + "orientation": "vertical", + "reduceOptions": { + "calcs": [ + "last" + ], + "fields": "", + "values": false + }, + "showUnfilled": false, + "sizing": "auto", + "text": {}, + "valueMode": "color" + }, + "pluginVersion": "11.5.0-80683", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "editorMode": "code", + "exemplar": true, + "expr": "sum(container_memory_working_set_bytes{origin_prometheus=~\"$origin_prometheus\",container!=\"\",node=~\"^$Node$\"}) / sum(kube_node_status_allocatable{origin_prometheus=~\"$origin_prometheus\",resource=\"memory\", unit=\"byte\", node=~\"^$Node$\"})", + "format": "time_series", + "hide": false, + "instant": true, + "interval": "", + "legendFormat": "内存使用率", + "refId": "C" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "editorMode": "code", + "exemplar": true, + "expr": "sum(kube_pod_container_resource_requests{origin_prometheus=~\"$origin_prometheus\",resource=\"memory\", unit=\"byte\",node=~\"^$Node$\"}) / sum(kube_node_status_allocatable{origin_prometheus=~\"$origin_prometheus\",resource=\"memory\", unit=\"byte\", node=~\"^$Node$\"})", + "format": "time_series", + "hide": false, + "instant": true, + "interval": "", + "legendFormat": "内存请求率", + "refId": "A" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "editorMode": "code", + "exemplar": true, + "expr": "sum(kube_pod_container_resource_limits{origin_prometheus=~\"$origin_prometheus\",resource=\"memory\", unit=\"byte\",node=~\"^$Node$\"}) / sum(kube_node_status_allocatable{origin_prometheus=~\"$origin_prometheus\",resource=\"memory\", unit=\"byte\", node=~\"^$Node$\"})", + "format": "time_series", + "hide": false, + "instant": true, + "interval": "", + "intervalFactor": 1, + "legendFormat": "内存限制率", + "refId": "B", + "step": 10 + } + ], + "title": "节点内存比例", + "type": "bargauge" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "fieldConfig": { + "defaults": { + "decimals": 1, + "mappings": [], + "max": 1, + "min": 0, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "orange", + "value": 0.7 + }, + { + "color": "red", + "value": 0.9 + } + ] + }, + "unit": "percentunit" + }, + "overrides": [] + }, + "gridPos": { + "h": 4, + "w": 4, + "x": 4, + "y": 1 + }, + "id": 45, + "options": { + "displayMode": "basic", + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": false + }, + "maxVizHeight": 300, + "minVizHeight": 10, + "minVizWidth": 0, + "namePlacement": "auto", + "orientation": "vertical", + "reduceOptions": { + "calcs": [ + "last" + ], + "fields": "", + "values": false + }, + "showUnfilled": false, + "sizing": "auto", + "text": {}, + "valueMode": "color" + }, + "pluginVersion": "11.5.0-80683", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "editorMode": "code", + "exemplar": true, + "expr": "sum (irate(container_cpu_usage_seconds_total{origin_prometheus=~\"$origin_prometheus\",container!=\"\",node=~\"^$Node$\"}[2m])) / sum(kube_node_status_allocatable{origin_prometheus=~\"$origin_prometheus\",resource=\"cpu\", unit=\"core\", node=~\"^$Node$\"})", + "format": "time_series", + "hide": false, + "instant": true, + "interval": "", + "legendFormat": "CPU使用率", + "refId": "C" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "editorMode": "code", + "exemplar": true, + "expr": "sum(kube_pod_container_resource_requests{origin_prometheus=~\"$origin_prometheus\",resource=\"cpu\", unit=\"core\",node=~\"^$Node$\"}) / sum(kube_node_status_allocatable{origin_prometheus=~\"$origin_prometheus\",resource=\"cpu\", unit=\"core\", node=~\"^$Node$\"})", + "format": "time_series", + "instant": true, + "interval": "", + "legendFormat": "CPU请求率", + "refId": "A" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "editorMode": "code", + "exemplar": true, + "expr": "sum(kube_pod_container_resource_limits{origin_prometheus=~\"$origin_prometheus\",resource=\"cpu\", unit=\"core\",node=~\"^$Node$\"}) / sum(kube_node_status_allocatable{origin_prometheus=~\"$origin_prometheus\",resource=\"cpu\", unit=\"core\", node=~\"^$Node$\"})", + "format": "time_series", + "instant": true, + "interval": "", + "legendFormat": "CPU限制率", + "refId": "B" + } + ], + "title": "节点CPU比例", + "type": "bargauge" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "description": "集群节点数,节点POD数,节点POD上限", + "fieldConfig": { + "defaults": { + "mappings": [], + "max": 100, + "min": 1, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "orange", + "value": 1000 + }, + { + "color": "red", + "value": 2000 + } + ] + }, + "unit": "none" + }, + "overrides": [] + }, + "gridPos": { + "h": 4, + "w": 3, + "x": 8, + "y": 1 + }, + "id": 74, + "options": { + "displayMode": "basic", + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": false + }, + "maxVizHeight": 300, + "minVizHeight": 10, + "minVizWidth": 0, + "namePlacement": "auto", + "orientation": "vertical", + "reduceOptions": { + "calcs": [ + "last" + ], + "fields": "", + "values": false + }, + "showUnfilled": false, + "sizing": "auto", + "text": {}, + "valueMode": "color" + }, + "pluginVersion": "11.5.0-80683", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "expr": "count(kube_node_info{origin_prometheus=~\"$origin_prometheus\"})", + "instant": true, + "interval": "", + "legendFormat": "节点数", + "refId": "A" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "expr": "count(kube_pod_info{origin_prometheus=~\"$origin_prometheus\",created_by_kind!~\"|Job\",node=~\"^$Node$\"})", + "hide": false, + "instant": true, + "interval": "", + "legendFormat": "Pod数", + "refId": "B" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "exemplar": true, + "expr": "sum(kube_node_status_allocatable{origin_prometheus=~\"$origin_prometheus\",resource=\"pods\", unit=\"integer\",node=~\"^$Node$\"})", + "hide": false, + "instant": true, + "interval": "", + "legendFormat": "上限Pod", + "refId": "C" + } + ], + "title": "节点与Pod", + "type": "bargauge" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "align": "center", + "cellOptions": { + "type": "color-text" + }, + "filterable": false, + "inspect": false + }, + "mappings": [], + "noValue": "0", + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "none" + }, + "overrides": [ + { + "matcher": { + "id": "byName", + "options": "空间" + }, + "properties": [ + { + "id": "custom.width", + "value": 59 + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "Pod" + }, + "properties": [ + { + "id": "custom.width", + "value": 21 + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "SVC" + }, + "properties": [ + { + "id": "custom.width", + "value": 7 + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "微服务" + }, + "properties": [ + { + "id": "custom.width", + "value": 4 + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "配置" + }, + "properties": [ + { + "id": "custom.width", + "value": 16 + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "密码" + }, + "properties": [ + { + "id": "custom.width", + "value": 33 + } + ] + } + ] + }, + "gridPos": { + "h": 8, + "w": 5, + "x": 11, + "y": 1 + }, + "id": 51, + "options": { + "cellHeight": "sm", + "footer": { + "countRows": false, + "fields": "", + "reducer": [ + "sum" + ], + "show": true + }, + "showHeader": true, + "sortBy": [ + { + "desc": true, + "displayName": "微服务" + } + ] + }, + "pluginVersion": "11.5.0-80683", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "editorMode": "code", + "expr": "count(kube_pod_info{origin_prometheus=~\"$origin_prometheus\",node=~\"^$Node$\"}) by (namespace)", + "format": "table", + "instant": true, + "interval": "", + "legendFormat": "", + "refId": "A" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "editorMode": "code", + "expr": "count(kube_service_info{origin_prometheus=~\"$origin_prometheus\"}) by(namespace)", + "format": "table", + "hide": false, + "instant": true, + "interval": "", + "legendFormat": "", + "refId": "C" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "editorMode": "code", + "expr": "count by (namespace)({__name__=~\"kube_deployment_metadata_generation|kube_daemonset_metadata_generation|kube_statefulset_metadata_generation\",origin_prometheus=~\"$origin_prometheus\"})", + "format": "table", + "hide": false, + "instant": true, + "interval": "", + "legendFormat": "__auto", + "refId": "D" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "editorMode": "code", + "expr": "count(kube_configmap_info{origin_prometheus=~\"$origin_prometheus\"}) by(namespace)", + "format": "table", + "hide": false, + "instant": true, + "interval": "", + "legendFormat": "configmap", + "refId": "B" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "editorMode": "code", + "expr": "count(kube_secret_info{origin_prometheus=~\"$origin_prometheus\"}) by(namespace)", + "format": "table", + "hide": false, + "instant": true, + "interval": "", + "legendFormat": "secret", + "refId": "E" + } + ], + "title": "命名空间资源统计", + "transformations": [ + { + "id": "seriesToColumns", + "options": { + "byField": "namespace" + } + }, + { + "id": "organize", + "options": { + "excludeByName": { + "Time": true, + "Time 1": true, + "Time 2": true, + "Time 3": true, + "Time 4": true, + "Time 5": true + }, + "includeByName": {}, + "indexByName": { + "Time 1": 2, + "Time 2": 4, + "Time 3": 6, + "Value #A": 3, + "Value #C": 5, + "Value #D": 1, + "namespace": 0 + }, + "renameByName": { + "Time 1": "", + "Time 2": "", + "Value #A": "Pod", + "Value #B": "配置", + "Value #C": "SVC", + "Value #D": "微服务", + "Value #E": "密码", + "namespace": "空间" + } + } + } + ], + "type": "table" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "series", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 30, + "gradientMode": "opacity", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineStyle": { + "fill": "solid" + }, + "lineWidth": 2, + "pointSize": 4, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "never", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "links": [], + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "binbps" + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 8, + "x": 16, + "y": 1 + }, + "id": 32, + "options": { + "legend": { + "calcs": [ + "max" + ], + "displayMode": "list", + "placement": "bottom", + "showLegend": true, + "width": 200 + }, + "tooltip": { + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "11.5.0-80683", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "editorMode": "code", + "exemplar": true, + "expr": "sum (irate(container_network_receive_bytes_total{origin_prometheus=~\"$origin_prometheus\",node=~\"^$Node$\",namespace=~\"$NameSpace\"}[2m]))*8", + "format": "time_series", + "interval": "", + "intervalFactor": 1, + "legendFormat": "接收", + "metric": "network", + "range": true, + "refId": "A", + "step": 10 + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "editorMode": "code", + "exemplar": true, + "expr": "sum (irate(container_network_transmit_bytes_total{origin_prometheus=~\"$origin_prometheus\",node=~\"^$Node$\",namespace=~\"$NameSpace\"}[2m]))*8", + "instant": false, + "interval": "", + "intervalFactor": 1, + "legendFormat": "发送", + "metric": "network", + "refId": "B", + "step": 10 + } + ], + "title": "$NameSpace:网络总览(可关联节点与命名空间)", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "fieldConfig": { + "defaults": { + "decimals": 1, + "mappings": [], + "max": 2000000000000, + "min": 1, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "orange", + "value": 100000000000 + }, + { + "color": "red", + "value": 2000000000000 + } + ] + }, + "unit": "bytes" + }, + "overrides": [] + }, + "gridPos": { + "h": 4, + "w": 4, + "x": 0, + "y": 5 + }, + "id": 71, + "options": { + "displayMode": "basic", + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": false + }, + "maxVizHeight": 300, + "minVizHeight": 10, + "minVizWidth": 0, + "namePlacement": "auto", + "orientation": "vertical", + "reduceOptions": { + "calcs": [ + "last" + ], + "fields": "", + "values": false + }, + "showUnfilled": false, + "sizing": "auto", + "text": {}, + "valueMode": "color" + }, + "pluginVersion": "11.5.0-80683", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "exemplar": true, + "expr": "sum(kube_node_status_allocatable{origin_prometheus=~\"$origin_prometheus\",resource=\"memory\", unit=\"byte\", node=~\"^$Node$\"})", + "instant": true, + "interval": "", + "legendFormat": "总内存", + "refId": "A" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "exemplar": true, + "expr": "sum (container_memory_working_set_bytes{origin_prometheus=~\"$origin_prometheus\",container!=\"\",node=~\"^$Node$\"})", + "instant": true, + "interval": "", + "legendFormat": "使用量", + "refId": "C" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "exemplar": true, + "expr": "sum(kube_pod_container_resource_requests{origin_prometheus=~\"$origin_prometheus\",resource=\"memory\", unit=\"byte\",node=~\"^$Node$\"})", + "instant": true, + "interval": "", + "legendFormat": "请求量", + "refId": "D" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "exemplar": true, + "expr": "sum(kube_pod_container_resource_limits{origin_prometheus=~\"$origin_prometheus\",resource=\"memory\", unit=\"byte\",node=~\"^$Node$\"})", + "instant": true, + "interval": "", + "legendFormat": "限制量", + "refId": "B" + } + ], + "title": "节点内存信息", + "type": "bargauge" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "fieldConfig": { + "defaults": { + "decimals": 1, + "mappings": [], + "max": 500, + "min": 1, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "#EAB839", + "value": 500 + }, + { + "color": "red", + "value": 1000 + } + ] + }, + "unit": "none" + }, + "overrides": [] + }, + "gridPos": { + "h": 4, + "w": 4, + "x": 4, + "y": 5 + }, + "id": 72, + "options": { + "displayMode": "basic", + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": false + }, + "maxVizHeight": 300, + "minVizHeight": 10, + "minVizWidth": 0, + "namePlacement": "auto", + "orientation": "vertical", + "reduceOptions": { + "calcs": [ + "last" + ], + "fields": "", + "values": false + }, + "showUnfilled": false, + "sizing": "auto", + "text": {}, + "valueMode": "color" + }, + "pluginVersion": "11.5.0-80683", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "exemplar": true, + "expr": "sum(kube_node_status_allocatable{origin_prometheus=~\"$origin_prometheus\",resource=\"cpu\", unit=\"core\", node=~\"^$Node$\"})", + "instant": true, + "interval": "", + "legendFormat": "总核数", + "refId": "A" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "exemplar": true, + "expr": "sum (irate(container_cpu_usage_seconds_total{origin_prometheus=~\"$origin_prometheus\",id=\"/\",node=~\"^$Node$\"}[2m]))", + "instant": true, + "interval": "", + "legendFormat": "使用量", + "refId": "C" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "exemplar": true, + "expr": "sum(kube_pod_container_resource_requests{origin_prometheus=~\"$origin_prometheus\",resource=\"cpu\", unit=\"core\",node=~\"^$Node$\"})", + "instant": true, + "interval": "", + "legendFormat": "请求量", + "refId": "D" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "exemplar": true, + "expr": "sum(kube_pod_container_resource_limits{origin_prometheus=~\"$origin_prometheus\",resource=\"cpu\", unit=\"core\",node=~\"^$Node$\"})", + "instant": true, + "interval": "", + "legendFormat": "限制量", + "refId": "B" + } + ], + "title": "节点CPU核数", + "type": "bargauge" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "fieldConfig": { + "defaults": { + "decimals": 1, + "mappings": [], + "max": 8000000000000, + "min": 1, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "#EAB839", + "value": 5000000000000 + }, + { + "color": "red", + "value": 10000000000000 + } + ] + }, + "unit": "bytes" + }, + "overrides": [ + { + "matcher": { + "id": "byName", + "options": "使用率" + }, + "properties": [ + { + "id": "unit", + "value": "percentunit" + }, + { + "id": "max" + }, + { + "id": "min", + "value": 0 + }, + { + "id": "thresholds", + "value": { + "mode": "percentage", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "orange", + "value": 80 + }, + { + "color": "red", + "value": 90 + } + ] + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "总量" + }, + "properties": [ + { + "id": "decimals", + "value": 0 + } + ] + } + ] + }, + "gridPos": { + "h": 4, + "w": 3, + "x": 8, + "y": 5 + }, + "id": 73, + "options": { + "displayMode": "basic", + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": false + }, + "maxVizHeight": 300, + "minVizHeight": 10, + "minVizWidth": 0, + "namePlacement": "auto", + "orientation": "vertical", + "reduceOptions": { + "calcs": [ + "last" + ], + "fields": "", + "values": false + }, + "showUnfilled": false, + "sizing": "auto", + "text": {}, + "valueMode": "color" + }, + "pluginVersion": "11.5.0-80683", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "expr": "sum (container_fs_usage_bytes{origin_prometheus=~\"$origin_prometheus\",device=~\"^/dev/.*$\",id=\"/\",node=~\"^$Node$\"}) / sum (container_fs_limit_bytes{origin_prometheus=~\"$origin_prometheus\",device=~\"^/dev/.*$\",id=\"/\",node=~\"^$Node$\"})", + "instant": true, + "interval": "", + "legendFormat": "使用率", + "refId": "C" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "expr": "sum (container_fs_usage_bytes{origin_prometheus=~\"$origin_prometheus\",device=~\"^/dev/.*$\",id=\"/\",node=~\"^$Node$\"})", + "instant": true, + "interval": "", + "legendFormat": "使用量", + "refId": "A" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "expr": "sum (container_fs_limit_bytes{origin_prometheus=~\"$origin_prometheus\",device=~\"^/dev/.*$\",id=\"/\",node=~\"^$Node$\"})", + "instant": true, + "interval": "", + "legendFormat": "总量", + "refId": "B" + } + ], + "title": "节点存储信息", + "type": "bargauge" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + } + }, + "overrides": [ + { + "matcher": { + "id": "byRegexp", + "options": "/异常.*/" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "red", + "mode": "fixed" + } + } + ] + } + ] + }, + "gridPos": { + "h": 2, + "w": 24, + "x": 0, + "y": 9 + }, + "id": 88, + "maxPerRow": 2, + "options": { + "colorMode": "background", + "graphMode": "none", + "justifyMode": "center", + "orientation": "auto", + "reduceOptions": { + "calcs": [ + "last" + ], + "fields": "", + "values": false + }, + "showPercentChange": false, + "text": {}, + "textMode": "auto", + "wideLayout": true + }, + "pluginVersion": "10.4.3", + "repeat": "origin_prometheus", + "repeatDirection": "v", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "editorMode": "code", + "exemplar": false, + "expr": "count({__name__=~\"kube_deployment_metadata_generation|kube_daemonset_metadata_generation|kube_statefulset_metadata_generation\",origin_prometheus=~\"$origin_prometheus\"})", + "hide": false, + "instant": true, + "legendFormat": "工作负载", + "range": false, + "refId": "F" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "editorMode": "code", + "exemplar": false, + "expr": "count(kube_pod_info{origin_prometheus=~\"$origin_prometheus\"})", + "hide": false, + "instant": true, + "legendFormat": "总Pod", + "range": false, + "refId": "E" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "editorMode": "code", + "exemplar": false, + "expr": "count by(key,origin_prometheus)(kube_node_spec_taint{origin_prometheus=~\"$origin_prometheus\",key=~\"node.kubernetes.io.*\"})", + "format": "time_series", + "hide": false, + "instant": true, + "legendFormat": "{{key}}", + "range": false, + "refId": "D" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "editorMode": "code", + "exemplar": false, + "expr": "count by(origin_prometheus)(kube_node_info{origin_prometheus=~\"$origin_prometheus\"})", + "hide": false, + "instant": true, + "legendFormat": "总节点", + "range": false, + "refId": "C" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "editorMode": "code", + "exemplar": false, + "expr": "count by(origin_prometheus)(kube_node_info{origin_prometheus=~\"$origin_prometheus\"}) - count by(origin_prometheus)(kube_node_spec_taint{origin_prometheus=~\"$origin_prometheus\",key!~\"node.kubernetes.io.*\"})", + "hide": false, + "instant": true, + "legendFormat": "正常节点", + "range": false, + "refId": "B" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "editorMode": "code", + "exemplar": false, + "expr": "count by(key,origin_prometheus)(kube_node_spec_taint{origin_prometheus=~\"$origin_prometheus\",key!~\"node.kubernetes.io.*\"})", + "hide": false, + "instant": true, + "legendFormat": "{{key}}", + "range": false, + "refId": "A" + } + ], + "transformations": [ + { + "id": "renameByRegex", + "options": { + "regex": "(node.kubernetes.io/)(.*)", + "renamePattern": "异常:$2" + } + } + ], + "type": "stat" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 15, + "gradientMode": "opacity", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "never", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "bytes" + }, + "overrides": [ + { + "matcher": { + "id": "byName", + "options": "总内存" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "red", + "mode": "fixed" + } + }, + { + "id": "custom.lineWidth", + "value": 2 + } + ] + } + ] + }, + "gridPos": { + "h": 5, + "w": 8, + "x": 0, + "y": 11 + }, + "id": 79, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": false + }, + "tooltip": { + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "11.5.0-80683", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "editorMode": "code", + "exemplar": true, + "expr": "sum(kube_node_status_allocatable{origin_prometheus=~\"$origin_prometheus\",resource=\"memory\", unit=\"byte\", node=~\"^$Node$\"})", + "instant": false, + "interval": "", + "legendFormat": "总内存", + "refId": "A" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "exemplar": true, + "expr": "sum (container_memory_working_set_bytes{origin_prometheus=~\"$origin_prometheus\",container!=\"\",node=~\"^$Node$\"})", + "instant": false, + "interval": "", + "legendFormat": "使用量", + "refId": "C" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "exemplar": true, + "expr": "sum(kube_pod_container_resource_requests{origin_prometheus=~\"$origin_prometheus\",resource=\"memory\", unit=\"byte\",node=~\"^$Node$\"})", + "hide": true, + "instant": false, + "interval": "", + "legendFormat": "请求量", + "refId": "D" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "exemplar": true, + "expr": "sum(kube_pod_container_resource_limits{origin_prometheus=~\"$origin_prometheus\",resource=\"memory\", unit=\"byte\",node=~\"^$Node$\"})", + "hide": true, + "instant": false, + "interval": "", + "legendFormat": "限制量", + "refId": "B" + } + ], + "title": "内存使用量【$Node】", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 15, + "gradientMode": "opacity", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "never", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "none" + }, + "overrides": [ + { + "matcher": { + "id": "byName", + "options": "总核数" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "red", + "mode": "fixed" + } + }, + { + "id": "custom.lineWidth", + "value": 2 + } + ] + } + ] + }, + "gridPos": { + "h": 5, + "w": 8, + "x": 8, + "y": 11 + }, + "id": 80, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": false + }, + "tooltip": { + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "11.5.0-80683", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "editorMode": "code", + "exemplar": true, + "expr": "sum(kube_node_status_allocatable{origin_prometheus=~\"$origin_prometheus\",resource=\"cpu\", unit=\"core\", node=~\"^$Node$\"})", + "instant": false, + "interval": "", + "legendFormat": "总核数", + "refId": "A" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "exemplar": true, + "expr": "sum (irate(container_cpu_usage_seconds_total{origin_prometheus=~\"$origin_prometheus\",id=\"/\",node=~\"^$Node$\"}[2m]))", + "instant": false, + "interval": "", + "legendFormat": "使用量", + "refId": "C" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "exemplar": true, + "expr": "sum(kube_pod_container_resource_requests{origin_prometheus=~\"$origin_prometheus\",resource=\"cpu\", unit=\"core\",node=~\"^$Node$\"})", + "hide": true, + "instant": false, + "interval": "", + "legendFormat": "请求量", + "refId": "D" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "exemplar": true, + "expr": "sum(kube_pod_container_resource_limits{origin_prometheus=~\"$origin_prometheus\",resource=\"cpu\", unit=\"core\",node=~\"^$Node$\"})", + "hide": true, + "instant": true, + "interval": "", + "legendFormat": "限制量", + "refId": "B" + } + ], + "title": "CPU使用核【$Node】", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "description": "集群节点数,节点POD数,节点POD上限", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "series", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 15, + "gradientMode": "opacity", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "never", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "none" + }, + "overrides": [ + { + "matcher": { + "id": "byName", + "options": "上限Pod" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "red", + "mode": "fixed" + } + }, + { + "id": "custom.lineWidth", + "value": 2 + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "节点数" + }, + "properties": [ + { + "id": "custom.axisPlacement", + "value": "right" + }, + { + "id": "custom.drawStyle", + "value": "points" + }, + { + "id": "color", + "value": { + "fixedColor": "blue", + "mode": "fixed" + } + }, + { + "id": "custom.pointSize", + "value": 3 + } + ] + } + ] + }, + "gridPos": { + "h": 5, + "w": 8, + "x": 16, + "y": 11 + }, + "id": 81, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "11.5.0-80683", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "exemplar": true, + "expr": "count(kube_node_info{origin_prometheus=~\"$origin_prometheus\"})", + "hide": false, + "instant": false, + "interval": "", + "legendFormat": "节点数", + "refId": "A" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "editorMode": "code", + "exemplar": true, + "expr": "count(kube_pod_info{origin_prometheus=~\"$origin_prometheus\",created_by_kind!~\"|Job\",node=~\"^$Node$\"})", + "hide": false, + "instant": false, + "interval": "", + "legendFormat": "Pod数", + "refId": "B" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "exemplar": true, + "expr": "sum(kube_node_status_allocatable{origin_prometheus=~\"$origin_prometheus\",resource=\"pods\", unit=\"integer\",node=~\"^$Node$\"})", + "hide": false, + "instant": false, + "interval": "", + "legendFormat": "上限Pod", + "refId": "C" + } + ], + "title": "Pod数与节点数【$Node】", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "never", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "percent" + }, + "overrides": [ + { + "matcher": { + "id": "byRegexp", + "options": "/总核数.*/" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "#C4162A", + "mode": "fixed" + } + } + ] + } + ] + }, + "gridPos": { + "h": 6, + "w": 8, + "x": 0, + "y": 16 + }, + "id": 75, + "options": { + "legend": { + "calcs": [ + "mean", + "lastNotNull", + "max" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": false + }, + "tooltip": { + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "11.5.0-80683", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "exemplar": true, + "expr": "sum (irate(container_cpu_usage_seconds_total{origin_prometheus=~\"$origin_prometheus\",container!=\"\",node=~\"^$Node$\"}[2m]))by (node) / sum(kube_node_status_allocatable{origin_prometheus=~\"$origin_prometheus\",resource=\"cpu\", unit=\"core\", node=~\"^$Node$\"})by (node)*100", + "format": "time_series", + "hide": false, + "instant": false, + "interval": "", + "legendFormat": "{{node}}", + "refId": "I" + } + ], + "title": "$Node:节点CPU明细", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "never", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "percent" + }, + "overrides": [] + }, + "gridPos": { + "h": 6, + "w": 8, + "x": 8, + "y": 16 + }, + "id": 76, + "options": { + "legend": { + "calcs": [ + "mean", + "lastNotNull", + "max" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": false + }, + "tooltip": { + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "11.5.0-80683", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "exemplar": true, + "expr": "sum (container_memory_working_set_bytes{origin_prometheus=~\"$origin_prometheus\",container!=\"\",node=~\"^$Node$\"})by (node) / sum(kube_node_status_allocatable{origin_prometheus=~\"$origin_prometheus\",resource=\"memory\", unit=\"byte\", node=~\"^$Node$\"})by (node)*100", + "format": "time_series", + "hide": false, + "instant": false, + "interval": "", + "legendFormat": "{{node}}", + "refId": "I" + } + ], + "title": "$Node:节点内存明细", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "series", + "axisLabel": "←流入/流出→", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "never", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "links": [], + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "binbps" + }, + "overrides": [ + { + "matcher": { + "id": "byRegexp", + "options": "/流入.*/" + }, + "properties": [ + { + "id": "custom.transform", + "value": "negative-Y" + } + ] + } + ] + }, + "gridPos": { + "h": 6, + "w": 8, + "x": 16, + "y": 16 + }, + "id": 78, + "options": { + "legend": { + "calcs": [ + "mean", + "lastNotNull", + "max" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": false + }, + "tooltip": { + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "11.5.0-80683", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "exemplar": true, + "expr": "sum (irate(container_network_receive_bytes_total{origin_prometheus=~\"$origin_prometheus\",node=~\"^$Node$\"}[2m]))by (node) *8", + "format": "time_series", + "interval": "", + "intervalFactor": 1, + "legendFormat": "流入:{{node}}", + "metric": "network", + "refId": "A", + "step": 10 + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "exemplar": true, + "expr": "sum (irate(container_network_transmit_bytes_total{origin_prometheus=~\"$origin_prometheus\",node=~\"^$Node$\"}[2m]))by (node) *8", + "instant": false, + "interval": "", + "intervalFactor": 1, + "legendFormat": "流出:{{node}}", + "metric": "network", + "refId": "B", + "step": 10 + } + ], + "title": "$Node:节点网络总览", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "custom": { + "align": "center", + "cellOptions": { + "type": "auto" + }, + "filterable": false, + "inspect": false + }, + "mappings": [], + "max": 1, + "min": 0, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + } + }, + "overrides": [ + { + "matcher": { + "id": "byName", + "options": "CPU限制" + }, + "properties": [ + { + "id": "custom.width", + "value": 76 + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "内存使用" + }, + "properties": [ + { + "id": "custom.width", + "value": 71 + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "内存限制" + }, + "properties": [ + { + "id": "custom.width", + "value": 74 + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "磁盘使用" + }, + "properties": [ + { + "id": "custom.width", + "value": 74 + } + ] + }, + { + "matcher": { + "id": "byRegexp", + "options": ".*%" + }, + "properties": [ + { + "id": "custom.cellOptions", + "value": { + "mode": "gradient", + "type": "color-background" + } + }, + { + "id": "color", + "value": { + "mode": "continuous-GrYlRd" + } + }, + { + "id": "custom.width", + "value": 85 + }, + { + "id": "unit", + "value": "percentunit" + }, + { + "id": "decimals", + "value": 0 + } + ] + }, + { + "matcher": { + "id": "byRegexp", + "options": "(内存使用|内存总|内存请求|内存限制|磁盘使用|磁盘总)" + }, + "properties": [ + { + "id": "unit", + "value": "bytes" + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "节点" + }, + "properties": [ + { + "id": "custom.width", + "value": 96 + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "内存请求" + }, + "properties": [ + { + "id": "custom.width", + "value": 76 + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "CPU请求" + }, + "properties": [ + { + "id": "custom.width", + "value": 75 + } + ] + }, + { + "matcher": { + "id": "byRegexp", + "options": "(CPU总|内存总|磁盘总|Pod上限)" + }, + "properties": [ + { + "id": "custom.cellOptions", + "value": { + "mode": "gradient", + "type": "color-background" + } + }, + { + "id": "thresholds", + "value": { + "mode": "absolute", + "steps": [ + { + "color": "blue", + "value": null + } + ] + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "Pod上限" + }, + "properties": [ + { + "id": "custom.width", + "value": 66 + } + ] + }, + { + "matcher": { + "id": "byRegexp", + "options": "CPU核使用$|内存使用$|磁盘使用$|Pod数" + }, + "properties": [ + { + "id": "custom.cellOptions", + "value": { + "type": "color-text" + } + }, + { + "id": "color", + "value": { + "fixedColor": "orange", + "mode": "fixed" + } + } + ] + }, + { + "matcher": { + "id": "byRegexp", + "options": "/.*总/" + }, + "properties": [ + { + "id": "custom.cellOptions", + "value": { + "mode": "gradient", + "type": "color-background" + } + }, + { + "id": "custom.cellOptions", + "value": { + "mode": "gradient", + "type": "color-background" + } + }, + { + "id": "color", + "value": { + "fixedColor": "blue", + "mode": "fixed" + } + }, + { + "id": "decimals", + "value": 0 + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "Pod数" + }, + "properties": [ + { + "id": "custom.width", + "value": 58 + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "CPU核总" + }, + "properties": [ + { + "id": "custom.width", + "value": 69 + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "内存总" + }, + "properties": [ + { + "id": "custom.width", + "value": 75 + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "磁盘总" + }, + "properties": [ + { + "id": "custom.width", + "value": 74 + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "CPU核使用" + }, + "properties": [ + { + "id": "custom.width", + "value": 74 + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "内存使用%" + }, + "properties": [ + { + "id": "custom.width", + "value": 102 + } + ] + } + ] + }, + "gridPos": { + "h": 11, + "w": 24, + "x": 0, + "y": 22 + }, + "id": 52, + "options": { + "cellHeight": "sm", + "footer": { + "countRows": false, + "enablePagination": true, + "fields": "", + "reducer": [ + "sum" + ], + "show": false + }, + "showHeader": true, + "sortBy": [ + { + "desc": true, + "displayName": "内存使用%" + } + ] + }, + "pluginVersion": "11.5.0-80683", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "exemplar": false, + "expr": "count(kube_pod_info{origin_prometheus=~\"$origin_prometheus\",created_by_kind!~\"|Job\",node=~\"^$Node$\"}) by (node)", + "format": "table", + "hide": false, + "instant": true, + "interval": "", + "legendFormat": "pod数", + "refId": "A" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "exemplar": false, + "expr": "kube_node_status_condition{origin_prometheus=~\"$origin_prometheus\",status=\"true\",node=~\"^$Node$\"} == 1", + "format": "table", + "hide": true, + "instant": true, + "interval": "", + "legendFormat": "状态", + "refId": "B" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "exemplar": false, + "expr": "sum (irate(container_cpu_usage_seconds_total{origin_prometheus=~\"$origin_prometheus\",container!=\"\",node=~\"^$Node$\"}[2m])) by (node)", + "format": "table", + "hide": false, + "instant": true, + "interval": "", + "legendFormat": "", + "refId": "I" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "exemplar": false, + "expr": "kube_node_status_allocatable{origin_prometheus=~\"$origin_prometheus\",resource=\"cpu\", unit=\"core\", node=~\"^$Node$\"} - 0", + "format": "table", + "hide": false, + "instant": true, + "interval": "", + "legendFormat": "", + "refId": "C" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "exemplar": false, + "expr": "sum(kube_pod_container_resource_requests{origin_prometheus=~\"$origin_prometheus\",resource=\"cpu\", unit=\"core\",node=~\"^$Node$\"}) by (node)", + "format": "table", + "hide": false, + "instant": true, + "interval": "", + "legendFormat": "", + "refId": "E" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "exemplar": false, + "expr": "sum(kube_pod_container_resource_limits{origin_prometheus=~\"$origin_prometheus\",resource=\"cpu\", unit=\"core\",node=~\"^$Node$\"}) by (node)", + "format": "table", + "hide": false, + "instant": true, + "interval": "", + "legendFormat": "", + "refId": "F" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "exemplar": false, + "expr": "sum (container_memory_working_set_bytes{origin_prometheus=~\"$origin_prometheus\",container!=\"\",node=~\"^$Node$\"}) by (node)", + "format": "table", + "hide": false, + "instant": true, + "interval": "", + "legendFormat": "", + "refId": "J" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "exemplar": false, + "expr": "sum(kube_node_status_allocatable{origin_prometheus=~\"$origin_prometheus\",resource=\"memory\", unit=\"byte\", node=~\"^$Node$\"}) by (node) - 0", + "format": "table", + "hide": false, + "instant": true, + "interval": "", + "legendFormat": "", + "refId": "D" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "exemplar": false, + "expr": "sum(kube_pod_container_resource_requests{origin_prometheus=~\"$origin_prometheus\",resource=\"memory\", unit=\"byte\",node=~\"^$Node$\"}) by (node)", + "format": "table", + "hide": false, + "instant": true, + "interval": "", + "legendFormat": "", + "refId": "G" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "exemplar": false, + "expr": "sum(kube_pod_container_resource_limits{origin_prometheus=~\"$origin_prometheus\",resource=\"memory\", unit=\"byte\",node=~\"^$Node$\"}) by (node)", + "format": "table", + "hide": false, + "instant": true, + "interval": "", + "legendFormat": "", + "refId": "H" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "exemplar": false, + "expr": "sum (container_fs_usage_bytes{origin_prometheus=~\"$origin_prometheus\",device=~\"^/dev/.*$\",id=\"/\",node=~\"^$Node$\"}) by (node)", + "format": "table", + "hide": false, + "instant": true, + "interval": "", + "legendFormat": "", + "refId": "K" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "exemplar": false, + "expr": "sum (container_fs_limit_bytes{origin_prometheus=~\"$origin_prometheus\",device=~\"^/dev/.*$\",id=\"/\",node=~\"^$Node$\"}) by (node)", + "format": "table", + "hide": false, + "instant": true, + "interval": "", + "legendFormat": "", + "refId": "L" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "exemplar": false, + "expr": "sum (container_memory_working_set_bytes{origin_prometheus=~\"$origin_prometheus\",container!=\"\",node=~\"^$Node$\"})by (node) / sum(kube_node_status_allocatable{origin_prometheus=~\"$origin_prometheus\",resource=\"memory\", unit=\"byte\", node=~\"^$Node$\"})by (node)", + "format": "table", + "hide": false, + "instant": true, + "interval": "", + "legendFormat": "内存使用%", + "refId": "M" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "exemplar": false, + "expr": "sum(kube_pod_container_resource_requests{origin_prometheus=~\"$origin_prometheus\",resource=\"memory\", unit=\"byte\",node=~\"^$Node$\"})by (node) / sum(kube_node_status_allocatable{origin_prometheus=~\"$origin_prometheus\",resource=\"memory\", unit=\"byte\", node=~\"^$Node$\"})by (node)", + "format": "table", + "hide": false, + "instant": true, + "interval": "", + "legendFormat": "内存请求%", + "refId": "N" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "exemplar": false, + "expr": "sum(kube_pod_container_resource_limits{origin_prometheus=~\"$origin_prometheus\",resource=\"memory\", unit=\"byte\",node=~\"^$Node$\"})by (node) / sum(kube_node_status_allocatable{origin_prometheus=~\"$origin_prometheus\",resource=\"memory\", unit=\"byte\", node=~\"^$Node$\"})by (node)", + "format": "table", + "hide": false, + "instant": true, + "interval": "", + "legendFormat": "内存限制%", + "refId": "O" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "exemplar": false, + "expr": "sum (irate(container_cpu_usage_seconds_total{origin_prometheus=~\"$origin_prometheus\",container!=\"\",node=~\"^$Node$\"}[2m]))by (node) / sum(kube_node_status_allocatable{origin_prometheus=~\"$origin_prometheus\",resource=\"cpu\", unit=\"core\", node=~\"^$Node$\"})by (node)", + "format": "table", + "hide": false, + "instant": true, + "interval": "", + "legendFormat": "CPU使用%", + "refId": "P" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "exemplar": false, + "expr": "sum(kube_pod_container_resource_requests{origin_prometheus=~\"$origin_prometheus\",resource=\"cpu\", unit=\"core\",node=~\"^$Node$\"})by (node) / sum(kube_node_status_allocatable{origin_prometheus=~\"$origin_prometheus\",resource=\"cpu\", unit=\"core\", node=~\"^$Node$\"})by (node)", + "format": "table", + "hide": false, + "instant": true, + "interval": "", + "legendFormat": "CPU请求%", + "refId": "Q" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "exemplar": false, + "expr": "sum(kube_pod_container_resource_limits{origin_prometheus=~\"$origin_prometheus\",resource=\"cpu\", unit=\"core\",node=~\"^$Node$\"})by (node) / sum(kube_node_status_allocatable{origin_prometheus=~\"$origin_prometheus\",resource=\"cpu\", unit=\"core\", node=~\"^$Node$\"})by (node)", + "format": "table", + "hide": false, + "instant": true, + "interval": "", + "legendFormat": "内存限制%", + "refId": "R" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "exemplar": false, + "expr": "sum (container_fs_usage_bytes{origin_prometheus=~\"$origin_prometheus\",device=~\"^/dev/.*$\",id=\"/\",node=~\"^$Node$\"})by (node) / sum (container_fs_limit_bytes{origin_prometheus=~\"$origin_prometheus\",device=~\"^/dev/.*$\",id=\"/\",node=~\"^$Node$\"})by (node)", + "format": "table", + "hide": false, + "instant": true, + "interval": "", + "legendFormat": "磁盘使用%", + "refId": "S" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "exemplar": false, + "expr": "sum(kube_node_status_allocatable{origin_prometheus=~\"$origin_prometheus\",resource=\"pods\", unit=\"integer\",node=~\"^$Node$\"})by (node)", + "format": "table", + "hide": false, + "instant": true, + "interval": "", + "legendFormat": "Pod上限", + "refId": "T" + } + ], + "title": "$Node:节点信息明细", + "transformations": [ + { + "id": "merge", + "options": {} + }, + { + "id": "organize", + "options": { + "excludeByName": { + "Time": true, + "Time 1": true, + "Time 10": true, + "Time 11": true, + "Time 12": true, + "Time 13": true, + "Time 14": true, + "Time 15": true, + "Time 16": true, + "Time 17": true, + "Time 18": true, + "Time 19": true, + "Time 2": true, + "Time 20": true, + "Time 3": true, + "Time 4": true, + "Time 5": true, + "Time 6": true, + "Time 7": true, + "Time 8": true, + "Time 9": true, + "Value #B": true, + "Value #E": false, + "Value #F": false, + "__name__": true, + "app_kubernetes_io_name": true, + "app_kubernetes_io_name 1": true, + "app_kubernetes_io_name 2": true, + "app_kubernetes_io_name 3": true, + "app_kubernetes_io_version": true, + "app_kubernetes_io_version 1": true, + "app_kubernetes_io_version 2": true, + "app_kubernetes_io_version 3": true, + "condition": true, + "instance": true, + "instance 1": true, + "instance 2": true, + "instance 3": true, + "job": true, + "job 1": true, + "job 2": true, + "job 3": true, + "k8s_namespace": true, + "k8s_namespace 1": true, + "k8s_namespace 2": true, + "k8s_namespace 3": true, + "k8s_sname": true, + "k8s_sname 1": true, + "k8s_sname 2": true, + "k8s_sname 3": true, + "origin_prometheus": true, + "origin_prometheus 1": true, + "origin_prometheus 2": true, + "origin_prometheus 3": true, + "resource": true, + "status": true, + "unit": true + }, + "includeByName": {}, + "indexByName": { + "Time": 22, + "Value #A": 2, + "Value #C": 6, + "Value #D": 8, + "Value #E": 16, + "Value #F": 17, + "Value #G": 18, + "Value #H": 19, + "Value #I": 7, + "Value #J": 9, + "Value #K": 11, + "Value #L": 10, + "Value #M": 4, + "Value #N": 13, + "Value #O": 15, + "Value #P": 3, + "Value #Q": 12, + "Value #R": 14, + "Value #S": 5, + "Value #T": 1, + "instance": 23, + "job": 24, + "node": 0, + "origin_prometheus": 25, + "resource": 20, + "unit": 21 + }, + "renameByName": { + "Value #A": "Pod数", + "Value #C": "CPU核总", + "Value #D": "内存总", + "Value #E": "CPU请求", + "Value #F": "CPU限制", + "Value #G": "内存请求", + "Value #H": "内存限制", + "Value #I": "CPU核使用", + "Value #J": "内存使用", + "Value #K": "磁盘使用", + "Value #L": "磁盘总", + "Value #M": "内存使用%", + "Value #N": "内存请求%", + "Value #O": "内存限制%", + "Value #P": "CPU使用%", + "Value #Q": "CPU请求%", + "Value #R": "CPU限制%", + "Value #S": "磁盘使用%", + "Value #T": "Pod上限", + "condition": "状态", + "node": "节点" + } + } + }, + { + "id": "filterFieldsByName", + "options": {} + } + ], + "type": "table" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "align": "center", + "cellOptions": { + "type": "color-background" + }, + "inspect": false + }, + "decimals": 0, + "links": [], + "mappings": [ + { + "options": { + "0": { + "color": "red", + "index": 0 + } + }, + "type": "value" + }, + { + "options": { + "match": "null", + "result": { + "color": "red", + "index": 1 + } + }, + "type": "special" + } + ], + "noValue": "0", + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + } + ] + }, + "unit": "bytes" + }, + "overrides": [ + { + "matcher": { + "id": "byName", + "options": "使用率" + }, + "properties": [ + { + "id": "unit", + "value": "percent" + }, + { + "id": "custom.width", + "value": 54 + }, + { + "id": "color", + "value": { + "fixedColor": "purple", + "mode": "fixed" + } + }, + { + "id": "decimals" + }, + { + "id": "mappings", + "value": [ + { + "options": { + "from": 75, + "result": { + "color": "semi-dark-red", + "index": 0 + }, + "to": 110 + }, + "type": "range" + } + ] + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "挂载Pod数" + }, + "properties": [ + { + "id": "unit", + "value": "none" + }, + { + "id": "custom.width", + "value": 59 + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "命名空间" + }, + "properties": [ + { + "id": "custom.width", + "value": 58 + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "PVC" + }, + "properties": [ + { + "id": "custom.width", + "value": 94 + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "使用量" + }, + "properties": [ + { + "id": "custom.width", + "value": 57 + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "总量" + }, + "properties": [ + { + "id": "custom.width", + "value": 54 + } + ] + } + ] + }, + "gridPos": { + "h": 8, + "w": 6, + "x": 0, + "y": 33 + }, + "id": 92, + "options": { + "cellHeight": "sm", + "footer": { + "countRows": false, + "fields": "", + "reducer": [ + "sum" + ], + "show": false + }, + "showHeader": true, + "sortBy": [ + { + "desc": true, + "displayName": "使用率" + } + ] + }, + "pluginVersion": "11.5.0-80683", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "editorMode": "code", + "exemplar": false, + "expr": "max by (namespace,persistentvolumeclaim) (kubelet_volume_stats_used_bytes{origin_prometheus=~\"$origin_prometheus\"})", + "format": "table", + "instant": true, + "interval": "", + "intervalFactor": 1, + "legendFormat": "{{namespace}}:{{ persistentvolumeclaim }}", + "metric": "container_memory_usage:sort_desc", + "range": false, + "refId": "A", + "step": 10 + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "editorMode": "code", + "exemplar": false, + "expr": "min by (namespace,persistentvolumeclaim) (kubelet_volume_stats_available_bytes{origin_prometheus=~\"$origin_prometheus\"}) + max by (namespace,persistentvolumeclaim) (kubelet_volume_stats_used_bytes{origin_prometheus=~\"$origin_prometheus\"})", + "format": "table", + "hide": false, + "instant": true, + "interval": "", + "intervalFactor": 1, + "legendFormat": "__auto", + "metric": "container_memory_usage:sort_desc", + "range": false, + "refId": "B", + "step": 10 + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "editorMode": "code", + "exemplar": false, + "expr": "max by (namespace,persistentvolumeclaim) (kubelet_volume_stats_used_bytes{origin_prometheus=~\"$origin_prometheus\"}) /(min by (namespace,persistentvolumeclaim) (kubelet_volume_stats_available_bytes{origin_prometheus=~\"$origin_prometheus\"}) + max by (namespace,persistentvolumeclaim) (kubelet_volume_stats_used_bytes{origin_prometheus=~\"$origin_prometheus\"}))*100", + "format": "table", + "hide": false, + "instant": true, + "interval": "", + "intervalFactor": 1, + "legendFormat": "{{namespace}}:{{ persistentvolumeclaim }}", + "metric": "container_memory_usage:sort_desc", + "range": false, + "refId": "C", + "step": 10 + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "editorMode": "code", + "exemplar": false, + "expr": "count by (namespace,persistentvolumeclaim)(kube_pod_spec_volumes_persistentvolumeclaims_info{origin_prometheus=~\"$origin_prometheus\"})", + "format": "table", + "hide": false, + "instant": true, + "interval": "", + "intervalFactor": 1, + "legendFormat": "__auto", + "metric": "container_memory_usage:sort_desc", + "range": false, + "refId": "D", + "step": 10 + } + ], + "title": "PVC存储使用情况", + "transformations": [ + { + "id": "merge", + "options": {} + }, + { + "id": "organize", + "options": { + "excludeByName": { + "Time": true + }, + "includeByName": {}, + "indexByName": {}, + "renameByName": { + "Value #A": "使用量", + "Value #B": "总量", + "Value #C": "使用率", + "Value #D": "挂载Pod数", + "namespace": "命名空间", + "persistentvolumeclaim": "PVC" + } + } + } + ], + "type": "table" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "never", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "links": [], + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "none" + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 9, + "x": 6, + "y": 33 + }, + "id": 86, + "options": { + "legend": { + "calcs": [ + "last", + "max" + ], + "displayMode": "table", + "placement": "right", + "showLegend": true, + "sortBy": "Max", + "sortDesc": true + }, + "tooltip": { + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "11.5.0-80683", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "editorMode": "code", + "exemplar": true, + "expr": "sum(irate(container_cpu_usage_seconds_total{origin_prometheus=~\"$origin_prometheus\",container !=\"\",container!=\"POD\"}[2m])) by (namespace)>0.5", + "hide": false, + "instant": false, + "interval": "", + "intervalFactor": 1, + "legendFormat": "{{ namespace }}", + "metric": "container_cpu", + "refId": "A", + "step": 10 + } + ], + "title": "各命名空间CPU使用核(>0.5)", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "never", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "decimals": 0, + "links": [], + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "bytes" + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 9, + "x": 15, + "y": 33 + }, + "id": 85, + "options": { + "legend": { + "calcs": [ + "last", + "max" + ], + "displayMode": "table", + "placement": "right", + "showLegend": true, + "sortBy": "Max", + "sortDesc": true + }, + "tooltip": { + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "11.5.0-80683", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "editorMode": "code", + "exemplar": true, + "expr": "sum (container_memory_working_set_bytes{origin_prometheus=~\"$origin_prometheus\",container !=\"\",container!=\"POD\"}) by (namespace) > 1*1024*1024*1024", + "interval": "", + "intervalFactor": 1, + "legendFormat": "{{namespace} {{ pod }}", + "metric": "container_memory_usage:sort_desc", + "range": true, + "refId": "A", + "step": 10 + } + ], + "title": "命名空间WSS内存使用(>1G)", + "type": "timeseries" + }, + { + "collapsed": false, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 41 + }, + "id": 49, + "panels": [], + "title": "Pod资源总览:所选Pod:【$Pod】", + "type": "row" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "custom": { + "align": "center", + "cellOptions": { + "type": "auto" + }, + "filterable": false, + "inspect": false + }, + "displayName": "", + "mappings": [], + "max": 100, + "min": 0, + "thresholds": { + "mode": "percentage", + "steps": [ + { + "color": "green" + }, + { + "color": "#EAB839", + "value": 80 + }, + { + "color": "red", + "value": 90 + } + ] + }, + "unit": "short" + }, + "overrides": [ + { + "matcher": { + "id": "byName", + "options": "命名空间" + }, + "properties": [ + { + "id": "custom.width", + "value": 96 + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "Pod名称" + }, + "properties": [ + { + "id": "custom.width", + "value": 207 + }, + { + "id": "custom.align", + "value": "right" + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "使用核数" + }, + "properties": [ + { + "id": "custom.width", + "value": 71 + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "重启" + }, + "properties": [ + { + "id": "custom.width", + "value": 38 + }, + { + "id": "thresholds", + "value": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "#EAB839", + "value": 1 + }, + { + "color": "red", + "value": 3 + } + ] + } + }, + { + "id": "custom.cellOptions", + "value": { + "mode": "gradient", + "type": "color-background" + } + }, + { + "id": "decimals" + } + ] + }, + { + "matcher": { + "id": "byRegexp", + "options": ".*%" + }, + "properties": [ + { + "id": "unit", + "value": "percentunit" + }, + { + "id": "custom.cellOptions", + "value": { + "type": "color-background" + } + }, + { + "id": "color", + "value": { + "mode": "continuous-GrYlRd" + } + }, + { + "id": "decimals", + "value": 1 + }, + { + "id": "custom.width", + "value": 55 + }, + { + "id": "min", + "value": 0 + }, + { + "id": "max", + "value": 1 + } + ] + }, + { + "matcher": { + "id": "byRegexp", + "options": ".*限制" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "blue", + "mode": "fixed" + } + }, + { + "id": "custom.cellOptions", + "value": { + "mode": "gradient", + "type": "color-background" + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "节点" + }, + "properties": [ + { + "id": "custom.width", + "value": 100 + } + ] + }, + { + "matcher": { + "id": "byRegexp", + "options": "使用核$|WSS$|RSS$|存活|流入|流出" + }, + "properties": [ + { + "id": "custom.cellOptions", + "value": { + "type": "color-text" + } + }, + { + "id": "color", + "value": { + "fixedColor": "orange", + "mode": "fixed" + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "容器名" + }, + "properties": [ + { + "id": "custom.width", + "value": 57 + }, + { + "id": "custom.align", + "value": "left" + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "存活" + }, + "properties": [ + { + "id": "unit", + "value": "s" + }, + { + "id": "custom.width", + "value": 80 + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "使用核" + }, + "properties": [ + { + "id": "custom.width", + "value": 62 + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "CPU限制" + }, + "properties": [ + { + "id": "custom.width", + "value": 58 + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "内存限制" + }, + "properties": [ + { + "id": "custom.width", + "value": 68 + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "内存需求" + }, + "properties": [ + { + "id": "custom.width", + "value": 88 + } + ] + }, + { + "matcher": { + "id": "byRegexp", + "options": "WSS$|RSS$|内存需求$|内存限制$|磁盘.*$" + }, + "properties": [ + { + "id": "unit", + "value": "bytes" + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "WSS" + }, + "properties": [ + { + "id": "custom.width", + "value": 81 + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "RSS" + }, + "properties": [ + { + "id": "custom.width", + "value": 74 + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "CPU需求" + }, + "properties": [ + { + "id": "custom.width", + "value": 72 + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "磁盘限制" + }, + "properties": [ + { + "id": "custom.width", + "value": 83 + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "磁盘使用" + }, + "properties": [ + { + "id": "custom.width", + "value": 72 + }, + { + "id": "custom.cellOptions", + "value": { + "type": "color-background" + } + }, + { + "id": "thresholds", + "value": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "orange", + "value": 10737418240 + }, + { + "color": "red", + "value": 16106127360 + } + ] + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "WSS%" + }, + "properties": [ + { + "id": "custom.width", + "value": 77 + } + ] + }, + { + "matcher": { + "id": "byRegexp", + "options": "/流入|流出/" + }, + "properties": [ + { + "id": "unit", + "value": "binbps" + }, + { + "id": "custom.width", + "value": 80 + } + ] + } + ] + }, + "gridPos": { + "h": 8, + "w": 24, + "x": 0, + "y": 42 + }, + "id": 47, + "options": { + "cellHeight": "sm", + "footer": { + "countRows": false, + "fields": "", + "reducer": [ + "sum" + ], + "show": false + }, + "showHeader": true, + "sortBy": [ + { + "desc": true, + "displayName": "WSS%" + } + ] + }, + "pluginVersion": "11.5.0-80683", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "editorMode": "code", + "exemplar": false, + "expr": "sum(irate(container_cpu_usage_seconds_total{origin_prometheus=~\"$origin_prometheus\",pod=~\"$Pod\",container =~\"$Container\",container !=\"\",container!=\"POD\",node=~\"^$Node$\",namespace=~\"$NameSpace\"}[2m])) by (container, pod,node,namespace) / (sum(container_spec_cpu_quota{origin_prometheus=~\"$origin_prometheus\",pod=~\"$Pod\",container =~\"$Container\",container !=\"\",container!=\"POD\",node=~\"^$Node$\",namespace=~\"$NameSpace\"}/100000) by (container, pod,node,namespace)) ", + "format": "table", + "hide": false, + "instant": true, + "interval": "", + "legendFormat": "", + "refId": "A" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "exemplar": false, + "expr": "sum(irate(container_cpu_usage_seconds_total{origin_prometheus=~\"$origin_prometheus\",pod=~\"$Pod\",container =~\"$Container\",container !=\"\",container!=\"POD\",node=~\"^$Node$\",namespace=~\"$NameSpace\"}[2m])) by (container, pod,node,namespace)", + "format": "table", + "hide": false, + "instant": true, + "interval": "", + "legendFormat": "CPU核数使用", + "refId": "Q" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "exemplar": false, + "expr": "sum(kube_pod_container_resource_requests{origin_prometheus=~\"$origin_prometheus\",resource=\"cpu\", unit=\"core\",pod=~\"$Pod\",container =~\"$Container\",node=~\"^$Node$\",namespace=~\"$NameSpace\"}) by (container,pod,node,namespace)", + "format": "table", + "hide": false, + "instant": true, + "interval": "", + "legendFormat": "", + "refId": "B" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "exemplar": false, + "expr": "sum(kube_pod_container_resource_limits{origin_prometheus=~\"$origin_prometheus\",resource=\"cpu\", unit=\"core\",pod=~\"$Pod\",container =~\"$Container\",node=~\"^$Node$\",namespace=~\"$NameSpace\"}) by (container,pod,node,namespace)", + "format": "table", + "instant": true, + "interval": "", + "legendFormat": "", + "refId": "C" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "editorMode": "code", + "exemplar": false, + "expr": "sum (container_memory_working_set_bytes{origin_prometheus=~\"$origin_prometheus\",pod=~\"$Pod\",container =~\"$Container\",container !=\"\",container!=\"POD\",node=~\"^$Node$\",namespace=~\"$NameSpace\"}) by (container, pod,node,namespace)/ sum(container_spec_memory_limit_bytes{origin_prometheus=~\"$origin_prometheus\",pod=~\"$Pod\",container =~\"$Container\",container !=\"\",container!=\"POD\",node=~\"^$Node$\",namespace=~\"$NameSpace\"}) by (container, pod,node,namespace)", + "format": "table", + "hide": false, + "instant": true, + "interval": "", + "legendFormat": "wss%", + "refId": "I" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "exemplar": false, + "expr": "sum (container_memory_working_set_bytes{origin_prometheus=~\"$origin_prometheus\",pod=~\"$Pod\",container =~\"$Container\",container !=\"\",container!=\"POD\",node=~\"^$Node$\",namespace=~\"$NameSpace\"}) by (container, pod,node,namespace)", + "format": "table", + "hide": false, + "instant": true, + "interval": "", + "legendFormat": "wss", + "refId": "D" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "editorMode": "code", + "exemplar": false, + "expr": "sum (container_memory_rss{origin_prometheus=~\"$origin_prometheus\",pod=~\"$Pod\",container =~\"$Container\",container !=\"\",container!=\"POD\",node=~\"^$Node$\",namespace=~\"$NameSpace\"}) by (container, pod,node,namespace)/ sum(container_spec_memory_limit_bytes{origin_prometheus=~\"$origin_prometheus\",pod=~\"$Pod\",container =~\"$Container\",container !=\"\",container!=\"POD\",node=~\"^$Node$\",namespace=~\"$NameSpace\"}) by (container, pod,node,namespace)", + "format": "table", + "hide": false, + "instant": true, + "interval": "", + "legendFormat": "rss%", + "refId": "L" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "exemplar": false, + "expr": "sum (container_memory_rss{origin_prometheus=~\"$origin_prometheus\",pod=~\"$Pod\",container =~\"$Container\",container !=\"\",container!=\"POD\",node=~\"^$Node$\",namespace=~\"$NameSpace\"}) by (container, pod,node,namespace)", + "format": "table", + "hide": false, + "instant": true, + "interval": "", + "legendFormat": "rss", + "refId": "K" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "editorMode": "code", + "exemplar": false, + "expr": "sum(kube_pod_container_resource_requests{origin_prometheus=~\"$origin_prometheus\",resource=\"memory\", unit=\"byte\",pod=~\"$Pod\",container =~\"$Container\",node=~\"^$Node$\",namespace=~\"$NameSpace\"}) by (container,pod,node,namespace)", + "format": "table", + "hide": false, + "instant": true, + "interval": "", + "legendFormat": "", + "refId": "E" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "exemplar": false, + "expr": "sum(kube_pod_container_resource_limits{origin_prometheus=~\"$origin_prometheus\",resource=\"memory\", unit=\"byte\",pod=~\"$Pod\",container =~\"$Container\",node=~\"^$Node$\",namespace=~\"$NameSpace\"}) by (container,pod,node,namespace)", + "format": "table", + "hide": false, + "instant": true, + "interval": "", + "legendFormat": "", + "refId": "F" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "editorMode": "code", + "exemplar": false, + "expr": "sum(container_fs_usage_bytes{origin_prometheus=~\"$origin_prometheus\",pod=~\"$Pod\",container =~\"$Container\",container !=\"\",container!=\"POD\",node=~\"^$Node$\",namespace=~\"$NameSpace\"}) by (container,pod,node,namespace)", + "format": "table", + "instant": true, + "interval": "", + "legendFormat": "", + "refId": "J" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "editorMode": "code", + "exemplar": false, + "expr": "kube_pod_container_status_restarts_total{origin_prometheus=~\"$origin_prometheus\",pod=~\"$Pod\",container =~\"$Container\",container !=\"\",container!=\"POD\",namespace=~\"$NameSpace\"} * on (pod) group_left(node) kube_pod_info{origin_prometheus=~\"$origin_prometheus\",pod=~\"$Pod\",node=~\"^$Node$\",namespace=~\"$NameSpace\"}", + "format": "table", + "hide": false, + "instant": true, + "interval": "", + "legendFormat": "", + "refId": "H" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "editorMode": "code", + "exemplar": false, + "expr": "time() - kube_pod_created{origin_prometheus=~\"$origin_prometheus\",pod=~\"$Pod\",namespace=~\"$NameSpace\"} * on(pod) group_right kube_pod_container_info{origin_prometheus=~\"$origin_prometheus\",pod=~\"$Pod\",namespace=~\"$NameSpace\",container =~\"$Container\"}", + "format": "table", + "hide": false, + "instant": true, + "interval": "", + "legendFormat": "__auto", + "refId": "R" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "editorMode": "code", + "exemplar": false, + "expr": "sum(container_fs_limit_bytes{origin_prometheus=~\"$origin_prometheus\",pod=~\"$Pod\",container =~\"$Container\",container !=\"\",container!=\"POD\",node=~\"^$Node$\",namespace=~\"$NameSpace\"}) by (container,pod,node,namespace)", + "format": "table", + "hide": false, + "instant": true, + "interval": "", + "legendFormat": "", + "refId": "S" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "editorMode": "code", + "exemplar": false, + "expr": "sum(sum(irate(container_network_receive_bytes_total{origin_prometheus=~\"$origin_prometheus\",pod=~\"$Pod\",node=~\"^$Node$\",namespace=~\"$NameSpace\"}[2m])) by (pod)* on(pod) group_right kube_pod_container_info{origin_prometheus=~\"$origin_prometheus\",pod=~\"$Pod\",namespace=~\"$NameSpace\",container =~\"$Container\"}) by(pod) *8", + "format": "table", + "hide": false, + "instant": true, + "interval": "", + "legendFormat": "__auto", + "refId": "T" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "editorMode": "code", + "exemplar": false, + "expr": "sum(sum(irate(container_network_transmit_bytes_total{origin_prometheus=~\"$origin_prometheus\",pod=~\"$Pod\",node=~\"^$Node$\",namespace=~\"$NameSpace\"}[2m])) by (pod)* on(pod) group_right kube_pod_container_info{origin_prometheus=~\"$origin_prometheus\",pod=~\"$Pod\",namespace=~\"$NameSpace\",container =~\"$Container\"}) by(pod) *8", + "format": "table", + "hide": false, + "instant": true, + "interval": "", + "legendFormat": "__auto", + "refId": "U" + } + ], + "title": "$Node:Pod资源明细(可关联节点)", + "transformations": [ + { + "id": "merge", + "options": {} + }, + { + "id": "organize", + "options": { + "excludeByName": { + "Time": true, + "Time 1": true, + "Time 10": true, + "Time 11": true, + "Time 12": true, + "Time 13": true, + "Time 2": true, + "Time 3": true, + "Time 4": true, + "Time 5": true, + "Time 6": true, + "Time 7": true, + "Time 8": true, + "Time 9": true, + "Value #G": false, + "__name__": true, + "app_kubernetes_io_name": true, + "app_kubernetes_io_name 1": true, + "app_kubernetes_io_name 2": true, + "app_kubernetes_io_version": true, + "app_kubernetes_io_version 1": true, + "app_kubernetes_io_version 2": true, + "container 1": true, + "container 10": true, + "container 11": true, + "container 12": true, + "container 2": true, + "container 3": true, + "container 4": true, + "container 5": true, + "container 6": true, + "container 7": true, + "container 8": true, + "container 9": true, + "created_by_kind": true, + "created_by_name": true, + "host_ip": true, + "instance": true, + "instance 1": true, + "instance 2": true, + "job": true, + "job 1": true, + "job 2": true, + "k8s_namespace": true, + "k8s_namespace 1": true, + "k8s_namespace 2": true, + "k8s_sname": true, + "k8s_sname 1": true, + "k8s_sname 2": true, + "namespace": false, + "namespace 1": true, + "namespace 10": true, + "namespace 11": true, + "namespace 12": false, + "namespace 2": true, + "namespace 3": true, + "namespace 4": true, + "namespace 5": true, + "namespace 6": true, + "namespace 7": true, + "namespace 8": true, + "namespace 9": true, + "node 1": true, + "node 10": true, + "node 11": false, + "node 12": true, + "node 2": true, + "node 3": true, + "node 4": true, + "node 5": true, + "node 6": true, + "node 7": true, + "node 8": true, + "node 9": true, + "origin_prometheus": true, + "origin_prometheus 1": true, + "origin_prometheus 2": true, + "phase": true, + "pod_ip": true, + "priority_class": true, + "uid": true + }, + "includeByName": {}, + "indexByName": { + "Time": 21, + "Value #A": 4, + "Value #B": 16, + "Value #C": 7, + "Value #D": 10, + "Value #E": 17, + "Value #F": 9, + "Value #G": 23, + "Value #H": 14, + "Value #I": 5, + "Value #J": 13, + "Value #K": 11, + "Value #L": 6, + "Value #M": 24, + "Value #N": 25, + "Value #O": 26, + "Value #P": 27, + "Value #Q": 8, + "Value #R": 15, + "Value #S": 12, + "container": 2, + "instance": 18, + "ip": 28, + "job": 19, + "namespace": 1, + "node": 0, + "origin_prometheus": 20, + "pod": 3, + "uid": 22 + }, + "renameByName": { + "Value #A": "CPU%", + "Value #B": "CPU需求", + "Value #C": "CPU限制", + "Value #D": "WSS", + "Value #E": "内存需求", + "Value #F": "内存限制", + "Value #H": "重启", + "Value #I": "WSS%", + "Value #J": "磁盘使用", + "Value #K": "RSS", + "Value #L": "RSS%", + "Value #M": "堆内存", + "Value #N": "max堆", + "Value #O": "非堆", + "Value #P": "max非堆", + "Value #Q": "使用核", + "Value #R": "存活", + "Value #S": "磁盘限制", + "Value #T": "流入", + "Value #U": "流出", + "container": "容器名", + "instance": "", + "ip": "POD IP", + "namespace": "命名空间", + "namespace 1": "", + "namespace 12": "命名空间", + "node": "节点", + "node 1": "", + "node 11": "节点", + "pod": "Pod名称", + "priority_class": "" + } + } + }, + { + "id": "filterFieldsByName", + "options": { + "include": { + "names": [ + "节点", + "命名空间", + "容器名", + "Pod名称", + "CPU%", + "WSS%", + "RSS%", + "CPU限制", + "使用核", + "内存限制", + "WSS", + "RSS", + "磁盘限制", + "磁盘使用", + "重启", + "CPU需求", + "内存需求", + "流入", + "流出", + "存活" + ] + } + } + } + ], + "type": "table" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "never", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "links": [], + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "percent" + }, + "overrides": [] + }, + "gridPos": { + "h": 9, + "w": 8, + "x": 0, + "y": 50 + }, + "id": 58, + "options": { + "legend": { + "calcs": [ + "mean", + "lastNotNull", + "max" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "11.5.0-80683", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "editorMode": "code", + "exemplar": true, + "expr": "max(irate(container_cpu_usage_seconds_total{origin_prometheus=~\"$origin_prometheus\",pod=~\"$Pod\",container =~\"$Container\",container !=\"\",container!=\"POD\",node=~\"^$Node$\",namespace=~\"$NameSpace\"}[2m])) by (container, pod) / (max(container_spec_cpu_quota{origin_prometheus=~\"$origin_prometheus\",pod=~\"$Pod\",container =~\"$Container\",container !=\"\",container!=\"POD\",node=~\"^$Node$\",namespace=~\"$NameSpace\"}/100000) by (container, pod)) * 100", + "hide": false, + "instant": false, + "interval": "", + "intervalFactor": 1, + "legendFormat": "{{ pod }}", + "metric": "container_cpu", + "refId": "A", + "step": 10 + } + ], + "title": "Pod容器CPU使用率(最大100%可关联节点)", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "never", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "links": [], + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "percent" + }, + "overrides": [] + }, + "gridPos": { + "h": 9, + "w": 8, + "x": 8, + "y": 50 + }, + "id": 27, + "options": { + "legend": { + "calcs": [ + "max", + "last", + "mean" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "11.5.0-80683", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "editorMode": "code", + "exemplar": false, + "expr": "max (container_memory_working_set_bytes{origin_prometheus=~\"$origin_prometheus\",pod=~\"$Pod\",container =~\"$Container\",container !=\"\",container!=\"POD\",node=~\"^$Node$\",namespace=~\"$NameSpace\"}) by (container, pod)/ max(container_spec_memory_limit_bytes{origin_prometheus=~\"$origin_prometheus\",pod=~\"$Pod\",container =~\"$Container\",container !=\"\",container!=\"POD\",node=~\"^$Node$\",namespace=~\"$NameSpace\"}) by (container, pod) * 100", + "interval": "", + "intervalFactor": 1, + "legendFormat": "WSS:{{ pod }}", + "metric": "container_memory_usage:sort_desc", + "range": true, + "refId": "A", + "step": 10 + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "editorMode": "code", + "exemplar": false, + "expr": "max (container_memory_rss{origin_prometheus=~\"$origin_prometheus\",pod=~\"$Pod\",container =~\"$Container\",container !=\"\",container!=\"POD\",node=~\"^$Node$\",namespace=~\"$NameSpace\"}) by (container, pod)/ max(container_spec_memory_limit_bytes{origin_prometheus=~\"$origin_prometheus\",pod=~\"$Pod\",container =~\"$Container\",container !=\"\",container!=\"POD\",node=~\"^$Node$\",namespace=~\"$NameSpace\"}) by (container, pod) * 100", + "interval": "", + "intervalFactor": 1, + "legendFormat": "RSS:{{ pod }}", + "metric": "container_memory_usage:sort_desc", + "range": true, + "refId": "B", + "step": 10 + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "editorMode": "code", + "exemplar": true, + "expr": "(cass_jvm_heap{service=~\"$Container\"} * on (pod_ip) group_right(service) kube_pod_info{origin_prometheus=~\"$origin_prometheus\",pod=~\"$Pod\",namespace=~\"$NameSpace\"}) / (cass_jvm_heap_max{service=~\"$Container\"} * on (pod_ip) group_right(service) kube_pod_info{origin_prometheus=~\"$origin_prometheus\",pod=~\"$Pod\",namespace=~\"$NameSpace\"}) * 100", + "hide": true, + "instant": false, + "interval": "", + "intervalFactor": 1, + "legendFormat": "Heap:{{ pod }}", + "metric": "container_memory_usage:sort_desc", + "refId": "C", + "step": 10 + } + ], + "title": "Pod容器内存使用率(可关联节点)", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "never", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "links": [], + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "binbps" + }, + "overrides": [] + }, + "gridPos": { + "h": 9, + "w": 8, + "x": 16, + "y": 50 + }, + "id": 77, + "options": { + "legend": { + "calcs": [ + "max", + "last", + "mean" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "11.5.0-80683", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "editorMode": "code", + "exemplar": false, + "expr": "max(max(irate(container_network_receive_bytes_total{origin_prometheus=~\"$origin_prometheus\",pod=~\"$Pod\",node=~\"^$Node$\",namespace=~\"$NameSpace\"}[2m])) by (pod)* on(pod) group_right kube_pod_container_info{origin_prometheus=~\"$origin_prometheus\",pod=~\"$Pod\",namespace=~\"$NameSpace\",container =~\"$Container\"}) by(pod) *8", + "hide": false, + "interval": "", + "intervalFactor": 1, + "legendFormat": "流入:{{ pod}}", + "metric": "network", + "range": true, + "refId": "A", + "step": 10 + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "editorMode": "code", + "exemplar": false, + "expr": "max(max(irate(container_network_transmit_bytes_total{origin_prometheus=~\"$origin_prometheus\",pod=~\"$Pod\",node=~\"^$Node$\",namespace=~\"$NameSpace\"}[2m])) by (pod)* on(pod) group_right kube_pod_container_info{origin_prometheus=~\"$origin_prometheus\",pod=~\"$Pod\",namespace=~\"$NameSpace\",container =~\"$Container\"}) by(pod) *8", + "interval": "", + "intervalFactor": 1, + "legendFormat": "流出:{{ pod}}", + "metric": "network", + "range": true, + "refId": "B", + "step": 10 + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "editorMode": "code", + "expr": "sum(sum(irate(container_network_receive_bytes_total{origin_prometheus=~\"$origin_prometheus\",pod=~\"$Pod\",image!=\"\",name=~\"^k8s_.*\",node=~\"^$Node$\",namespace=~\"$NameSpace\",pod=~\".*$Container.*\"}[2m])) by (pod)* on(pod) group_right kube_pod_container_info) by(pod) *8", + "hide": true, + "interval": "", + "intervalFactor": 1, + "legendFormat": "__auto", + "metric": "network", + "range": true, + "refId": "C", + "step": 10 + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "editorMode": "code", + "expr": "sum(sum(irate(container_network_transmit_bytes_total{origin_prometheus=~\"$origin_prometheus\",pod=~\"$Pod\",image!=\"\",name=~\"^k8s_.*\",node=~\"^$Node$\",namespace=~\"$NameSpace\",pod=~\".*$Container.*\"}[2m])) by (pod)* on(pod) group_right kube_pod_container_info) by(pod) *8", + "hide": true, + "interval": "", + "intervalFactor": 1, + "legendFormat": "__auto", + "metric": "network", + "range": true, + "refId": "D", + "step": 10 + } + ], + "title": "Pod每秒网络带宽 (可关联节点)", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "never", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "links": [], + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "none" + }, + "overrides": [ + { + "matcher": { + "id": "byRegexp", + "options": "/限制.*/" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "red", + "mode": "fixed" + } + } + ] + } + ] + }, + "gridPos": { + "h": 9, + "w": 8, + "x": 0, + "y": 59 + }, + "id": 82, + "options": { + "legend": { + "calcs": [ + "max", + "last", + "mean" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true, + "sortBy": "Max", + "sortDesc": true + }, + "tooltip": { + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "10.4.1", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "editorMode": "code", + "exemplar": true, + "expr": "max(irate(container_cpu_usage_seconds_total{origin_prometheus=~\"$origin_prometheus\",pod=~\"$Pod\",container =~\"$Container\",container !=\"\",container!=\"POD\",node=~\"^$Node$\",namespace=~\"$NameSpace\"}[2m])) by (container, pod,node,namespace)", + "hide": false, + "instant": false, + "interval": "", + "intervalFactor": 1, + "legendFormat": "CPU使用:{{ pod }}", + "metric": "container_cpu", + "refId": "A", + "step": 10 + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "editorMode": "code", + "exemplar": true, + "expr": "max(max(kube_pod_container_resource_limits{origin_prometheus=~\"$origin_prometheus\",resource=\"cpu\", unit=\"core\",pod=~\"$Pod\",container =~\"$Container\",node=~\"^$Node$\",namespace=~\"$NameSpace\"}) by (container,pod,node,namespace)) by(container)", + "hide": false, + "instant": false, + "interval": "", + "intervalFactor": 1, + "legendFormat": "Pod CPU限制:{{ container}}", + "metric": "container_cpu", + "refId": "B", + "step": 10 + } + ], + "title": "Pod容器CPU核使用", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "never", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "links": [], + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "bytes" + }, + "overrides": [ + { + "matcher": { + "id": "byRegexp", + "options": "/.*限制/" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "red", + "mode": "fixed" + } + } + ] + } + ] + }, + "gridPos": { + "h": 9, + "w": 8, + "x": 8, + "y": 59 + }, + "id": 84, + "options": { + "legend": { + "calcs": [ + "max", + "last", + "mean" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true, + "sortBy": "Max", + "sortDesc": true + }, + "tooltip": { + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "10.4.1", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "editorMode": "code", + "exemplar": false, + "expr": "max (container_memory_working_set_bytes{origin_prometheus=~\"$origin_prometheus\",pod=~\"$Pod\",container =~\"$Container\",container !=\"\",container!=\"POD\",node=~\"^$Node$\",namespace=~\"$NameSpace\"}) by (container, pod,node,namespace)", + "interval": "", + "intervalFactor": 1, + "legendFormat": "WSS:{{ pod }}", + "metric": "container_memory_usage:sort_desc", + "range": true, + "refId": "A", + "step": 10 + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "editorMode": "code", + "exemplar": false, + "expr": "max(max(kube_pod_container_resource_limits{origin_prometheus=~\"$origin_prometheus\",resource=\"memory\", unit=\"byte\",pod=~\"$Pod\",container =~\"$Container\",node=~\"^$Node$\",namespace=~\"$NameSpace\"}) by (container,pod,node,namespace)) by(container)", + "hide": false, + "interval": "", + "intervalFactor": 1, + "legendFormat": "Pod内存限制:{{ container}}", + "metric": "container_memory_usage:sort_desc", + "range": true, + "refId": "B", + "step": 10 + } + ], + "title": "Pod容器WSS内存使用(可关联节点)", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "never", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "links": [], + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "bytes" + }, + "overrides": [] + }, + "gridPos": { + "h": 9, + "w": 8, + "x": 16, + "y": 59 + }, + "id": 83, + "options": { + "legend": { + "calcs": [ + "lastNotNull", + "max" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "10.4.1", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "editorMode": "code", + "exemplar": true, + "expr": "max (container_memory_rss{origin_prometheus=~\"$origin_prometheus\",pod=~\"$Pod\",container =~\"$Container\",container !=\"\",container!=\"POD\",node=~\"^$Node$\",namespace=~\"$NameSpace\"}) by (container, pod,node,namespace)", + "interval": "", + "intervalFactor": 1, + "legendFormat": "RSS:{{ pod }}", + "metric": "container_memory_usage:sort_desc", + "range": true, + "refId": "A", + "step": 10 + } + ], + "title": "Pod容器RSS内存使用(可关联节点)", + "type": "timeseries" + }, + { + "collapsed": true, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 68 + }, + "id": 61, + "panels": [ + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "custom": { + "align": "center", + "cellOptions": { + "type": "auto" + }, + "filterable": false, + "inspect": false + }, + "displayName": "", + "mappings": [], + "thresholds": { + "mode": "percentage", + "steps": [ + { + "color": "green" + } + ] + }, + "unit": "none" + }, + "overrides": [ + { + "matcher": { + "id": "byRegexp", + "options": ".*%" + }, + "properties": [ + { + "id": "unit", + "value": "percentunit" + }, + { + "id": "custom.cellOptions", + "value": { + "mode": "gradient", + "type": "gauge", + "valueDisplayMode": "color" + } + }, + { + "id": "max", + "value": 1 + }, + { + "id": "min", + "value": 0 + }, + { + "id": "color", + "value": { + "mode": "continuous-GrYlRd" + } + }, + { + "id": "decimals", + "value": 0 + } + ] + }, + { + "matcher": { + "id": "byRegexp", + "options": ".*内存使用$|.*内存限制$|.*内存需求$|.*磁盘使用$|.*磁盘限制$" + }, + "properties": [ + { + "id": "unit", + "value": "bytes" + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "命名空间" + }, + "properties": [ + { + "id": "custom.width", + "value": 92 + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "容器名" + }, + "properties": [ + { + "id": "custom.width", + "value": 187 + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "总CPU核使用" + }, + "properties": [ + { + "id": "custom.width", + "value": 100 + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "Pod" + }, + "properties": [ + { + "id": "custom.width", + "value": 44 + }, + { + "id": "custom.cellOptions", + "value": { + "type": "color-background" + } + }, + { + "id": "color", + "value": { + "fixedColor": "blue", + "mode": "fixed" + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "平均CPU使用%" + }, + "properties": [ + { + "id": "custom.width", + "value": 116 + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "平均RSS内存使用%" + }, + "properties": [ + { + "id": "custom.width", + "value": 141 + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "平均WSS内存使用%" + }, + "properties": [ + { + "id": "custom.width", + "value": 165 + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "总CPU限制" + }, + "properties": [ + { + "id": "custom.width", + "value": 86 + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "总内存限制" + }, + "properties": [ + { + "id": "custom.width", + "value": 86 + } + ] + }, + { + "matcher": { + "id": "byRegexp", + "options": "/.*限制$/" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "blue", + "mode": "fixed" + } + }, + { + "id": "custom.cellOptions", + "value": { + "type": "color-background" + } + } + ] + }, + { + "matcher": { + "id": "byRegexp", + "options": "/.*内存使用$|.*核使用$/" + }, + "properties": [ + { + "id": "custom.cellOptions", + "value": { + "type": "color-text" + } + }, + { + "id": "color", + "value": { + "fixedColor": "orange", + "mode": "fixed" + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "总RSS内存使用" + }, + "properties": [ + { + "id": "custom.width", + "value": 107 + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "总WSS内存使用" + }, + "properties": [ + { + "id": "custom.width", + "value": 113 + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "平均磁盘使用" + }, + "properties": [ + { + "id": "custom.width", + "value": 96 + }, + { + "id": "custom.cellOptions", + "value": { + "type": "color-background" + } + }, + { + "id": "thresholds", + "value": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "orange", + "value": 10737418240 + }, + { + "color": "red", + "value": 16106127360 + } + ] + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "平均磁盘限制" + }, + "properties": [ + { + "id": "custom.width", + "value": 96 + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "总CPU需求" + }, + "properties": [ + { + "id": "custom.width", + "value": 80 + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "总内存需求" + }, + "properties": [ + { + "id": "custom.width", + "value": 80 + } + ] + } + ] + }, + "gridPos": { + "h": 9, + "w": 24, + "x": 0, + "y": 3 + }, + "id": 87, + "options": { + "cellHeight": "sm", + "footer": { + "countRows": false, + "enablePagination": true, + "fields": "", + "reducer": [ + "sum" + ], + "show": false + }, + "showHeader": true, + "sortBy": [ + { + "desc": true, + "displayName": "平均WSS内存使用%" + } + ] + }, + "pluginVersion": "10.4.1", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "editorMode": "code", + "exemplar": false, + "expr": "sum(irate(container_cpu_usage_seconds_total{origin_prometheus=~\"$origin_prometheus\",container =~\"$Container\",container !=\"\",container!=\"POD\",namespace=~\"$NameSpace\"}[2m])) by (container) / (sum(container_spec_cpu_quota{origin_prometheus=~\"$origin_prometheus\",container =~\"$Container\",container !=\"\",container!=\"POD\",namespace=~\"$NameSpace\"}/100000) by (container))", + "format": "table", + "hide": false, + "instant": true, + "interval": "", + "legendFormat": "", + "refId": "A" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "editorMode": "code", + "exemplar": false, + "expr": "sum(irate(container_cpu_usage_seconds_total{origin_prometheus=~\"$origin_prometheus\",container =~\"$Container\",container !=\"\",container!=\"POD\",namespace=~\"$NameSpace\"}[2m])) by (container)", + "format": "table", + "hide": false, + "instant": true, + "interval": "", + "legendFormat": "总核数使用", + "refId": "L" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "exemplar": false, + "expr": "sum(kube_pod_container_resource_requests{origin_prometheus=~\"$origin_prometheus\",resource=\"cpu\", unit=\"core\",container =~\"$Container\",container !=\"\",container!=\"POD\",namespace=~\"$NameSpace\"}) by (container)", + "format": "table", + "hide": false, + "instant": true, + "interval": "", + "legendFormat": "", + "refId": "B" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "exemplar": false, + "expr": "sum(kube_pod_container_resource_limits{origin_prometheus=~\"$origin_prometheus\",resource=\"cpu\", unit=\"core\",container =~\"$Container\",container !=\"\",container!=\"POD\",namespace=~\"$NameSpace\"}) by (container)", + "format": "table", + "instant": true, + "interval": "", + "legendFormat": "", + "refId": "C" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "editorMode": "code", + "exemplar": false, + "expr": "sum (container_memory_working_set_bytes{origin_prometheus=~\"$origin_prometheus\",container =~\"$Container\",container !=\"\",container!=\"POD\",namespace=~\"$NameSpace\"}) by (container)/ sum(container_spec_memory_limit_bytes{origin_prometheus=~\"$origin_prometheus\",container =~\"$Container\",container !=\"\",container!=\"POD\",namespace=~\"$NameSpace\"}) by (container)", + "format": "table", + "hide": false, + "instant": true, + "interval": "", + "legendFormat": "", + "refId": "I" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "exemplar": false, + "expr": "sum (container_memory_working_set_bytes{origin_prometheus=~\"$origin_prometheus\",container =~\"$Container\",container !=\"\",container!=\"POD\",namespace=~\"$NameSpace\"}) by (container)", + "format": "table", + "hide": false, + "instant": true, + "interval": "", + "legendFormat": "", + "refId": "D" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "editorMode": "code", + "exemplar": false, + "expr": "sum (container_memory_rss{origin_prometheus=~\"$origin_prometheus\",container =~\"$Container\",container !=\"\",container!=\"POD\",namespace=~\"$NameSpace\"}) by (container)/ sum(container_spec_memory_limit_bytes{origin_prometheus=~\"$origin_prometheus\",container =~\"$Container\",container !=\"\",container!=\"POD\",namespace=~\"$NameSpace\"}) by (container)", + "format": "table", + "hide": false, + "instant": true, + "interval": "", + "legendFormat": "平均内存%(RSS)", + "refId": "H" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "exemplar": false, + "expr": "sum (container_memory_rss{origin_prometheus=~\"$origin_prometheus\",container =~\"$Container\",container !=\"\",container!=\"POD\",namespace=~\"$NameSpace\"}) by (container)", + "format": "table", + "hide": false, + "instant": true, + "interval": "", + "legendFormat": "总内存使用(RSS) ", + "refId": "K" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "editorMode": "code", + "exemplar": false, + "expr": "sum by(container) (kube_pod_container_resource_requests{origin_prometheus=~\"$origin_prometheus\",resource=\"memory\", unit=\"byte\",container =~\"$Container\",container !=\"\",container!=\"POD\",namespace=~\"$NameSpace\"})", + "format": "table", + "hide": false, + "instant": true, + "interval": "", + "legendFormat": "", + "refId": "E" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "exemplar": false, + "expr": "sum(kube_pod_container_resource_limits{origin_prometheus=~\"$origin_prometheus\",resource=\"memory\", unit=\"byte\",container =~\"$Container\",container !=\"\",container!=\"POD\",namespace=~\"$NameSpace\"}) by (container)", + "format": "table", + "hide": false, + "instant": true, + "interval": "", + "legendFormat": "", + "refId": "F" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "editorMode": "code", + "exemplar": false, + "expr": "avg(container_fs_usage_bytes{origin_prometheus=~\"$origin_prometheus\",container =~\"$Container\",container !=\"\",container!=\"POD\",namespace=~\"$NameSpace\"}) by (container)", + "format": "table", + "instant": true, + "interval": "", + "legendFormat": "", + "refId": "J" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "editorMode": "code", + "exemplar": false, + "expr": "count(kube_pod_container_info{origin_prometheus=~\"$origin_prometheus\",container =~\"$Container\",container !=\"\",container!=\"POD\",namespace=~\"$NameSpace\"}) by(container,namespace)", + "format": "table", + "instant": true, + "interval": "", + "legendFormat": "", + "refId": "G" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "editorMode": "code", + "exemplar": false, + "expr": "avg(container_fs_limit_bytes{origin_prometheus=~\"$origin_prometheus\",container =~\"$Container\",container !=\"\",container!=\"POD\",namespace=~\"$NameSpace\"}) by (container)", + "format": "table", + "hide": false, + "instant": true, + "interval": "", + "legendFormat": "", + "refId": "M" + } + ], + "title": "微服务(容器名)资源统计", + "transformations": [ + { + "id": "merge", + "options": {} + }, + { + "id": "organize", + "options": { + "excludeByName": { + "Time": true, + "Time 1": true, + "Time 10": true, + "Time 11": true, + "Time 12": true, + "Time 2": true, + "Time 3": true, + "Time 4": true, + "Time 5": true, + "Time 6": true, + "Time 7": true, + "Time 8": true, + "Time 9": true + }, + "includeByName": {}, + "indexByName": { + "Time": 15, + "Value #A": 3, + "Value #B": 13, + "Value #C": 6, + "Value #D": 9, + "Value #E": 14, + "Value #F": 8, + "Value #G": 2, + "Value #H": 5, + "Value #I": 4, + "Value #J": 12, + "Value #K": 10, + "Value #L": 7, + "Value #M": 11, + "container": 1, + "namespace": 0 + }, + "renameByName": { + "Time 1": "", + "Value #A": "平均CPU使用%", + "Value #B": "总CPU需求", + "Value #C": "总CPU限制", + "Value #D": "总WSS内存使用", + "Value #E": "总内存需求", + "Value #F": "总内存限制", + "Value #G": "Pod", + "Value #H": "平均RSS内存使用%", + "Value #I": "平均WSS内存使用%", + "Value #J": "平均磁盘使用", + "Value #K": "总RSS内存使用", + "Value #L": "总CPU核使用", + "Value #M": "平均磁盘限制", + "container": "容器名", + "namespace": "命名空间" + } + } + }, + { + "id": "filterFieldsByName", + "options": {} + } + ], + "type": "table" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "never", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "links": [], + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "percent" + }, + "overrides": [] + }, + "gridPos": { + "h": 7, + "w": 8, + "x": 0, + "y": 12 + }, + "id": 24, + "options": { + "legend": { + "calcs": [ + "max", + "last", + "mean" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "10.4.1", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "exemplar": true, + "expr": "sum(irate(container_cpu_usage_seconds_total{origin_prometheus=~\"$origin_prometheus\",container =~\"$Container\",container !=\"\",container!=\"POD\",namespace=~\"$NameSpace\"}[2m])) by (container) / (sum(container_spec_cpu_quota{origin_prometheus=~\"$origin_prometheus\",container =~\"$Container\",container !=\"\",container!=\"POD\",namespace=~\"$NameSpace\"}/100000) by (container)) * 100", + "hide": false, + "instant": false, + "interval": "", + "intervalFactor": 1, + "legendFormat": "{{ container}}", + "metric": "container_cpu", + "refId": "A", + "step": 10 + } + ], + "title": "微服务(容器名)平均CPU使用率(最大100%)", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "never", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "links": [], + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "percent" + }, + "overrides": [] + }, + "gridPos": { + "h": 7, + "w": 8, + "x": 8, + "y": 12 + }, + "id": 89, + "options": { + "legend": { + "calcs": [ + "max", + "last", + "mean" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "10.4.1", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "expr": "sum (container_memory_working_set_bytes{origin_prometheus=~\"$origin_prometheus\",container =~\"$Container\",container !=\"\",container!=\"POD\",namespace=~\"$NameSpace\"}) by (container)/ sum(container_spec_memory_limit_bytes{origin_prometheus=~\"$origin_prometheus\",container =~\"$Container\",container !=\"\",container!=\"POD\",namespace=~\"$NameSpace\"}) by (container) * 100", + "interval": "", + "intervalFactor": 1, + "legendFormat": "WSS:{{ container }}", + "metric": "container_memory_usage:sort_desc", + "refId": "A", + "step": 10 + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "expr": "sum (container_memory_rss{origin_prometheus=~\"$origin_prometheus\",container =~\"$Container\",container !=\"\",container!=\"POD\",namespace=~\"$NameSpace\"}) by (container)/ sum(container_spec_memory_limit_bytes{origin_prometheus=~\"$origin_prometheus\",container =~\"$Container\",container !=\"\",container!=\"POD\",namespace=~\"$NameSpace\"}) by (container) * 100", + "interval": "", + "intervalFactor": 1, + "legendFormat": "RSS:{{ container }}", + "metric": "container_memory_usage:sort_desc", + "refId": "B", + "step": 10 + } + ], + "title": "微服务(容器名)平均内存使用率", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "never", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "links": [], + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "binbps" + }, + "overrides": [] + }, + "gridPos": { + "h": 7, + "w": 8, + "x": 16, + "y": 12 + }, + "id": 16, + "options": { + "legend": { + "calcs": [ + "mean", + "last", + "max" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "10.4.1", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "editorMode": "code", + "exemplar": true, + "expr": "sum(sum(irate(container_network_receive_bytes_total{origin_prometheus=~\"$origin_prometheus\",node=~\"^$Node$\",namespace=~\"$NameSpace\"}[2m])) by (pod)* on(pod) group_right kube_pod_container_info{origin_prometheus=~\"$origin_prometheus\",namespace=~\"$NameSpace\",container =~\"$Container\"}) by(container) *8", + "hide": false, + "interval": "", + "intervalFactor": 1, + "legendFormat": "流入:{{ container }}", + "metric": "network", + "range": true, + "refId": "A", + "step": 10 + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "editorMode": "code", + "exemplar": true, + "expr": "sum(sum(irate(container_network_transmit_bytes_total{origin_prometheus=~\"$origin_prometheus\",node=~\"^$Node$\",namespace=~\"$NameSpace\"}[2m])) by (pod)* on(pod) group_right kube_pod_container_info{origin_prometheus=~\"$origin_prometheus\",namespace=~\"$NameSpace\",container =~\"$Container\"}) by(container) *8", + "interval": "", + "intervalFactor": 1, + "legendFormat": "流出:{{ container }}", + "metric": "network", + "range": true, + "refId": "B", + "step": 10 + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "expr": "sum (rate (container_network_receive_bytes_total{origin_prometheus=~\"$origin_prometheus\",pod=~\"$Pod\",image!=\"\",name=~\"^k8s_.*\",node=~\"^$Node$\",namespace=~\"$NameSpace\",pod=~\".*$Container.*\"}[2m])) by (pod)", + "hide": true, + "interval": "", + "intervalFactor": 1, + "legendFormat": "-> {{ pod }}", + "metric": "network", + "refId": "C", + "step": 10 + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "expr": "- sum (rate (container_network_transmit_bytes_total{origin_prometheus=~\"$origin_prometheus\",pod=~\"$Pod\",image!=\"\",name=~\"^k8s_.*\",node=~\"^$Node$\",namespace=~\"$NameSpace\",pod=~\".*$Container.*\"}[2m])) by (pod)", + "hide": true, + "interval": "", + "intervalFactor": 1, + "legendFormat": "<- {{ pod }}", + "metric": "network", + "refId": "D", + "step": 10 + } + ], + "title": "微服务(容器名)每秒网络带宽 (可关联节点)", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "never", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "links": [], + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "none" + }, + "overrides": [ + { + "matcher": { + "id": "byRegexp", + "options": "/CPU限制.*/" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "red", + "mode": "fixed" + } + } + ] + } + ] + }, + "gridPos": { + "h": 8, + "w": 8, + "x": 0, + "y": 19 + }, + "id": 91, + "options": { + "legend": { + "calcs": [ + "max", + "last", + "mean" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true, + "sortBy": "Max", + "sortDesc": true + }, + "tooltip": { + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "10.4.1", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "editorMode": "code", + "exemplar": true, + "expr": "sum(kube_pod_container_resource_limits{origin_prometheus=~\"$origin_prometheus\",resource=\"cpu\", unit=\"core\",container =~\"$Container\",container !=\"\",container!=\"POD\",namespace=~\"$NameSpace\"}) by (container)", + "hide": false, + "instant": false, + "interval": "", + "intervalFactor": 1, + "legendFormat": "CPU限制:{{ container}}", + "metric": "container_cpu", + "refId": "A", + "step": 10 + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "editorMode": "code", + "exemplar": true, + "expr": "sum(irate(container_cpu_usage_seconds_total{origin_prometheus=~\"$origin_prometheus\",container =~\"$Container\",container !=\"\",container!=\"POD\",namespace=~\"$NameSpace\"}[2m])) by (container)", + "hide": false, + "instant": false, + "interval": "", + "intervalFactor": 1, + "legendFormat": "CPU核使用:{{ container}}", + "metric": "container_cpu", + "refId": "B", + "step": 10 + } + ], + "title": "微服务(容器名)整体CPU使用核", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "never", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "links": [], + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "bytes" + }, + "overrides": [ + { + "matcher": { + "id": "byRegexp", + "options": "/内存限制.*/" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "red", + "mode": "fixed" + } + } + ] + } + ] + }, + "gridPos": { + "h": 8, + "w": 8, + "x": 8, + "y": 19 + }, + "id": 90, + "options": { + "legend": { + "calcs": [ + "max", + "last", + "mean" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true, + "sortBy": "Max", + "sortDesc": true + }, + "tooltip": { + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "10.4.1", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "editorMode": "code", + "expr": "sum (container_memory_working_set_bytes{origin_prometheus=~\"$origin_prometheus\",container =~\"$Container\",container !=\"\",container!=\"POD\",namespace=~\"$NameSpace\"}) by (container)", + "interval": "", + "intervalFactor": 1, + "legendFormat": "WSS:{{ container }}", + "metric": "container_memory_usage:sort_desc", + "range": true, + "refId": "A", + "step": 10 + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "editorMode": "code", + "expr": "sum(container_spec_memory_limit_bytes{origin_prometheus=~\"$origin_prometheus\",container =~\"$Container\",container !=\"\",container!=\"POD\",namespace=~\"$NameSpace\"}) by (container)", + "interval": "", + "intervalFactor": 1, + "legendFormat": "内存限制:{{ container }}", + "metric": "container_memory_usage:sort_desc", + "range": true, + "refId": "B", + "step": 10 + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "editorMode": "code", + "expr": "sum (container_memory_rss{origin_prometheus=~\"$origin_prometheus\",container =~\"$Container\",container !=\"\",container!=\"POD\",namespace=~\"$NameSpace\"}) by (container)", + "hide": false, + "interval": "", + "intervalFactor": 1, + "legendFormat": "RSS:{{ container }}", + "metric": "container_memory_usage:sort_desc", + "range": true, + "refId": "C", + "step": 10 + } + ], + "title": "微服务(容器名)整体内存使用量", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "never", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "links": [], + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "none" + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 8, + "x": 16, + "y": 19 + }, + "id": 59, + "options": { + "legend": { + "calcs": [ + "max", + "last", + "mean" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "10.4.1", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "editorMode": "code", + "expr": "count(kube_pod_container_info{origin_prometheus=~\"$origin_prometheus\",container =~\"$Container\",container !=\"\",container!=\"POD\",namespace=~\"$NameSpace\"}) by(container,namespace)", + "interval": "", + "intervalFactor": 1, + "legendFormat": "{{namespace}}:{{ container }}", + "metric": "container_memory_usage:sort_desc", + "range": true, + "refId": "A", + "step": 10 + } + ], + "title": "微服务(容器名)Pod数", + "type": "timeseries" + } + ], + "title": "微服务(容器名)资源总览:所选微服务:【$Container】", + "type": "row" + } + ], + "refresh": "", + "schemaVersion": 40, + "tags": [ + "StarsL.cn", + "Prometheus", + "Kubernetes" + ], + "templating": { + "list": [ + { + "current": {}, + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "definition": "label_values(kube_node_info,origin_prometheus)", + "includeAll": false, + "label": "K8S", + "name": "origin_prometheus", + "options": [], + "query": { + "query": "label_values(kube_node_info,origin_prometheus)", + "refId": "StandardVariableQuery" + }, + "refresh": 2, + "regex": "", + "sort": 5, + "type": "query" + }, + { + "allValue": ".*", + "current": {}, + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "definition": "label_values(kube_node_info{origin_prometheus=~\"$origin_prometheus\"},node)", + "includeAll": true, + "label": "节点", + "name": "Node", + "options": [], + "query": { + "query": "label_values(kube_node_info{origin_prometheus=~\"$origin_prometheus\"},node)", + "refId": "StandardVariableQuery" + }, + "refresh": 2, + "regex": "", + "sort": 5, + "type": "query" + }, + { + "allValue": ".*", + "current": {}, + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "definition": "label_values(kube_namespace_created{origin_prometheus=~\"$origin_prometheus\"},namespace)", + "includeAll": true, + "label": "命名空间", + "name": "NameSpace", + "options": [], + "query": { + "query": "label_values(kube_namespace_created{origin_prometheus=~\"$origin_prometheus\"},namespace)", + "refId": "PrometheusVariableQueryEditor-VariableQuery" + }, + "refresh": 2, + "regex": "", + "sort": 5, + "type": "query" + }, + { + "allValue": ".*", + "current": {}, + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "definition": "label_values(kube_pod_container_info{origin_prometheus=~\"$origin_prometheus\",namespace=~\"$NameSpace\"},container)", + "includeAll": true, + "label": "微服务(容器名)", + "name": "Container", + "options": [], + "query": { + "query": "label_values(kube_pod_container_info{origin_prometheus=~\"$origin_prometheus\",namespace=~\"$NameSpace\"},container)", + "refId": "StandardVariableQuery" + }, + "refresh": 2, + "regex": "", + "sort": 5, + "type": "query" + }, + { + "allValue": ".*", + "current": {}, + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "definition": "label_values(kube_pod_container_info{origin_prometheus=~\"$origin_prometheus\",namespace=~\"$NameSpace\",container=~\"$Container\"},pod)", + "includeAll": true, + "label": "Pod", + "name": "Pod", + "options": [], + "query": { + "query": "label_values(kube_pod_container_info{origin_prometheus=~\"$origin_prometheus\",namespace=~\"$NameSpace\",container=~\"$Container\"},pod)", + "refId": "StandardVariableQuery" + }, + "refresh": 2, + "regex": "", + "sort": 5, + "type": "query" + } + ] + }, + "time": { + "from": "now-30m", + "to": "now" + }, + "timepicker": { + "refresh_intervals": [ + "30s", + "1m", + "5m", + "15m", + "30m", + "1h" + ] + }, + "timezone": "browser", + "title": "K8S Dashboard", + "uid": "StarsL_cn_K8S", + "version": 4, + "weekStart": "" +} \ No newline at end of file diff --git a/roles/grafana-dashboard/Node-Exporter-Dashboard-202501015.json b/roles/grafana-dashboard/Node-Exporter-Dashboard-202501015.json new file mode 100644 index 0000000..31a9be3 --- /dev/null +++ b/roles/grafana-dashboard/Node-Exporter-Dashboard-202501015.json @@ -0,0 +1,5890 @@ +{ + "__inputs": [ + { + "name": "DS_指标", + "label": "指标", + "description": "", + "type": "datasource", + "pluginId": "prometheus", + "pluginName": "Prometheus" + } + ], + "__elements": {}, + "__requires": [ + { + "type": "panel", + "id": "bargauge", + "name": "Bar gauge", + "version": "" + }, + { + "type": "grafana", + "id": "grafana", + "name": "Grafana", + "version": "11.5.0-80683" + }, + { + "type": "datasource", + "id": "prometheus", + "name": "Prometheus", + "version": "1.0.0" + }, + { + "type": "panel", + "id": "stat", + "name": "Stat", + "version": "" + }, + { + "type": "panel", + "id": "table", + "name": "Table", + "version": "" + }, + { + "type": "panel", + "id": "timeseries", + "name": "Time series", + "version": "" + } + ], + "annotations": { + "list": [ + { + "$$hashKey": "object:2875", + "builtIn": 1, + "datasource": { + "type": "datasource", + "uid": "grafana" + }, + "enable": true, + "hide": true, + "iconColor": "rgba(0, 211, 255, 1)", + "name": "Annotations & Alerts", + "target": { + "limit": 100, + "matchAny": false, + "tags": [], + "type": "dashboard" + }, + "type": "dashboard" + } + ] + }, + "description": "【中文版本】2024.05.22更新,优化重要指标展示。使用Grafana10新样式重建,新增健康评分概念,并新增了整体资源消耗信息的一些图表。包含整体资源展示与资源明细图表:CPU 内存 磁盘 IO 网络等监控指标。https://github.com/starsliao/TenSunS", + "editable": true, + "fiscalYearStartMonth": 0, + "graphTooltip": 0, + "id": null, + "links": [ + { + "$$hashKey": "object:2300", + "icon": "bolt", + "tags": [], + "targetBlank": true, + "title": "Update", + "tooltip": "更多仪表板", + "type": "link", + "url": "https://grafana.com/orgs/starsliao/dashboards" + }, + { + "$$hashKey": "object:2301", + "icon": "question", + "tags": [], + "targetBlank": true, + "title": "GitHub", + "tooltip": "GITHUB:TenSunS", + "type": "link", + "url": "https://github.com/starsliao/TenSunS" + }, + { + "$$hashKey": "object:2302", + "asDropdown": true, + "icon": "external link", + "tags": [], + "targetBlank": true, + "title": "", + "type": "dashboards" + } + ], + "panels": [ + { + "collapsed": false, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 0 + }, + "id": 187, + "panels": [], + "title": "🏡资源总览:当前JOB【$origin_prometheus:$job】当前选中主机【$show_name】实例:$instance", + "type": "row" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "description": "分区使用率、磁盘读取、磁盘写入、下载带宽、上传带宽,如果有多个网卡或者多个分区,是采集的使用率最高的网卡或者分区的数值。\n\n连接数:CurrEstab - 当前状态为 ESTABLISHED 或 CLOSE-WAIT 的 TCP 连接数。\n\n健康值是一个新增的指标,根据CPU,内存,IO计算出来的一个值,低于90分说明系统的资源使用情况需要注意了,这是一个正在测试的指标,参数可能需要根据实际情况再优化。", + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "custom": { + "align": "center", + "cellOptions": { + "type": "auto" + }, + "filterable": false, + "inspect": false + }, + "decimals": 1, + "mappings": [], + "max": 100, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + } + ] + }, + "unit": "none" + }, + "overrides": [ + { + "matcher": { + "id": "byName", + "options": "内存" + }, + "properties": [ + { + "id": "unit", + "value": "bytes" + }, + { + "id": "decimals" + }, + { + "id": "custom.width", + "value": 66 + }, + { + "id": "color", + "value": { + "fixedColor": "blue", + "mode": "fixed" + } + }, + { + "id": "custom.cellOptions", + "value": { + "type": "color-text" + } + }, + { + "id": "decimals", + "value": 0 + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "启动(天)" + }, + "properties": [ + { + "id": "unit", + "value": "none" + }, + { + "id": "custom.width", + "value": 69 + }, + { + "id": "decimals" + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "磁盘读取*" + }, + "properties": [ + { + "id": "unit", + "value": "binBps" + }, + { + "id": "custom.cellOptions", + "value": { + "mode": "gradient", + "type": "color-background" + } + }, + { + "id": "thresholds", + "value": { + "mode": "absolute", + "steps": [ + { + "color": "rgba(50, 172, 45, 0.97)", + "value": null + }, + { + "color": "rgba(237, 129, 40, 0.89)", + "value": 10485760 + }, + { + "color": "rgba(245, 54, 54, 0.9)", + "value": 20485760 + } + ] + } + }, + { + "id": "custom.width", + "value": 93 + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "磁盘写入*" + }, + "properties": [ + { + "id": "unit", + "value": "binBps" + }, + { + "id": "custom.cellOptions", + "value": { + "mode": "gradient", + "type": "color-background" + } + }, + { + "id": "thresholds", + "value": { + "mode": "absolute", + "steps": [ + { + "color": "rgba(50, 172, 45, 0.97)", + "value": null + }, + { + "color": "rgba(237, 129, 40, 0.89)", + "value": 10485760 + }, + { + "color": "rgba(245, 54, 54, 0.9)", + "value": 20485760 + } + ] + } + }, + { + "id": "custom.width", + "value": 95 + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "下载带宽*" + }, + "properties": [ + { + "id": "unit", + "value": "binbps" + }, + { + "id": "custom.cellOptions", + "value": { + "mode": "gradient", + "type": "color-background" + } + }, + { + "id": "thresholds", + "value": { + "mode": "absolute", + "steps": [ + { + "color": "rgba(50, 172, 45, 0.97)", + "value": null + }, + { + "color": "rgba(237, 129, 40, 0.89)", + "value": 30485760 + }, + { + "color": "rgba(245, 54, 54, 0.9)", + "value": 104857600 + } + ] + } + }, + { + "id": "custom.width", + "value": 91 + }, + { + "id": "decimals" + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "上传带宽*" + }, + "properties": [ + { + "id": "unit", + "value": "binbps" + }, + { + "id": "custom.cellOptions", + "value": { + "mode": "gradient", + "type": "color-background" + } + }, + { + "id": "thresholds", + "value": { + "mode": "absolute", + "steps": [ + { + "color": "rgba(50, 172, 45, 0.97)", + "value": null + }, + { + "color": "rgba(237, 129, 40, 0.89)", + "value": 30485760 + }, + { + "color": "rgba(245, 54, 54, 0.9)", + "value": 104857600 + } + ] + } + }, + { + "id": "custom.width", + "value": 85 + }, + { + "id": "decimals" + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "负载" + }, + "properties": [ + { + "id": "decimals", + "value": 2 + }, + { + "id": "custom.width", + "value": 63 + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "连接数" + }, + "properties": [ + { + "id": "custom.cellOptions", + "value": { + "mode": "gradient", + "type": "color-background" + } + }, + { + "id": "thresholds", + "value": { + "mode": "absolute", + "steps": [ + { + "color": "rgba(50, 172, 45, 0.97)", + "value": null + }, + { + "color": "rgba(237, 129, 40, 0.89)", + "value": 1000 + }, + { + "color": "rgba(245, 54, 54, 0.9)", + "value": 1500 + } + ] + } + }, + { + "id": "custom.width", + "value": 59 + }, + { + "id": "decimals" + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "TCP_tw" + }, + "properties": [ + { + "id": "custom.cellOptions", + "value": { + "mode": "gradient", + "type": "color-background" + } + }, + { + "id": "thresholds", + "value": { + "mode": "absolute", + "steps": [ + { + "color": "rgba(50, 172, 45, 0.97)", + "value": null + }, + { + "color": "rgba(237, 129, 40, 0.89)", + "value": 5000 + }, + { + "color": "rgba(245, 54, 54, 0.9)", + "value": 20000 + } + ] + } + }, + { + "id": "custom.width", + "value": 69 + }, + { + "id": "decimals" + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "CPU" + }, + "properties": [ + { + "id": "custom.width", + "value": 63 + }, + { + "id": "decimals", + "value": 0 + }, + { + "id": "custom.cellOptions", + "value": { + "type": "color-text" + } + }, + { + "id": "color", + "value": { + "fixedColor": "blue", + "mode": "fixed" + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "IP" + }, + "properties": [ + { + "id": "custom.width", + "value": 111 + }, + { + "id": "custom.filterable", + "value": true + }, + { + "id": "custom.align", + "value": "left" + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "主机名" + }, + "properties": [ + { + "id": "custom.filterable", + "value": true + }, + { + "id": "custom.width" + }, + { + "id": "custom.align", + "value": "left" + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "健康值" + }, + "properties": [ + { + "id": "custom.width", + "value": 75 + }, + { + "id": "thresholds", + "value": { + "mode": "absolute", + "steps": [ + { + "color": "red", + "value": null + }, + { + "color": "orange", + "value": 80 + }, + { + "color": "green", + "value": 90 + } + ] + } + }, + { + "id": "color", + "value": { + "mode": "thresholds" + } + }, + { + "id": "custom.cellOptions", + "value": { + "mode": "gradient", + "type": "color-background" + } + } + ] + }, + { + "matcher": { + "id": "byRegexp", + "options": "/.*使用率.*/" + }, + "properties": [ + { + "id": "unit", + "value": "percent" + }, + { + "id": "custom.cellOptions", + "value": { + "mode": "gradient", + "type": "gauge" + } + }, + { + "id": "color", + "value": { + "mode": "continuous-GrYlRd" + } + }, + { + "id": "custom.width", + "value": 110 + } + ] + } + ] + }, + "gridPos": { + "h": 11, + "w": 24, + "x": 0, + "y": 1 + }, + "id": 198, + "options": { + "cellHeight": "sm", + "footer": { + "countRows": false, + "enablePagination": true, + "fields": [ + "Value #B", + "Value #C", + "Value #L", + "Value #H", + "Value #I", + "Value #M", + "Value #N", + "Value #J", + "Value #K" + ], + "reducer": [ + "sum" + ], + "show": false + }, + "showHeader": true, + "sortBy": [ + { + "desc": false, + "displayName": "健康值" + } + ] + }, + "pluginVersion": "11.5.0-80683", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "editorMode": "code", + "exemplar": false, + "expr": "node_uname_info{origin_prometheus=~\"$origin_prometheus\",job=~\"$job\"} - 0", + "format": "table", + "hide": false, + "instant": true, + "interval": "", + "legendFormat": "主机名", + "refId": "A" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "editorMode": "code", + "exemplar": false, + "expr": "sum(time() - node_boot_time_seconds{origin_prometheus=~\"$origin_prometheus\",job=~\"$job\"})by(instance)/86400", + "format": "table", + "hide": false, + "instant": true, + "interval": "", + "legendFormat": "运行时间", + "refId": "D" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "editorMode": "code", + "exemplar": false, + "expr": "node_memory_MemTotal_bytes{origin_prometheus=~\"$origin_prometheus\",job=~\"$job\"} - 0", + "format": "table", + "hide": false, + "instant": true, + "interval": "", + "legendFormat": "总内存", + "refId": "B" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "editorMode": "code", + "exemplar": false, + "expr": "count(node_cpu_seconds_total{origin_prometheus=~\"$origin_prometheus\",job=~\"$job\",mode='system'}) by (instance)", + "format": "table", + "hide": false, + "instant": true, + "interval": "", + "legendFormat": "总核数", + "refId": "C" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "editorMode": "code", + "exemplar": false, + "expr": "node_load5{origin_prometheus=~\"$origin_prometheus\",job=~\"$job\"}", + "format": "table", + "instant": true, + "interval": "", + "legendFormat": "5分钟负载", + "refId": "L" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "editorMode": "code", + "exemplar": false, + "expr": "(1 - avg(irate(node_cpu_seconds_total{origin_prometheus=~\"$origin_prometheus\",job=~\"$job\",mode=\"idle\"}[$interval])) by (instance)) * 100", + "format": "table", + "hide": false, + "instant": true, + "interval": "", + "legendFormat": "CPU使用率", + "refId": "F" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "editorMode": "code", + "exemplar": false, + "expr": "(1 - (node_memory_MemAvailable_bytes{origin_prometheus=~\"$origin_prometheus\",job=~\"$job\"} / (node_memory_MemTotal_bytes{origin_prometheus=~\"$origin_prometheus\",job=~\"$job\"})))* 100", + "format": "table", + "hide": false, + "instant": true, + "interval": "", + "legendFormat": "内存使用率", + "refId": "G" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "editorMode": "code", + "exemplar": false, + "expr": "max((node_filesystem_size_bytes{origin_prometheus=~\"$origin_prometheus\",job=~\"$job\",fstype=~\"ext.?|xfs\"}-node_filesystem_free_bytes{origin_prometheus=~\"$origin_prometheus\",job=~\"$job\",fstype=~\"ext.?|xfs\"}) *100/(node_filesystem_avail_bytes {origin_prometheus=~\"$origin_prometheus\",job=~\"$job\",fstype=~\"ext.?|xfs\"}+(node_filesystem_size_bytes{origin_prometheus=~\"$origin_prometheus\",job=~\"$job\",fstype=~\"ext.?|xfs\"}-node_filesystem_free_bytes{origin_prometheus=~\"$origin_prometheus\",job=~\"$job\",fstype=~\"ext.?|xfs\"})))by(instance)", + "format": "table", + "hide": false, + "instant": true, + "interval": "", + "legendFormat": "__auto", + "refId": "E" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "editorMode": "code", + "exemplar": false, + "expr": "max(irate(node_disk_read_bytes_total{origin_prometheus=~\"$origin_prometheus\",job=~\"$job\"}[$interval])) by (instance)", + "format": "table", + "hide": false, + "instant": true, + "interval": "", + "legendFormat": "最大读取", + "refId": "H" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "editorMode": "code", + "exemplar": false, + "expr": "max(irate(node_disk_written_bytes_total{origin_prometheus=~\"$origin_prometheus\",job=~\"$job\"}[$interval])) by (instance)", + "format": "table", + "hide": false, + "instant": true, + "interval": "", + "legendFormat": "最大写入", + "refId": "I" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "editorMode": "code", + "exemplar": false, + "expr": "node_netstat_Tcp_CurrEstab{origin_prometheus=~\"$origin_prometheus\",job=~\"$job\"} - 0", + "format": "table", + "hide": false, + "instant": true, + "interval": "", + "legendFormat": "连接数", + "refId": "M" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "editorMode": "code", + "exemplar": false, + "expr": "node_sockstat_TCP_tw{origin_prometheus=~\"$origin_prometheus\",job=~\"$job\"} - 0", + "format": "table", + "hide": false, + "instant": true, + "interval": "", + "legendFormat": "TIME_WAIT", + "refId": "N" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "editorMode": "code", + "exemplar": false, + "expr": "max(irate(node_network_receive_bytes_total{origin_prometheus=~\"$origin_prometheus\",job=~\"$job\"}[$interval])*8) by (instance)", + "format": "table", + "hide": false, + "instant": true, + "interval": "", + "legendFormat": "下载带宽", + "refId": "J" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "editorMode": "code", + "exemplar": false, + "expr": "max(irate(node_network_transmit_bytes_total{origin_prometheus=~\"$origin_prometheus\",job=~\"$job\"}[$interval])*8) by (instance)", + "format": "table", + "hide": false, + "instant": true, + "interval": "", + "legendFormat": "上传带宽", + "refId": "K" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "editorMode": "code", + "exemplar": false, + "expr": "((1-(1 - avg(irate(node_cpu_seconds_total{origin_prometheus=~\"$origin_prometheus\",job=~\"$job\",mode=\"idle\"}[$interval])) by (instance))^1.3)^(1/3)*0.5 + \r\n(1-(1 - avg(node_memory_MemAvailable_bytes{origin_prometheus=~\"$origin_prometheus\",job=~\"$job\"} / node_memory_MemTotal_bytes{origin_prometheus=~\"$origin_prometheus\",job=~\"$job\"})by (instance))^6)^(1/3)*0.3 + \r\n(1 - max(irate(node_disk_io_time_seconds_total{origin_prometheus=~\"$origin_prometheus\",job=~\"$job\"}[$interval]))by (instance)^1.1)^(1/2)*0.2)*100", + "format": "table", + "hide": false, + "instant": true, + "interval": "", + "legendFormat": "__auto", + "refId": "O" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "editorMode": "code", + "exemplar": false, + "expr": "max(irate(node_disk_io_time_seconds_total{origin_prometheus=~\"$origin_prometheus\",job=~\"$job\"}[$interval])) by (instance) *100", + "format": "table", + "hide": false, + "instant": true, + "interval": "", + "legendFormat": "IOutil使用率", + "refId": "P" + } + ], + "title": "服务器资源总览表【主机总数:$total】", + "transformations": [ + { + "id": "merge", + "options": { + "reducers": [] + } + }, + { + "id": "organize", + "options": { + "excludeByName": { + "exp": false, + "iid": false + }, + "includeByName": {}, + "indexByName": { + "Time": 20, + "Value #A": 36, + "Value #B": 7, + "Value #C": 8, + "Value #D": 4, + "Value #E": 13, + "Value #F": 10, + "Value #G": 11, + "Value #H": 14, + "Value #I": 15, + "Value #J": 18, + "Value #K": 19, + "Value #L": 9, + "Value #M": 16, + "Value #N": 17, + "Value #O": 6, + "Value #P": 12, + "__name__": 37, + "account": 21, + "cservice": 22, + "domainname": 23, + "exp": 5, + "group": 24, + "iaccount": 25, + "igroup": 26, + "iid": 3, + "iname": 27, + "instance": 2, + "job": 28, + "machine": 29, + "name": 1, + "nodename": 0, + "origin_prometheus": 30, + "region": 31, + "release": 32, + "sysname": 33, + "vendor": 34, + "version": 35 + }, + "renameByName": { + "Value #B": "内存", + "Value #C": "CPU", + "Value #D": "启动(天)", + "Value #E": "分区使用率*", + "Value #F": "CPU使用率", + "Value #G": "内存使用率", + "Value #H": "磁盘读取*", + "Value #I": "磁盘写入*", + "Value #J": "下载带宽*", + "Value #K": "上传带宽*", + "Value #L": "负载", + "Value #M": "连接数", + "Value #N": "TCP_tw", + "Value #O": "健康值", + "Value #P": "IOutil使用率*", + "exp": "到期日", + "iid": "实例ID", + "instance": "IP", + "name": "", + "nodename": "主机名" + } + } + }, + { + "id": "filterFieldsByName", + "options": { + "include": { + "names": [ + "主机名", + "IP", + "启动(天)", + "健康值", + "内存", + "CPU", + "负载", + "CPU使用率", + "内存使用率", + "IOutil使用率*", + "分区使用率*", + "磁盘读取*", + "磁盘写入*", + "连接数", + "TCP_tw", + "下载带宽*", + "上传带宽*" + ] + } + } + } + ], + "type": "table" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "description": "- P99:数据集按升序排列,第99分位置大的数据。(即升序排列后排在99%位置的数据)\n- 该表格需要在Prometheus增加记录规则(参考看板下载页)\n- 增加记录规则1小时后才会有展示的数据。\n- 时间范围[7d:1h]表示要查看过去 7 天内每小时的数据点。", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "align": "center", + "cellOptions": { + "type": "color-text" + }, + "inspect": false + }, + "mappings": [], + "max": 100, + "min": 0, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + } + }, + "overrides": [ + { + "matcher": { + "id": "byRegexp", + "options": "/.*%/" + }, + "properties": [ + { + "id": "unit", + "value": "percent" + }, + { + "id": "decimals", + "value": 1 + }, + { + "id": "custom.width", + "value": 72 + }, + { + "id": "color", + "value": { + "mode": "continuous-GrYlRd" + } + }, + { + "id": "custom.cellOptions", + "value": { + "type": "color-background" + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "IP" + }, + "properties": [ + { + "id": "custom.width", + "value": 91 + }, + { + "id": "mappings", + "value": [ + { + "options": { + "pattern": "/(.+):.+/", + "result": { + "index": 0, + "text": "$1" + } + }, + "type": "regex" + } + ] + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "P99内存使用率" + }, + "properties": [ + { + "id": "custom.width", + "value": 79 + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "P99CPU使用率" + }, + "properties": [ + { + "id": "custom.width", + "value": 101 + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "名称" + }, + "properties": [ + { + "id": "custom.width", + "value": 128 + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "主机名" + }, + "properties": [ + { + "id": "custom.width", + "value": 138 + } + ] + } + ] + }, + "gridPos": { + "h": 7, + "w": 6, + "x": 0, + "y": 12 + }, + "id": 200, + "options": { + "cellHeight": "sm", + "footer": { + "countRows": false, + "fields": "", + "reducer": [ + "sum" + ], + "show": false + }, + "showHeader": true, + "sortBy": [ + { + "desc": true, + "displayName": "P99内存%" + } + ] + }, + "pluginVersion": "11.5.0-80683", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "editorMode": "code", + "exemplar": false, + "expr": "node_uname_info{origin_prometheus=~\"$origin_prometheus\",job=~\"$job\"} - 0", + "format": "table", + "instant": true, + "interval": "", + "legendFormat": "主机名", + "refId": "A" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "editorMode": "code", + "exemplar": false, + "expr": "quantile_over_time(0.99, cpu:usage:rate1m{origin_prometheus=~\"$origin_prometheus\",job=~\"$job\"}[7d:1h])", + "format": "table", + "hide": false, + "instant": true, + "interval": "", + "legendFormat": "CPU使用率P99", + "refId": "B" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "editorMode": "code", + "exemplar": false, + "expr": "quantile_over_time(0.99, mem:usage:rate1m{origin_prometheus=~\"$origin_prometheus\",job=~\"$job\"}[7d:1h])", + "format": "table", + "hide": false, + "instant": true, + "interval": "", + "legendFormat": "内存使用率P99", + "refId": "C" + } + ], + "title": "最近7天P99资源使用率", + "transformations": [ + { + "id": "seriesToColumns", + "options": { + "byField": "instance" + } + }, + { + "id": "filterFieldsByName", + "options": { + "include": { + "pattern": "/^Value #[^A]|^instance$|^nodename$/" + } + } + }, + { + "id": "organize", + "options": { + "excludeByName": {}, + "includeByName": {}, + "indexByName": { + "Value #B": 2, + "Value #C": 3, + "instance": 1, + "nodename": 0 + }, + "renameByName": { + "Value #B": "P99CPU%", + "Value #C": "P99内存%", + "instance": "IP", + "name": "", + "name 1": "", + "nodename": "主机名" + } + } + } + ], + "type": "table" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "description": "", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "series", + "axisLabel": "总5分钟负载", + "axisPlacement": "auto", + "axisSoftMin": 0, + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 2, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "never", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "links": [], + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "none" + }, + "overrides": [ + { + "matcher": { + "id": "byName", + "options": "平均%" + }, + "properties": [ + { + "id": "unit", + "value": "percent" + }, + { + "id": "custom.axisLabel", + "value": "总平均使用率" + }, + { + "id": "custom.pointSize", + "value": 3 + }, + { + "id": "custom.lineWidth", + "value": 1 + }, + { + "id": "custom.showPoints", + "value": "always" + }, + { + "id": "custom.axisSoftMin" + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "核数" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "#C4162A", + "mode": "fixed" + } + }, + { + "id": "custom.pointSize", + "value": 3 + }, + { + "id": "custom.drawStyle", + "value": "points" + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "5m负载" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "orange", + "mode": "fixed" + } + } + ] + } + ] + }, + "gridPos": { + "h": 7, + "w": 6, + "x": 6, + "y": 12 + }, + "id": 191, + "maxDataPoints": 100, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "maxHeight": 600, + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "11.5.0-80683", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "editorMode": "code", + "exemplar": true, + "expr": "sum(node_load5{origin_prometheus=~\"$origin_prometheus\",job=~\"$job\"})", + "format": "time_series", + "hide": false, + "interval": "", + "intervalFactor": 1, + "legendFormat": "5m负载", + "range": true, + "refId": "A", + "step": 240 + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "editorMode": "code", + "exemplar": true, + "expr": "count(node_cpu_seconds_total{origin_prometheus=~\"$origin_prometheus\",job=~\"$job\",mode='system'})", + "format": "time_series", + "hide": false, + "instant": false, + "interval": "", + "intervalFactor": 1, + "legendFormat": "核数", + "refId": "B", + "step": 240 + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "editorMode": "code", + "exemplar": true, + "expr": "avg(1 - avg(irate(node_cpu_seconds_total{origin_prometheus=~\"$origin_prometheus\",job=~\"$job\",mode=\"idle\"}[$interval])) by (instance)) * 100", + "format": "time_series", + "hide": false, + "interval": "", + "intervalFactor": 1, + "legendFormat": "平均%", + "range": true, + "refId": "F", + "step": 240 + } + ], + "title": "整体总负载与整体平均CPU使用率", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "series", + "axisLabel": "总已用内存", + "axisPlacement": "auto", + "axisSoftMin": 0, + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 2, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "never", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "decimals": 0, + "links": [], + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "bytes" + }, + "overrides": [ + { + "matcher": { + "id": "byName", + "options": "总内存" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "#C4162A", + "mode": "fixed" + } + }, + { + "id": "custom.drawStyle", + "value": "points" + }, + { + "id": "custom.pointSize", + "value": 3 + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "平均%" + }, + "properties": [ + { + "id": "unit", + "value": "percent" + }, + { + "id": "decimals", + "value": 1 + }, + { + "id": "custom.axisLabel", + "value": "总平均使用率" + }, + { + "id": "custom.showPoints", + "value": "always" + }, + { + "id": "custom.lineWidth", + "value": 1 + }, + { + "id": "custom.pointSize", + "value": 3 + }, + { + "id": "custom.axisSoftMin" + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "总已用" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "orange", + "mode": "fixed" + } + } + ] + } + ] + }, + "gridPos": { + "h": 7, + "w": 6, + "x": 12, + "y": 12 + }, + "id": 195, + "maxDataPoints": 100, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "maxHeight": 600, + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "11.5.0-80683", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "editorMode": "code", + "exemplar": true, + "expr": "sum(node_memory_MemTotal_bytes{origin_prometheus=~\"$origin_prometheus\",job=~\"$job\"} - node_memory_MemAvailable_bytes{origin_prometheus=~\"$origin_prometheus\",job=~\"$job\"})", + "format": "time_series", + "hide": false, + "interval": "", + "intervalFactor": 1, + "legendFormat": "总已用", + "range": true, + "refId": "B", + "step": 4 + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "editorMode": "code", + "exemplar": true, + "expr": "sum(node_memory_MemTotal_bytes{origin_prometheus=~\"$origin_prometheus\",job=~\"$job\"})", + "format": "time_series", + "hide": false, + "instant": false, + "interval": "", + "intervalFactor": 1, + "legendFormat": "总内存", + "refId": "A", + "step": 4 + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "editorMode": "code", + "exemplar": true, + "expr": "(sum(node_memory_MemTotal_bytes{origin_prometheus=~\"$origin_prometheus\",job=~\"$job\"} - node_memory_MemAvailable_bytes{origin_prometheus=~\"$origin_prometheus\",job=~\"$job\"}) / sum(node_memory_MemTotal_bytes{origin_prometheus=~\"$origin_prometheus\",job=~\"$job\"}))*100", + "format": "time_series", + "hide": false, + "interval": "", + "intervalFactor": 1, + "legendFormat": "平均%", + "range": true, + "refId": "H" + } + ], + "title": "整体总内存与整体平均内存使用率", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "description": "", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "series", + "axisLabel": "总磁盘使用量", + "axisPlacement": "auto", + "axisSoftMin": 0, + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 2, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "never", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "links": [], + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "bytes" + }, + "overrides": [ + { + "matcher": { + "id": "byName", + "options": "平均%" + }, + "properties": [ + { + "id": "unit", + "value": "percent" + }, + { + "id": "decimals", + "value": 2 + }, + { + "id": "custom.axisLabel", + "value": "总平均使用率" + }, + { + "id": "custom.lineWidth", + "value": 1 + }, + { + "id": "custom.showPoints", + "value": "always" + }, + { + "id": "custom.pointSize", + "value": 3 + }, + { + "id": "custom.axisSoftMin" + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "总磁盘" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "#C4162A", + "mode": "fixed" + } + }, + { + "id": "custom.drawStyle", + "value": "points" + }, + { + "id": "custom.pointSize", + "value": 3 + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "使用量" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "orange", + "mode": "fixed" + } + } + ] + } + ] + }, + "gridPos": { + "h": 7, + "w": 6, + "x": 18, + "y": 12 + }, + "id": 197, + "maxDataPoints": 100, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "maxHeight": 600, + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "11.5.0-80683", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "editorMode": "code", + "exemplar": true, + "expr": "sum(avg(node_filesystem_size_bytes{origin_prometheus=~\"$origin_prometheus\",job=~\"$job\",fstype=~\"xfs|ext.*\"})by(device,instance)) - sum(avg(node_filesystem_free_bytes{origin_prometheus=~\"$origin_prometheus\",job=~\"$job\",fstype=~\"xfs|ext.*\"})by(device,instance))", + "format": "time_series", + "instant": false, + "interval": "", + "intervalFactor": 1, + "legendFormat": "使用量", + "refId": "C" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "editorMode": "code", + "exemplar": true, + "expr": "sum(avg(node_filesystem_size_bytes{origin_prometheus=~\"$origin_prometheus\",job=~\"$job\",fstype=~\"xfs|ext.*\"})by(device,instance))", + "format": "time_series", + "instant": false, + "interval": "", + "intervalFactor": 1, + "legendFormat": "总磁盘", + "refId": "E" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "editorMode": "code", + "exemplar": true, + "expr": "(sum(avg(node_filesystem_size_bytes{origin_prometheus=~\"$origin_prometheus\",job=~\"$job\",fstype=~\"xfs|ext.*\"})by(device,instance)) - sum(avg(node_filesystem_free_bytes{origin_prometheus=~\"$origin_prometheus\",job=~\"$job\",fstype=~\"xfs|ext.*\"})by(device,instance))) *100/(sum(avg(node_filesystem_avail_bytes{origin_prometheus=~\"$origin_prometheus\",job=~\"$job\",fstype=~\"xfs|ext.*\"})by(device,instance))+(sum(avg(node_filesystem_size_bytes{origin_prometheus=~\"$origin_prometheus\",job=~\"$job\",fstype=~\"xfs|ext.*\"})by(device,instance)) - sum(avg(node_filesystem_free_bytes{origin_prometheus=~\"$origin_prometheus\",job=~\"$job\",fstype=~\"xfs|ext.*\"})by(device,instance))))", + "format": "time_series", + "instant": false, + "interval": "", + "intervalFactor": 1, + "legendFormat": "平均%", + "refId": "A" + } + ], + "title": "整体总磁盘与整体平均磁盘使用率", + "type": "timeseries" + }, + { + "collapsed": false, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 19 + }, + "id": 189, + "panels": [], + "title": "🧮资源明细:【$show_name】【$instance】", + "type": "row" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "description": "本看板中的:磁盘总量、使用量、可用量、使用率保持和df命令的Size、Used、Avail、Use% 列的值一致,并且Use%的值会四舍五入保留一位小数,会更加准确。\n\n注:df中Use%算法为:(size - free) * 100 / (avail + (size - free)),结果是整除则为该值,非整除则为该值+1,结果的单位是%。\n参考df命令源码:", + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "custom": { + "align": "center", + "cellOptions": { + "type": "auto" + }, + "inspect": false + }, + "displayName": "", + "mappings": [], + "thresholds": { + "mode": "percentage", + "steps": [ + { + "color": "green" + } + ] + }, + "unit": "none" + }, + "overrides": [ + { + "matcher": { + "id": "byName", + "options": "分区" + }, + "properties": [ + { + "id": "custom.width", + "value": 81 + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "剩余空间" + }, + "properties": [ + { + "id": "unit", + "value": "bytes" + }, + { + "id": "decimals" + }, + { + "id": "custom.cellOptions", + "value": { + "type": "color-text" + } + }, + { + "id": "thresholds", + "value": { + "mode": "absolute", + "steps": [ + { + "color": "red" + }, + { + "color": "orange", + "value": 10000000000 + }, + { + "color": "green", + "value": 20000000000 + } + ] + } + }, + { + "id": "custom.width", + "value": 72 + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "使用率" + }, + "properties": [ + { + "id": "unit", + "value": "percent" + }, + { + "id": "decimals", + "value": 0 + }, + { + "id": "custom.cellOptions", + "value": { + "mode": "gradient", + "type": "gauge" + } + }, + { + "id": "custom.width", + "value": 115 + }, + { + "id": "min", + "value": 0 + }, + { + "id": "max", + "value": 100 + }, + { + "id": "color", + "value": { + "mode": "continuous-GrYlRd" + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "总空间" + }, + "properties": [ + { + "id": "unit", + "value": "bytes" + }, + { + "id": "custom.width", + "value": 75 + }, + { + "id": "color", + "value": { + "fixedColor": "blue", + "mode": "fixed" + } + }, + { + "id": "custom.cellOptions", + "value": { + "type": "color-text" + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "类型" + }, + "properties": [ + { + "id": "custom.width", + "value": 51 + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "设备名" + }, + "properties": [ + { + "id": "custom.width", + "value": 120 + } + ] + } + ] + }, + "gridPos": { + "h": 6, + "w": 8, + "x": 0, + "y": 20 + }, + "id": 181, + "links": [ + { + "targetBlank": true, + "title": "https://github.com/coreutils/coreutils/blob/master/src/df.c", + "url": "https://github.com/coreutils/coreutils/blob/master/src/df.c" + } + ], + "options": { + "cellHeight": "sm", + "footer": { + "countRows": false, + "fields": "", + "reducer": [ + "sum" + ], + "show": false + }, + "showHeader": true, + "sortBy": [ + { + "desc": true, + "displayName": "使用率" + } + ] + }, + "pluginVersion": "11.5.0-80683", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "editorMode": "code", + "exemplar": false, + "expr": "node_filesystem_size_bytes{instance=~\"$instance\",fstype=~\"ext.*|xfs|nfs\",mountpoint !~\".*pod.*\"}-0", + "format": "table", + "hide": false, + "instant": true, + "interval": "", + "intervalFactor": 1, + "legendFormat": "总量", + "refId": "C" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "editorMode": "code", + "exemplar": false, + "expr": "node_filesystem_avail_bytes {instance=~\"$instance\",fstype=~\"ext.*|xfs|nfs\",mountpoint !~\".*pod.*\"}-0", + "format": "table", + "hide": false, + "instant": true, + "interval": "10s", + "intervalFactor": 1, + "legendFormat": "", + "refId": "A" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "exemplar": false, + "expr": "(node_filesystem_size_bytes{instance=~\"$instance\",fstype=~\"ext.*|xfs|nfs\",mountpoint !~\".*pod.*\"}-node_filesystem_free_bytes{instance=~\"$instance\",fstype=~\"ext.*|xfs|nfs\",mountpoint !~\".*pod.*\"}) *100/(node_filesystem_avail_bytes {instance=~\"$instance\",fstype=~\"ext.*|xfs|nfs\",mountpoint !~\".*pod.*\"}+(node_filesystem_size_bytes{instance=~\"$instance\",fstype=~\"ext.*|xfs|nfs\",mountpoint !~\".*pod.*\"}-node_filesystem_free_bytes{instance=~\"$instance\",fstype=~\"ext.*|xfs|nfs\",mountpoint !~\".*pod.*\"}))", + "format": "table", + "hide": false, + "instant": true, + "interval": "", + "intervalFactor": 1, + "legendFormat": "", + "refId": "B" + } + ], + "title": "【$show_name】:分区可用空间(EXT.*/XFS/NFS)", + "transformations": [ + { + "id": "merge", + "options": { + "reducers": [] + } + }, + { + "id": "filterFieldsByName", + "options": { + "include": { + "names": [ + "device", + "fstype", + "mountpoint", + "Value #C", + "Value #A", + "Value #B" + ] + } + } + }, + { + "id": "organize", + "options": { + "excludeByName": {}, + "indexByName": {}, + "renameByName": { + "Value #A": "剩余空间", + "Value #B": "使用率", + "Value #C": "总空间", + "device": "设备名", + "fstype": "类型", + "mountpoint": "分区" + } + } + } + ], + "type": "table" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "decimals": 1, + "mappings": [ + { + "options": { + "0": { + "text": "N/A" + } + }, + "type": "value" + } + ], + "max": 100, + "min": 0.1, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "#EAB839", + "value": 70 + }, + { + "color": "red", + "value": 90 + } + ] + }, + "unit": "percent" + }, + "overrides": [] + }, + "gridPos": { + "h": 6, + "w": 4, + "x": 8, + "y": 20 + }, + "id": 177, + "options": { + "displayMode": "lcd", + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": false + }, + "maxVizHeight": 300, + "minVizHeight": 45, + "minVizWidth": 0, + "namePlacement": "auto", + "orientation": "horizontal", + "reduceOptions": { + "calcs": [ + "last" + ], + "fields": "", + "values": false + }, + "showUnfilled": true, + "sizing": "auto", + "valueMode": "color" + }, + "pluginVersion": "11.5.0-80683", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "exemplar": false, + "expr": "100 - (avg(irate(node_cpu_seconds_total{instance=~\"$instance\",mode=\"idle\"}[$interval])) * 100)", + "instant": true, + "interval": "", + "legendFormat": "总CPU使用率", + "refId": "A" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "editorMode": "code", + "exemplar": false, + "expr": "avg(irate(node_cpu_seconds_total{instance=~\"$instance\",mode=\"iowait\"}[$interval])) * 100", + "hide": true, + "instant": true, + "interval": "", + "legendFormat": "IOwait使用率", + "refId": "C" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "exemplar": false, + "expr": "(1 - (node_memory_MemAvailable_bytes{instance=~\"$instance\"} / (node_memory_MemTotal_bytes{instance=~\"$instance\"})))* 100", + "instant": true, + "interval": "", + "legendFormat": "内存使用率", + "refId": "B" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "editorMode": "code", + "exemplar": false, + "expr": "(node_filesystem_size_bytes{instance=~\"$instance\",fstype=~\"ext.*|xfs\",mountpoint=\"$maxmount\"}-node_filesystem_free_bytes{instance=~\"$instance\",fstype=~\"ext.*|xfs\",mountpoint=\"$maxmount\"})*100 /(node_filesystem_avail_bytes {instance=~\"$instance\",fstype=~\"ext.*|xfs\",mountpoint=\"$maxmount\"}+(node_filesystem_size_bytes{instance=~\"$instance\",fstype=~\"ext.*|xfs\",mountpoint=\"$maxmount\"}-node_filesystem_free_bytes{instance=~\"$instance\",fstype=~\"ext.*|xfs\",mountpoint=\"$maxmount\"}))", + "hide": false, + "instant": true, + "interval": "", + "legendFormat": "最大分区使用率({{mountpoint}})", + "refId": "D" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "editorMode": "code", + "exemplar": false, + "expr": "(1 - ((node_memory_SwapFree_bytes{instance=~\"$instance\"} + 1)/ (node_memory_SwapTotal_bytes{instance=~\"$instance\"} + 1))) * 100", + "instant": true, + "interval": "", + "legendFormat": "交换分区使用率", + "refId": "F" + } + ], + "type": "bargauge" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + } + ] + }, + "unit": "none" + }, + "overrides": [ + { + "matcher": { + "id": "byName", + "options": "运行时间" + }, + "properties": [ + { + "id": "thresholds", + "value": { + "mode": "absolute", + "steps": [ + { + "color": "red" + }, + { + "color": "orange", + "value": 3600 + }, + { + "color": "green", + "value": 7200 + } + ] + } + }, + { + "id": "unit", + "value": "s" + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "总内存" + }, + "properties": [ + { + "id": "unit", + "value": "bytes" + }, + { + "id": "decimals", + "value": 0 + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "CPU iowait" + }, + "properties": [ + { + "id": "unit", + "value": "percent" + }, + { + "id": "thresholds", + "value": { + "mode": "percentage", + "steps": [ + { + "color": "green" + }, + { + "color": "orange", + "value": 40 + }, + { + "color": "red", + "value": 60 + } + ] + } + }, + { + "id": "decimals", + "value": 2 + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "总文件描述符" + }, + "properties": [ + { + "id": "unit", + "value": "short" + }, + { + "id": "thresholds", + "value": { + "mode": "absolute", + "steps": [ + { + "color": "red" + }, + { + "color": "orange", + "value": 50000 + }, + { + "color": "green", + "value": 200000 + } + ] + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "最大打开文件" + }, + "properties": [ + { + "id": "unit", + "value": "none" + }, + { + "id": "thresholds", + "value": { + "mode": "absolute", + "steps": [ + { + "color": "red" + }, + { + "color": "orange", + "value": 10000 + }, + { + "color": "green", + "value": 50000 + } + ] + } + } + ] + } + ] + }, + "gridPos": { + "h": 6, + "w": 4, + "x": 12, + "y": 20 + }, + "id": 206, + "interval": "15s", + "options": { + "colorMode": "background", + "graphMode": "none", + "justifyMode": "center", + "orientation": "auto", + "percentChangeColorMode": "standard", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + }, + "showPercentChange": false, + "text": { + "valueSize": 15 + }, + "textMode": "auto", + "wideLayout": true + }, + "pluginVersion": "11.5.0-80683", + "targets": [ + { + "alias": "", + "bucketAggs": [ + { + "id": "2", + "settings": { + "interval": "auto" + }, + "type": "date_histogram" + } + ], + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "exemplar": false, + "expr": "avg(time() - node_boot_time_seconds{instance=~\"$instance\"})", + "hide": false, + "instant": true, + "interval": "", + "legendFormat": "运行时间", + "metrics": [ + { + "id": "1", + "type": "count" + } + ], + "query": "", + "refId": "C", + "timeField": "@timestamp" + }, + { + "alias": "", + "bucketAggs": [ + { + "id": "2", + "settings": { + "interval": "auto" + }, + "type": "date_histogram" + } + ], + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "exemplar": false, + "expr": "count(node_cpu_seconds_total{instance=~\"$instance\", mode='system'})", + "instant": true, + "interval": "", + "legendFormat": "CPU 核数", + "metrics": [ + { + "id": "1", + "type": "count" + } + ], + "query": "", + "refId": "A", + "timeField": "@timestamp" + }, + { + "alias": "", + "bucketAggs": [ + { + "id": "2", + "settings": { + "interval": "auto" + }, + "type": "date_histogram" + } + ], + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "exemplar": false, + "expr": "sum(node_memory_MemTotal_bytes{instance=~\"$instance\"})", + "hide": false, + "instant": true, + "interval": "", + "legendFormat": "总内存", + "metrics": [ + { + "id": "1", + "type": "count" + } + ], + "query": "", + "refId": "B", + "timeField": "@timestamp" + }, + { + "alias": "", + "bucketAggs": [ + { + "id": "2", + "settings": { + "interval": "auto" + }, + "type": "date_histogram" + } + ], + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "exemplar": false, + "expr": "avg(irate(node_cpu_seconds_total{instance=~\"$instance\",mode=\"iowait\"}[$interval])) * 100", + "hide": false, + "instant": true, + "interval": "", + "legendFormat": "CPU iowait", + "metrics": [ + { + "id": "1", + "type": "count" + } + ], + "query": "", + "refId": "D", + "timeField": "@timestamp" + }, + { + "alias": "", + "bucketAggs": [ + { + "id": "2", + "settings": { + "interval": "auto" + }, + "type": "date_histogram" + } + ], + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "exemplar": false, + "expr": "node_filefd_maximum{instance=~\"$instance\"}", + "hide": false, + "instant": true, + "interval": "", + "legendFormat": "总文件描述符", + "metrics": [ + { + "id": "1", + "type": "count" + } + ], + "query": "", + "refId": "E", + "timeField": "@timestamp" + }, + { + "alias": "", + "bucketAggs": [ + { + "id": "2", + "settings": { + "interval": "auto" + }, + "type": "date_histogram" + } + ], + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "editorMode": "code", + "exemplar": false, + "expr": "process_max_fds{job=\"node_exporter\",instance=~\"$instance\"}", + "hide": false, + "instant": true, + "interval": "", + "legendFormat": "最大打开文件", + "metrics": [ + { + "id": "1", + "type": "count" + } + ], + "query": "", + "refId": "F", + "timeField": "@timestamp" + } + ], + "type": "stat" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "bars", + "fillOpacity": 60, + "gradientMode": "opacity", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 2, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "never", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "links": [], + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "bytes" + }, + "overrides": [ + { + "matcher": { + "id": "byName", + "options": "cn-shenzhen.i-wz9cq1dcb6zwc39ehw59_cni0_in" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "light-red", + "mode": "fixed" + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "cn-shenzhen.i-wz9cq1dcb6zwc39ehw59_cni0_in下载" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "green", + "mode": "fixed" + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "cn-shenzhen.i-wz9cq1dcb6zwc39ehw59_cni0_out上传" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "yellow", + "mode": "fixed" + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "cn-shenzhen.i-wz9cq1dcb6zwc39ehw59_eth0_in下载" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "purple", + "mode": "fixed" + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "cn-shenzhen.i-wz9cq1dcb6zwc39ehw59_eth0_out" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "purple", + "mode": "fixed" + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "cn-shenzhen.i-wz9cq1dcb6zwc39ehw59_eth0_out上传" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "blue", + "mode": "fixed" + } + } + ] + } + ] + }, + "gridPos": { + "h": 6, + "w": 8, + "x": 16, + "y": 20 + }, + "id": 183, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "maxHeight": 600, + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "11.5.0-80683", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "exemplar": true, + "expr": "increase(node_network_receive_bytes_total{instance=~\"$instance\",device=~\"$device\"}[1m])", + "interval": "1m", + "intervalFactor": 2, + "legendFormat": "{{device}}_in下载", + "metric": "", + "refId": "A", + "step": 600, + "target": "" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "exemplar": true, + "expr": "increase(node_network_transmit_bytes_total{instance=~\"$instance\",device=~\"$device\"}[1m])", + "hide": false, + "interval": "1m", + "intervalFactor": 2, + "legendFormat": "{{device}}_out上传", + "refId": "B", + "step": 600 + } + ], + "title": "每分钟流量$device", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "description": "", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "series", + "axisLabel": "总使用率", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "never", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "decimals": 0, + "links": [], + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "percent" + }, + "overrides": [ + { + "matcher": { + "id": "byRegexp", + "options": "/.*总使用率/" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "dark-red", + "mode": "fixed" + } + }, + { + "id": "custom.fillOpacity", + "value": 0 + }, + { + "id": "custom.lineWidth", + "value": 2 + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "磁盘IO使用率" + }, + "properties": [ + { + "id": "custom.axisPlacement", + "value": "right" + }, + { + "id": "custom.axisLabel", + "value": "磁盘IO使用率" + }, + { + "id": "color", + "value": { + "fixedColor": "#0ad4ff", + "mode": "fixed" + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "用户使用率" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "yellow", + "mode": "fixed" + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "系统使用率" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "green", + "mode": "fixed" + } + } + ] + } + ] + }, + "gridPos": { + "h": 8, + "w": 8, + "x": 0, + "y": 26 + }, + "id": 207, + "options": { + "legend": { + "calcs": [ + "mean", + "lastNotNull", + "max" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true, + "sortBy": "Max", + "sortDesc": true + }, + "tooltip": { + "maxHeight": 600, + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "11.5.0-80683", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "expr": "(1 - avg(irate(node_cpu_seconds_total{instance=~\"$instance\",mode=\"idle\"}[$interval])) by (instance))*100", + "format": "time_series", + "hide": false, + "interval": "", + "intervalFactor": 1, + "legendFormat": "总使用率", + "refId": "F", + "step": 240 + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "editorMode": "code", + "expr": "avg(irate(node_cpu_seconds_total{instance=~\"$instance\",mode=\"system\"}[$interval])) by (instance) *100", + "format": "time_series", + "hide": false, + "instant": false, + "interval": "", + "intervalFactor": 1, + "legendFormat": "系统使用率", + "refId": "A", + "step": 20 + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "expr": "avg(irate(node_cpu_seconds_total{instance=~\"$instance\",mode=\"user\"}[$interval])) by (instance) *100", + "format": "time_series", + "hide": false, + "interval": "", + "intervalFactor": 1, + "legendFormat": "用户使用率", + "refId": "B", + "step": 240 + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "expr": "avg(irate(node_cpu_seconds_total{instance=~\"$instance\",mode=\"iowait\"}[$interval])) by (instance) *100", + "format": "time_series", + "hide": false, + "instant": false, + "interval": "", + "intervalFactor": 1, + "legendFormat": "磁盘IO使用率", + "refId": "D", + "step": 240 + } + ], + "title": "CPU使用率", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "series", + "axisLabel": "剩余内存", + "axisPlacement": "left", + "axisSoftMin": 0, + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "never", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "links": [], + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "bytes" + }, + "overrides": [ + { + "matcher": { + "id": "byName", + "options": "可用" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "#9ac48a", + "mode": "fixed" + } + }, + { + "id": "custom.lineWidth", + "value": 2 + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "总内存" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "#C4162A", + "mode": "fixed" + } + }, + { + "id": "custom.lineWidth", + "value": 1 + }, + { + "id": "custom.pointSize", + "value": 3 + }, + { + "id": "custom.showPoints", + "value": "always" + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "使用率" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "#00d1ff", + "mode": "fixed" + } + }, + { + "id": "custom.lineWidth", + "value": 1 + }, + { + "id": "unit", + "value": "percent" + }, + { + "id": "custom.axisLabel", + "value": "内存使用率" + }, + { + "id": "custom.pointSize", + "value": 3 + }, + { + "id": "custom.showPoints", + "value": "always" + }, + { + "id": "custom.axisPlacement", + "value": "right" + }, + { + "id": "custom.axisSoftMin" + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "已用" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "orange", + "mode": "fixed" + } + } + ] + } + ] + }, + "gridPos": { + "h": 8, + "w": 8, + "x": 8, + "y": 26 + }, + "id": 156, + "options": { + "legend": { + "calcs": [ + "mean", + "lastNotNull", + "max" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true, + "sortBy": "Max", + "sortDesc": true + }, + "tooltip": { + "maxHeight": 600, + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "11.5.0-80683", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "expr": "node_memory_MemAvailable_bytes{instance=~\"$instance\"}", + "format": "time_series", + "hide": false, + "interval": "", + "intervalFactor": 1, + "legendFormat": "可用", + "refId": "F", + "step": 4 + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "exemplar": true, + "expr": "node_memory_MemTotal_bytes{instance=~\"$instance\"}", + "format": "time_series", + "hide": false, + "instant": false, + "interval": "2m", + "intervalFactor": 1, + "legendFormat": "总内存", + "refId": "A", + "step": 4 + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "expr": "node_memory_MemTotal_bytes{instance=~\"$instance\"} - node_memory_MemAvailable_bytes{instance=~\"$instance\"}", + "format": "time_series", + "hide": false, + "interval": "", + "intervalFactor": 1, + "legendFormat": "已用", + "refId": "B", + "step": 4 + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "exemplar": true, + "expr": "(1 - (node_memory_MemAvailable_bytes{instance=~\"$instance\"} / (node_memory_MemTotal_bytes{instance=~\"$instance\"})))* 100", + "format": "time_series", + "hide": false, + "interval": "", + "intervalFactor": 1, + "legendFormat": "使用率", + "refId": "H" + } + ], + "title": "内存信息", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "description": "", + "fieldConfig": { + "defaults": { + "color": { + "mode": "continuous-GrYlRd" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "series", + "axisLabel": "容量使用率", + "axisPlacement": "auto", + "axisSoftMax": 100, + "axisSoftMin": 0, + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 2, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "never", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "links": [], + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "percent" + }, + "overrides": [ + { + "matcher": { + "id": "byRegexp", + "options": "/Inodes.*/" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "#00d1ff", + "mode": "fixed" + } + }, + { + "id": "custom.lineWidth", + "value": 0 + }, + { + "id": "custom.showPoints", + "value": "always" + }, + { + "id": "custom.pointSize", + "value": 3 + }, + { + "id": "custom.axisLabel", + "value": "Inodes使用率" + } + ] + } + ] + }, + "gridPos": { + "h": 8, + "w": 8, + "x": 16, + "y": 26 + }, + "id": 174, + "options": { + "legend": { + "calcs": [ + "mean", + "lastNotNull", + "max" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "maxHeight": 600, + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "11.5.0-80683", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "editorMode": "code", + "exemplar": true, + "expr": "(node_filesystem_size_bytes{instance=~\"$instance\",fstype=~\"ext.*|xfs|nfs\",mountpoint !~\".*pod.*\"}-node_filesystem_free_bytes{instance=~\"$instance\",fstype=~\"ext.*|xfs|nfs\",mountpoint !~\".*pod.*\"}) *100/(node_filesystem_avail_bytes {instance=~\"$instance\",fstype=~\"ext.*|xfs|nfs\",mountpoint !~\".*pod.*\"}+(node_filesystem_size_bytes{instance=~\"$instance\",fstype=~\"ext.*|xfs|nfs\",mountpoint !~\".*pod.*\"}-node_filesystem_free_bytes{instance=~\"$instance\",fstype=~\"ext.*|xfs|nfs\",mountpoint !~\".*pod.*\"}))", + "format": "time_series", + "instant": false, + "interval": "", + "intervalFactor": 1, + "legendFormat": "容量%:{{mountpoint}}", + "refId": "A" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "editorMode": "code", + "exemplar": true, + "expr": "(1 - node_filesystem_files_free{instance=~\"$instance\",fstype=~\"ext.?|xfs|nfs\",mountpoint !~\".*pod.*\"} / node_filesystem_files{instance=~\"$instance\",fstype=~\"ext.?|xfs|nfs\",mountpoint !~\".*pod.*\"}) * 100", + "hide": false, + "interval": "", + "legendFormat": "Inodes%:{{mountpoint}}", + "range": true, + "refId": "B" + } + ], + "title": "磁盘使用率", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "series", + "axisLabel": "1分钟负载", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "never", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "links": [], + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "none" + }, + "overrides": [ + { + "matcher": { + "id": "byName", + "options": "15分钟负载" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "purple", + "mode": "fixed" + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "1分钟负载" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "orange", + "mode": "fixed" + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "5分钟负载" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "blue", + "mode": "fixed" + } + } + ] + }, + { + "matcher": { + "id": "byRegexp", + "options": "/.*总核数/" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "#C4162A", + "mode": "fixed" + } + }, + { + "id": "custom.lineWidth", + "value": 1 + }, + { + "id": "custom.pointSize", + "value": 4 + }, + { + "id": "custom.showPoints", + "value": "always" + } + ] + } + ] + }, + "gridPos": { + "h": 8, + "w": 8, + "x": 0, + "y": 34 + }, + "id": 13, + "options": { + "legend": { + "calcs": [ + "mean", + "lastNotNull", + "max" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "maxHeight": 600, + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "11.5.0-80683", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "exemplar": true, + "expr": "node_load1{instance=~\"$instance\"}", + "format": "time_series", + "instant": false, + "interval": "", + "intervalFactor": 1, + "legendFormat": "1分钟负载", + "metric": "", + "refId": "A", + "step": 20, + "target": "" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "exemplar": true, + "expr": " sum(count(node_cpu_seconds_total{instance=~\"$instance\", mode='system'}) by (cpu,instance)) by(instance)", + "format": "time_series", + "instant": false, + "interval": "2m", + "intervalFactor": 1, + "legendFormat": "CPU总核数", + "refId": "D", + "step": 20 + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "expr": "node_load5{instance=~\"$instance\"}", + "format": "time_series", + "instant": false, + "interval": "", + "intervalFactor": 1, + "legendFormat": "5分钟负载", + "refId": "B", + "step": 20 + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "expr": "node_load15{instance=~\"$instance\"}", + "format": "time_series", + "instant": false, + "interval": "", + "intervalFactor": 1, + "legendFormat": "15分钟负载", + "refId": "C", + "step": 20 + } + ], + "title": "系统平均负载", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "bars", + "fillOpacity": 100, + "gradientMode": "opacity", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "never", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "normal" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "min": 0, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "none" + }, + "overrides": [ + { + "matcher": { + "id": "byName", + "options": "等待IO完成阻塞的进程" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "red", + "mode": "fixed" + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "运行态的进程" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "green", + "mode": "fixed" + } + } + ] + }, + { + "matcher": { + "id": "byValue", + "options": { + "op": "gte", + "reducer": "allIsZero", + "value": 0 + } + }, + "properties": [ + { + "id": "custom.hideFrom", + "value": { + "legend": true, + "tooltip": true, + "viz": false + } + } + ] + }, + { + "matcher": { + "id": "byValue", + "options": { + "op": "gte", + "reducer": "allIsNull", + "value": 0 + } + }, + "properties": [ + { + "id": "custom.hideFrom", + "value": { + "legend": true, + "tooltip": true, + "viz": false + } + } + ] + } + ] + }, + "gridPos": { + "h": 8, + "w": 8, + "x": 8, + "y": 34 + }, + "id": 202, + "options": { + "legend": { + "calcs": [ + "mean", + "lastNotNull", + "max" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "maxHeight": 600, + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "11.5.0-80683", + "targets": [ + { + "calculatedInterval": "2m", + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "datasourceErrors": {}, + "errors": {}, + "exemplar": true, + "expr": "node_procs_running{instance=~\"$instance\"}", + "format": "time_series", + "interval": "1m", + "intervalFactor": 1, + "legendFormat": "运行态的进程", + "metric": "", + "prometheusLink": "/api/datasources/proxy/1/graph#%5B%7B%22expr%22%3A%22node_procs_running%7Binstance%3D%5C%22%24host%5C%22%7D%22%2C%22range_input%22%3A%2243200s%22%2C%22end_input%22%3A%222015-9-18%2013%3A46%22%2C%22step_input%22%3A%22%22%2C%22stacked%22%3Atrue%2C%22tab%22%3A0%7D%5D", + "refId": "A", + "step": 5, + "target": "" + }, + { + "calculatedInterval": "2m", + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "datasourceErrors": {}, + "errors": {}, + "exemplar": true, + "expr": "node_procs_blocked{instance=~\"$instance\"}", + "format": "time_series", + "interval": "1m", + "intervalFactor": 1, + "legendFormat": "等待IO完成阻塞的进程", + "metric": "", + "prometheusLink": "/api/datasources/proxy/1/graph#%5B%7B%22expr%22%3A%22node_procs_blocked%7Binstance%3D%5C%22%24host%5C%22%7D%22%2C%22range_input%22%3A%2243200s%22%2C%22end_input%22%3A%222015-9-18%2013%3A46%22%2C%22step_input%22%3A%22%22%2C%22stacked%22%3Atrue%2C%22tab%22%3A0%7D%5D", + "refId": "B", + "step": 5, + "target": "" + } + ], + "title": "进程运行状态", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "description": "", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "series", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "opacity", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 2, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "never", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "links": [], + "mappings": [], + "min": 0, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "short" + }, + "overrides": [ + { + "matcher": { + "id": "byName", + "options": "总使用FD" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "red", + "mode": "fixed" + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "总使用FD占比" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "yellow", + "mode": "fixed" + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "每秒上下文切换" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "dark-blue", + "mode": "fixed" + } + } + ] + }, + { + "matcher": { + "id": "byRegexp", + "options": "/.*占比/" + }, + "properties": [ + { + "id": "custom.lineWidth", + "value": 0 + }, + { + "id": "unit", + "value": "percent" + }, + { + "id": "custom.showPoints", + "value": "always" + }, + { + "id": "custom.pointSize", + "value": 3 + }, + { + "id": "custom.axisSoftMax", + "value": 100 + }, + { + "id": "custom.axisSoftMin", + "value": 0 + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "进程使用FD占比" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "dark-orange", + "mode": "fixed" + } + } + ] + } + ] + }, + "gridPos": { + "h": 8, + "w": 8, + "x": 16, + "y": 34 + }, + "id": 16, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "maxHeight": 600, + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "11.5.0-80683", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "editorMode": "code", + "exemplar": true, + "expr": "irate(node_context_switches_total{instance=~\"$instance\"}[$interval])", + "interval": "", + "intervalFactor": 1, + "legendFormat": "每秒上下文切换", + "range": true, + "refId": "A" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "editorMode": "code", + "exemplar": true, + "expr": "node_filefd_allocated{instance=~\"$instance\"}", + "format": "time_series", + "instant": false, + "interval": "", + "intervalFactor": 1, + "legendFormat": "总使用FD", + "refId": "B" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "editorMode": "code", + "exemplar": true, + "expr": "(node_filefd_allocated{instance=~\"$instance\"}/node_filefd_maximum{instance=~\"$instance\"}) *100", + "format": "time_series", + "hide": false, + "instant": false, + "interval": "", + "intervalFactor": 1, + "legendFormat": "总使用FD占比", + "refId": "C" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "editorMode": "code", + "exemplar": true, + "expr": "(process_open_fds{instance=~\"$instance\"}/process_max_fds{instance=~\"$instance\"}) *100", + "format": "time_series", + "hide": false, + "instant": false, + "interval": "", + "intervalFactor": 1, + "legendFormat": "进程使用FD占比", + "refId": "D" + } + ], + "title": "文件描述符(FD)/每秒上下文切换", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "description": "Read time seconds 每个磁盘分区读操作花费的秒数\n\nWrite time seconds 每个磁盘分区写操作花费的秒数\n\nIO time seconds 每个磁盘分区输入/输出操作花费的秒数\n\nIO time weighted seconds每个磁盘分区输入/输出操作花费的加权秒数", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "读取(-)/写入(+)", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 10, + "gradientMode": "opacity", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "never", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "links": [], + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "s" + }, + "overrides": [ + { + "matcher": { + "id": "byName", + "options": "vda" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "#6ED0E0", + "mode": "fixed" + } + } + ] + }, + { + "matcher": { + "id": "byRegexp", + "options": "/,*_读取$/" + }, + "properties": [ + { + "id": "custom.transform", + "value": "negative-Y" + } + ] + }, + { + "matcher": { + "id": "byValue", + "options": { + "op": "gte", + "reducer": "allIsZero", + "value": 0 + } + }, + "properties": [ + { + "id": "custom.hideFrom", + "value": { + "legend": true, + "tooltip": true, + "viz": false + } + } + ] + }, + { + "matcher": { + "id": "byValue", + "options": { + "op": "gte", + "reducer": "allIsNull", + "value": 0 + } + }, + "properties": [ + { + "id": "custom.hideFrom", + "value": { + "legend": true, + "tooltip": true, + "viz": false + } + } + ] + } + ] + }, + "gridPos": { + "h": 8, + "w": 6, + "x": 0, + "y": 42 + }, + "id": 160, + "options": { + "legend": { + "calcs": [ + "mean", + "lastNotNull", + "max" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "maxHeight": 600, + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "11.5.0-80683", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "expr": "irate(node_disk_read_time_seconds_total{instance=~\"$instance\"}[$interval]) / irate(node_disk_reads_completed_total{instance=~\"$instance\"}[$interval])", + "format": "time_series", + "hide": false, + "instant": false, + "interval": "", + "intervalFactor": 1, + "legendFormat": "{{device}}_读取", + "refId": "B" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "expr": "irate(node_disk_write_time_seconds_total{instance=~\"$instance\"}[$interval]) / irate(node_disk_writes_completed_total{instance=~\"$instance\"}[$interval])", + "format": "time_series", + "hide": false, + "instant": false, + "interval": "", + "intervalFactor": 1, + "legendFormat": "{{device}}_写入", + "refId": "C" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "expr": "irate(node_disk_io_time_seconds_total{instance=~\"$instance\"}[$interval])", + "format": "time_series", + "hide": true, + "interval": "", + "intervalFactor": 1, + "legendFormat": "{{device}}", + "refId": "A", + "step": 10 + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "expr": "irate(node_disk_io_time_weighted_seconds_total{instance=~\"$instance\"}[$interval])", + "format": "time_series", + "hide": true, + "interval": "", + "intervalFactor": 1, + "legendFormat": "{{device}}_加权", + "refId": "D" + } + ], + "title": "每次IO读写的耗时(参考:小于100ms)", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "description": "Reads completed: 每个磁盘分区每秒读完成次数\n\nWrites completed: 每个磁盘分区每秒写完成次数\n\nIO now 每个磁盘分区每秒正在处理的输入/输出请求数", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "读取(-)/写入(+)I/O ops/sec", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "never", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "links": [], + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "none" + }, + "overrides": [ + { + "matcher": { + "id": "byName", + "options": "vda_write" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "#6ED0E0", + "mode": "fixed" + } + } + ] + }, + { + "matcher": { + "id": "byRegexp", + "options": "/.*_读取$/" + }, + "properties": [ + { + "id": "custom.transform", + "value": "negative-Y" + } + ] + }, + { + "matcher": { + "id": "byValue", + "options": { + "op": "gte", + "reducer": "allIsZero", + "value": 0 + } + }, + "properties": [ + { + "id": "custom.hideFrom", + "value": { + "legend": true, + "tooltip": true, + "viz": false + } + } + ] + }, + { + "matcher": { + "id": "byValue", + "options": { + "op": "gte", + "reducer": "allIsNull", + "value": 0 + } + }, + "properties": [ + { + "id": "custom.hideFrom", + "value": { + "legend": true, + "tooltip": true, + "viz": false + } + } + ] + } + ] + }, + "gridPos": { + "h": 8, + "w": 6, + "x": 6, + "y": 42 + }, + "id": 161, + "options": { + "legend": { + "calcs": [ + "mean", + "lastNotNull", + "max" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "maxHeight": 600, + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "11.5.0-80683", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "expr": "irate(node_disk_reads_completed_total{instance=~\"$instance\"}[$interval])", + "format": "time_series", + "hide": false, + "interval": "", + "intervalFactor": 1, + "legendFormat": "{{device}}_读取", + "refId": "A", + "step": 10 + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "expr": "irate(node_disk_writes_completed_total{instance=~\"$instance\"}[$interval])", + "format": "time_series", + "hide": false, + "interval": "", + "intervalFactor": 1, + "legendFormat": "{{device}}_写入", + "refId": "B", + "step": 10 + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "expr": "node_disk_io_now{instance=~\"$instance\"}", + "format": "time_series", + "hide": true, + "interval": "", + "intervalFactor": 1, + "legendFormat": "{{device}}", + "refId": "C" + } + ], + "title": "磁盘读写速率(IOPS)", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "description": "Read bytes 每个磁盘分区每秒读取的比特数\nWritten bytes 每个磁盘分区每秒写入的比特数", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "读取(-)/写入(+)", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "never", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "links": [], + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "Bps" + }, + "overrides": [ + { + "matcher": { + "id": "byName", + "options": "vda_write" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "#6ED0E0", + "mode": "fixed" + } + } + ] + }, + { + "matcher": { + "id": "byRegexp", + "options": "/.*_读取$/" + }, + "properties": [ + { + "id": "custom.transform", + "value": "negative-Y" + } + ] + }, + { + "matcher": { + "id": "byValue", + "options": { + "op": "gte", + "reducer": "allIsZero", + "value": 0 + } + }, + "properties": [ + { + "id": "custom.hideFrom", + "value": { + "legend": true, + "tooltip": true, + "viz": false + } + } + ] + }, + { + "matcher": { + "id": "byValue", + "options": { + "op": "gte", + "reducer": "allIsNull", + "value": 0 + } + }, + "properties": [ + { + "id": "custom.hideFrom", + "value": { + "legend": true, + "tooltip": true, + "viz": false + } + } + ] + } + ] + }, + "gridPos": { + "h": 8, + "w": 6, + "x": 12, + "y": 42 + }, + "id": 168, + "options": { + "legend": { + "calcs": [ + "mean", + "lastNotNull", + "max" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "maxHeight": 600, + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "11.5.0-80683", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "expr": "irate(node_disk_read_bytes_total{instance=~\"$instance\"}[$interval])", + "format": "time_series", + "interval": "", + "intervalFactor": 1, + "legendFormat": "{{device}}_读取", + "refId": "A", + "step": 10 + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "expr": "irate(node_disk_written_bytes_total{instance=~\"$instance\"}[$interval])", + "format": "time_series", + "hide": false, + "interval": "", + "intervalFactor": 1, + "legendFormat": "{{device}}_写入", + "refId": "B", + "step": 10 + } + ], + "title": "每秒磁盘读写容量", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "description": "每一秒钟的自然时间内,花费在I/O上的耗时。(wall-clock time)\n\nnode_disk_io_time_seconds_total:\n磁盘花费在输入/输出操作上的秒数。该值为累加值。(Milliseconds Spent Doing I/Os)\n\nirate(node_disk_io_time_seconds_total[1m]):\n计算每秒的速率:(last值-last前一个值)/时间戳差值,即:1秒钟内磁盘花费在I/O操作的时间占比。", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 10, + "gradientMode": "opacity", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "never", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "links": [], + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "percentunit" + }, + "overrides": [ + { + "matcher": { + "id": "byName", + "options": "Idle - Waiting for something to happen" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "#052B51", + "mode": "fixed" + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "guest" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "#9AC48A", + "mode": "fixed" + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "idle" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "#052B51", + "mode": "fixed" + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "iowait" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "#EAB839", + "mode": "fixed" + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "irq" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "#BF1B00", + "mode": "fixed" + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "nice" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "#C15C17", + "mode": "fixed" + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "sdb_每秒I/O操作%" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "#d683ce", + "mode": "fixed" + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "softirq" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "#E24D42", + "mode": "fixed" + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "steal" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "#FCE2DE", + "mode": "fixed" + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "system" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "#508642", + "mode": "fixed" + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "user" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "#5195CE", + "mode": "fixed" + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "磁盘花费在I/O操作占比" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "#ba43a9", + "mode": "fixed" + } + } + ] + }, + { + "matcher": { + "id": "byValue", + "options": { + "op": "gte", + "reducer": "allIsZero", + "value": 0 + } + }, + "properties": [ + { + "id": "custom.hideFrom", + "value": { + "legend": true, + "tooltip": true, + "viz": false + } + } + ] + }, + { + "matcher": { + "id": "byValue", + "options": { + "op": "gte", + "reducer": "allIsNull", + "value": 0 + } + }, + "properties": [ + { + "id": "custom.hideFrom", + "value": { + "legend": true, + "tooltip": true, + "viz": false + } + } + ] + } + ] + }, + "gridPos": { + "h": 8, + "w": 6, + "x": 18, + "y": 42 + }, + "id": 175, + "options": { + "legend": { + "calcs": [ + "mean", + "lastNotNull", + "max" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "maxHeight": 600, + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "11.5.0-80683", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "exemplar": true, + "expr": "irate(node_disk_io_time_seconds_total{instance=~\"$instance\"}[$interval])", + "format": "time_series", + "interval": "", + "intervalFactor": 1, + "legendFormat": "{{device}}_每秒I/O操作%", + "refId": "C" + } + ], + "title": "每1秒内I/O操作耗时占比(I/O Util)", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "description": "Sockets_used - 已使用的所有协议套接字总量\n\nCurrEstab - 当前状态为 ESTABLISHED 或 CLOSE-WAIT 的 TCP 连接数\n\nTCP_alloc - 已分配(已建立、已申请到sk_buff)的TCP套接字数量\n\nTCP_tw - 等待关闭的TCP连接数\n\nUDP_inuse - 正在使用的 UDP 套接字数量\n\nRetransSegs - TCP 重传报文数\n\nOutSegs - TCP 发送的报文数\n\nInSegs - TCP 接收的报文数", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "series", + "axisLabel": "CurrEstab", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "never", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "links": [], + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "none" + }, + "overrides": [ + { + "matcher": { + "id": "byName", + "options": "TCP_alloc" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "blue", + "mode": "fixed" + } + } + ] + }, + { + "matcher": { + "id": "byRegexp", + "options": "/.*Sockets_used/" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "#E02F44", + "mode": "fixed" + } + }, + { + "id": "custom.lineWidth", + "value": 1 + }, + { + "id": "custom.axisLabel", + "value": "已使用的所有协议套接字总量" + }, + { + "id": "custom.showPoints", + "value": "always" + } + ] + } + ] + }, + "gridPos": { + "h": 8, + "w": 16, + "x": 0, + "y": 50 + }, + "id": 158, + "options": { + "legend": { + "calcs": [ + "last", + "max" + ], + "displayMode": "table", + "placement": "right", + "showLegend": true, + "sortBy": "Max", + "sortDesc": true + }, + "tooltip": { + "maxHeight": 600, + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "11.5.0-80683", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "expr": "node_netstat_Tcp_CurrEstab{instance=~\"$instance\"}", + "format": "time_series", + "hide": false, + "instant": false, + "interval": "", + "intervalFactor": 1, + "legendFormat": "CurrEstab", + "refId": "A", + "step": 20 + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "expr": "node_sockstat_TCP_tw{instance=~\"$instance\"}", + "format": "time_series", + "interval": "", + "intervalFactor": 1, + "legendFormat": "TCP_tw", + "refId": "D" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "exemplar": true, + "expr": "node_sockstat_sockets_used{instance=~\"$instance\"}", + "hide": false, + "interval": "2m", + "intervalFactor": 1, + "legendFormat": "Sockets_used", + "refId": "B" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "expr": "node_sockstat_UDP_inuse{instance=~\"$instance\"}", + "interval": "", + "legendFormat": "UDP_inuse", + "refId": "C" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "expr": "node_sockstat_TCP_alloc{instance=~\"$instance\"}", + "interval": "", + "legendFormat": "TCP_alloc", + "refId": "E" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "expr": "irate(node_netstat_Tcp_PassiveOpens{instance=~\"$instance\"}[$interval])", + "hide": true, + "interval": "", + "legendFormat": "{{instance}}_Tcp_PassiveOpens", + "refId": "G" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "expr": "irate(node_netstat_Tcp_ActiveOpens{instance=~\"$instance\"}[$interval])", + "hide": true, + "interval": "", + "legendFormat": "{{instance}}_Tcp_ActiveOpens", + "refId": "F" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "expr": "irate(node_netstat_Tcp_InSegs{instance=~\"$instance\"}[$interval])", + "interval": "", + "legendFormat": "Tcp_InSegs", + "refId": "H" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "expr": "irate(node_netstat_Tcp_OutSegs{instance=~\"$instance\"}[$interval])", + "interval": "", + "legendFormat": "Tcp_OutSegs", + "refId": "I" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "expr": "irate(node_netstat_Tcp_RetransSegs{instance=~\"$instance\"}[$interval])", + "hide": false, + "interval": "", + "legendFormat": "Tcp_RetransSegs", + "refId": "J" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "expr": "irate(node_netstat_TcpExt_ListenDrops{instance=~\"$instance\"}[$interval])", + "hide": true, + "interval": "", + "legendFormat": "", + "refId": "K" + } + ], + "title": "网络Socket连接信息", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "上传(-)/下载(+)", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "never", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "links": [], + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "bps" + }, + "overrides": [ + { + "matcher": { + "id": "byRegexp", + "options": "/.*_out上传$/" + }, + "properties": [ + { + "id": "custom.transform", + "value": "negative-Y" + }, + { + "id": "color", + "value": { + "fixedColor": "blue", + "mode": "fixed" + } + } + ] + }, + { + "matcher": { + "id": "byValue", + "options": { + "op": "gte", + "reducer": "allIsZero", + "value": 0 + } + }, + "properties": [ + { + "id": "custom.hideFrom", + "value": { + "legend": true, + "tooltip": true, + "viz": false + } + } + ] + }, + { + "matcher": { + "id": "byValue", + "options": { + "op": "gte", + "reducer": "allIsNull", + "value": 0 + } + }, + "properties": [ + { + "id": "custom.hideFrom", + "value": { + "legend": true, + "tooltip": true, + "viz": false + } + } + ] + }, + { + "matcher": { + "id": "byRegexp", + "options": "/.*_in下载$/" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "yellow", + "mode": "fixed" + } + } + ] + } + ] + }, + "gridPos": { + "h": 8, + "w": 8, + "x": 16, + "y": 50 + }, + "id": 157, + "options": { + "legend": { + "calcs": [ + "mean", + "lastNotNull", + "max" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "maxHeight": 600, + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "11.5.0-80683", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "exemplar": true, + "expr": "irate(node_network_receive_bytes_total{instance=~\"$instance\",device=~\"$device\"}[$interval])*8", + "format": "time_series", + "interval": "", + "intervalFactor": 1, + "legendFormat": "{{device}}_in下载", + "refId": "A", + "step": 4 + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "expr": "irate(node_network_transmit_bytes_total{instance=~\"$instance\",device=~\"$device\"}[$interval])*8", + "format": "time_series", + "interval": "", + "intervalFactor": 1, + "legendFormat": "{{device}}_out上传", + "refId": "B", + "step": 4 + } + ], + "title": "每秒网络带宽使用$device", + "type": "timeseries" + } + ], + "refresh": "", + "schemaVersion": 40, + "tags": [ + "Prometheus", + "node_exporter", + "StarsL.cn", + "TenSunS" + ], + "templating": { + "list": [ + { + "current": {}, + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "definition": "label_values(origin_prometheus)", + "includeAll": false, + "label": "数据源", + "name": "origin_prometheus", + "options": [], + "query": { + "qryType": 1, + "query": "label_values(origin_prometheus)", + "refId": "PrometheusVariableQueryEditor-VariableQuery" + }, + "refresh": 2, + "regex": "", + "sort": 5, + "type": "query" + }, + { + "current": {}, + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "definition": "label_values(node_uname_info{origin_prometheus=~\"$origin_prometheus\"},job)", + "includeAll": false, + "label": "JOB", + "name": "job", + "options": [], + "query": { + "qryType": 1, + "query": "label_values(node_uname_info{origin_prometheus=~\"$origin_prometheus\"},job)", + "refId": "PrometheusVariableQueryEditor-VariableQuery" + }, + "refresh": 2, + "regex": "", + "sort": 5, + "type": "query" + }, + { + "current": {}, + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "definition": "label_values(node_uname_info{origin_prometheus=~\"$origin_prometheus\", job=~\"$job\"},nodename)", + "includeAll": true, + "label": "名称", + "name": "name", + "options": [], + "query": { + "qryType": 1, + "query": "label_values(node_uname_info{origin_prometheus=~\"$origin_prometheus\", job=~\"$job\"},nodename)", + "refId": "PrometheusVariableQueryEditor-VariableQuery" + }, + "refresh": 2, + "regex": "", + "sort": 5, + "type": "query" + }, + { + "current": {}, + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "definition": "label_values(node_uname_info{origin_prometheus=~\"$origin_prometheus\", job=~\"$job\", nodename=~\"$name\"},instance)", + "includeAll": false, + "label": "IP", + "name": "instance", + "options": [], + "query": { + "qryType": 1, + "query": "label_values(node_uname_info{origin_prometheus=~\"$origin_prometheus\", job=~\"$job\", nodename=~\"$name\"},instance)", + "refId": "PrometheusVariableQueryEditor-VariableQuery" + }, + "refresh": 2, + "regex": "", + "sort": 5, + "type": "query" + }, + { + "auto": false, + "auto_count": 100, + "auto_min": "1m", + "current": { + "text": "3m", + "value": "3m" + }, + "hide": 2, + "label": "间隔", + "name": "interval", + "options": [ + { + "selected": true, + "text": "3m", + "value": "3m" + } + ], + "query": "3m", + "refresh": 2, + "type": "interval" + }, + { + "current": {}, + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "definition": "query_result(count(node_uname_info{origin_prometheus=~\"$origin_prometheus\",job=~\"$job\"}))", + "hide": 2, + "includeAll": false, + "label": "主机数", + "name": "total", + "options": [], + "query": { + "qryType": 3, + "query": "query_result(count(node_uname_info{origin_prometheus=~\"$origin_prometheus\",job=~\"$job\"}))", + "refId": "PrometheusVariableQueryEditor-VariableQuery" + }, + "refresh": 2, + "regex": "/{} (.*) .*/", + "type": "query" + }, + { + "current": {}, + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "definition": "label_values(node_network_info{origin_prometheus=~\"$origin_prometheus\", job=~\"$job\", instance=~\"$instance\", device!~\"'tap.*|veth.*|br.*|docker.*|virbr.*|lo.*|cni.*'\"},device)", + "includeAll": true, + "label": "网卡", + "multi": true, + "name": "device", + "options": [], + "query": { + "qryType": 1, + "query": "label_values(node_network_info{origin_prometheus=~\"$origin_prometheus\", job=~\"$job\", instance=~\"$instance\", device!~\"'tap.*|veth.*|br.*|docker.*|virbr.*|lo.*|cni.*'\"},device)", + "refId": "PrometheusVariableQueryEditor-VariableQuery" + }, + "refresh": 2, + "regex": "", + "sort": 5, + "type": "query" + }, + { + "current": {}, + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "definition": "query_result(topk(1,sort_desc(max(node_filesystem_size_bytes{origin_prometheus=~\"$origin_prometheus\",instance=~\"$instance\",fstype=~\"ext.?|xfs\",mountpoint!~\".*pods.*\"}) by (mountpoint))))", + "hide": 2, + "includeAll": false, + "label": "最大挂载目录", + "name": "maxmount", + "options": [], + "query": { + "qryType": 3, + "query": "query_result(topk(1,sort_desc(max(node_filesystem_size_bytes{origin_prometheus=~\"$origin_prometheus\",instance=~\"$instance\",fstype=~\"ext.?|xfs\",mountpoint!~\".*pods.*\"}) by (mountpoint))))", + "refId": "PrometheusVariableQueryEditor-VariableQuery" + }, + "refresh": 2, + "regex": "/.*\\\"(.*)\\\".*/", + "type": "query" + }, + { + "current": {}, + "datasource": { + "type": "prometheus", + "uid": "${DS_指标}" + }, + "definition": "label_values(node_uname_info{origin_prometheus=~\"$origin_prometheus\", job=~\"$job\", nodename=~\"$name\", instance=~\"$instance\"},nodename)", + "hide": 2, + "includeAll": false, + "label": "展示使用的名称", + "name": "show_name", + "options": [], + "query": { + "qryType": 1, + "query": "label_values(node_uname_info{origin_prometheus=~\"$origin_prometheus\", job=~\"$job\", nodename=~\"$name\", instance=~\"$instance\"},nodename)", + "refId": "PrometheusVariableQueryEditor-VariableQuery" + }, + "refresh": 2, + "regex": "", + "sort": 5, + "type": "query" + } + ] + }, + "time": { + "from": "now-5m", + "to": "now" + }, + "timepicker": { + "refresh_intervals": [ + "30s", + "1m", + "3m", + "5m", + "15m", + "30m" + ] + }, + "timezone": "browser", + "title": "Node Exporter Dashboard", + "uid": "StarsL-JOB-node", + "version": 6, + "weekStart": "" +} \ No newline at end of file diff --git a/roles/vhosts/common/defaults/main.yml b/roles/vhosts/common/defaults/main.yml new file mode 100644 index 0000000..aadc9eb --- /dev/null +++ b/roles/vhosts/common/defaults/main.yml @@ -0,0 +1,18 @@ +enable_set_timezone: true # 默认启用 Set timezone +enable_set_hostname: true # 默认启用 Set hostname +enable_install_packages: true # 默认不安装额外的软件包 +enable_all_hosts_update: false # 默认不更新所有主机的条目 + +rsyslog_log_rotation: # 可选的日志管理配置 + enable: true # 启用 rsyslog 日志管理 + rotate_count: 4 # 默认保留的日志文件数量 + rotate_frequency: weekly # 默认每周轮换, 可选:daily, hourly + max_log_size: 100M # 默认日志文件最大大小 + +journald_log_rotation: # 启用 journald 日志管理 + enable: true # 启用 journald 日志管理 + max_log_size: 100M # 默认日志文件最大大小 + max_files: 100 # 默认保留的最大日志文件数 + max_file_sec: 1month # 默认日志文件保存的最大时长 + system_max_use: 1G # 默认系统日志最大使用空间 + runtime_max_use: 500M # 默认运行时日志最大使用空间 diff --git a/roles/vhosts/common/files/install-packages.sh b/roles/vhosts/common/files/install-packages.sh new file mode 100644 index 0000000..982db40 --- /dev/null +++ b/roles/vhosts/common/files/install-packages.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +export DEBIAN_FRONTEND=noninteractive +sudo apt-get update +sudo apt-get install -y vim iputils-ping rsync wireguard-tools diff --git a/roles/vhosts/common/files/secure_ssh.sh b/roles/vhosts/common/files/secure_ssh.sh new file mode 100644 index 0000000..4c6f5f0 --- /dev/null +++ b/roles/vhosts/common/files/secure_ssh.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +# 设置 ~/.ssh/ 目录的权限 +sudo chmod 700 ~/.ssh + +# 设置 ~/.ssh/authorized_keys 文件的权限 +sudo chmod 600 ~/.ssh/authorized_keys + +# 使用 chattr +i 确保 authorized_keys 文件不能被删除 +sudo chattr +i ~/.ssh/authorized_keys || true + diff --git a/roles/vhosts/common/handlers/main.yml b/roles/vhosts/common/handlers/main.yml new file mode 100644 index 0000000..da6f188 --- /dev/null +++ b/roles/vhosts/common/handlers/main.yml @@ -0,0 +1,10 @@ +--- +- name: Restart logrotate service + service: + name: logrotate + state: restarted + +- name: Restart systemd-journald service + service: + name: systemd-journald + state: restarted diff --git a/roles/vhosts/common/tasks/configure_journald.yml b/roles/vhosts/common/tasks/configure_journald.yml new file mode 100644 index 0000000..993aeba --- /dev/null +++ b/roles/vhosts/common/tasks/configure_journald.yml @@ -0,0 +1,7 @@ +--- +- name: Configure journald log rotation using template + template: + src: journald_logrotate.j2 + dest: /etc/systemd/journald.conf + when: journald_log_rotation.enable + notify: Restart systemd-journald service diff --git a/roles/vhosts/common/tasks/configure_logrotate.yaml b/roles/vhosts/common/tasks/configure_logrotate.yaml new file mode 100644 index 0000000..90332b8 --- /dev/null +++ b/roles/vhosts/common/tasks/configure_logrotate.yaml @@ -0,0 +1,7 @@ +--- +- name: Configure logrotate for rsyslog using template + template: + src: rsyslog_logrotate.j2 + dest: /etc/logrotate.d/rsyslog + when: rsyslog_log_rotation.enable + notify: Restart logrotate service diff --git a/roles/vhosts/common/tasks/disable-systemd-resolved.yml b/roles/vhosts/common/tasks/disable-systemd-resolved.yml new file mode 100644 index 0000000..2ff43ff --- /dev/null +++ b/roles/vhosts/common/tasks/disable-systemd-resolved.yml @@ -0,0 +1,27 @@ +- name: Stop systemd-resolved + systemd: + name: systemd-resolved + state: stopped + enabled: no + +- name: Remove /etc/resolv.conf if it's a symlink + file: + path: /etc/resolv.conf + state: absent + force: true + +- name: Create static /etc/resolv.conf + copy: + dest: /etc/resolv.conf + content: | + nameserver 8.8.8.8 + nameserver 1.1.1.1 + owner: root + group: root + mode: '0644' + +- name: Optionally make resolv.conf immutable to prevent changes + command: chattr +i /etc/resolv.conf + args: + warn: false + when: make_resolv_conf_immutable | default(false) diff --git a/roles/vhosts/common/tasks/include_gpu.yaml b/roles/vhosts/common/tasks/include_gpu.yaml new file mode 100644 index 0000000..cb55513 --- /dev/null +++ b/roles/vhosts/common/tasks/include_gpu.yaml @@ -0,0 +1,17 @@ +- name: Add NVIDIA repository + shell: | + add-apt-repository -y ppa:graphics-drivers + curl -s -L https://nvidia.github.io/nvidia-container-runtime/gpgkey | apt-key add - + distribution=$(. /etc/os-release;echo $ID$VERSION_ID) + curl -s -L https://nvidia.github.io/nvidia-container-runtime/$distribution/nvidia-container-runtime.list | tee /etc/apt/sources.list.d/nvidia-container-runtime.list + apt-get update + +- name: Install NVIDIA driver and container runtime + apt: + name: + - nvidia-modprobe + - nvidia-driver-535 + - nvidia-headless-535 + - nvidia-container-runtime + state: present + update_cache: yes diff --git a/roles/vhosts/common/tasks/main.yml b/roles/vhosts/common/tasks/main.yml new file mode 100644 index 0000000..fbf7a91 --- /dev/null +++ b/roles/vhosts/common/tasks/main.yml @@ -0,0 +1,38 @@ +- name: Set timezone + shell: "timedatectl set-timezone Asia/Shanghai" + +- name: Set hostname + shell: "hostname -F /etc/hostname" + +- name: update /etc/hostname + template: src=templates/hostname dest=/etc/hostname owner=root group=root mode=0644 unsafe_writes=yes + +- name: Update /etc/hosts + template: src=templates/hosts dest=/etc/hosts owner=root group=root mode=0644 force=yes unsafe_writes=yes + +- name: Set systemd-resolved and set static DNS + include_tasks: setup-systemd-resolved.yml + +- name: Install packages + script: files/install-packages.sh + when: (ansible_facts['distribution'] == "Ubuntu") or (ansible_facts['distribution'] == "Debian") + +- name: Include Privoxy sub task for SOCKS5 to HTTP proxy (optional) + include_tasks: setup-privoxy.yml + when: privoxy.enable | default(false) + +#- name: Include GPU Configuration +# include_tasks: include_gpu.yaml +# when: (ansible_facts['distribution'] == "Ubuntu") or (ansible_facts['distribution'] == "Debian") +# tags: +# - k3s +# - gpu +# - nvidia + +#- name: enable ip_forward +# shell: 'echo "net.ipv4.ip_forward = 1" >> /etc/sysctl.conf; echo "net.ipv4.conf.all.proxy_arp = 1" >> /etc/sysctl.conf ; sysctl -p /etc/sysctl.conf' + + +#- name: Install packages +# shell: "yum makecache && yum install -y audit container-selinux" +# when: (ansible_facts['distribution'] != "Ubuntu") or (ansible_facts['distribution'] != "Debian") diff --git a/roles/vhosts/common/tasks/set_hostname.yaml b/roles/vhosts/common/tasks/set_hostname.yaml new file mode 100644 index 0000000..edd3dda --- /dev/null +++ b/roles/vhosts/common/tasks/set_hostname.yaml @@ -0,0 +1,12 @@ +- name: Check if systemctl is available + command: which hostnamectl + register: systemctl_check + ignore_errors: true + +- name: Set hostname using systemctl if available + shell: "hostnamectl set-hostname {{ inventory_hostname }}" + when: systemctl_check.rc == 0 + +- name: Set hostname using hostname -F if systemctl is not available + shell: "hostname -F /etc/hostname" + when: systemctl_check.rc != 0 diff --git a/roles/vhosts/common/tasks/set_timezone.yaml b/roles/vhosts/common/tasks/set_timezone.yaml new file mode 100644 index 0000000..1c85cd7 --- /dev/null +++ b/roles/vhosts/common/tasks/set_timezone.yaml @@ -0,0 +1,2 @@ +- name: Set timezone + shell: "timedatectl set-timezone Asia/Shanghai" diff --git a/roles/vhosts/common/tasks/setup-privoxy.yml b/roles/vhosts/common/tasks/setup-privoxy.yml new file mode 100644 index 0000000..2783de2 --- /dev/null +++ b/roles/vhosts/common/tasks/setup-privoxy.yml @@ -0,0 +1,24 @@ +--- +- name: Install privoxy (Debian) + apt: + name: privoxy + state: present + when: ansible_os_family == 'Debian' + +- name: Install privoxy (RedHat) + yum: + name: privoxy + state: present + when: ansible_os_family == 'RedHat' + +- name: Ensure SOCKS5 forwarding is configured in privoxy + lineinfile: + path: /etc/privoxy/config + line: "forward-socks5t / {{ proxy.socks5_host }}:{{ proxcy.socks5_port }} ." + state: present + +- name: Restart and enable privoxy + systemd: + name: privoxy + state: restarted + enabled: yes diff --git a/roles/vhosts/common/tasks/setup-systemd-resolved.yml b/roles/vhosts/common/tasks/setup-systemd-resolved.yml new file mode 100644 index 0000000..e7a130c --- /dev/null +++ b/roles/vhosts/common/tasks/setup-systemd-resolved.yml @@ -0,0 +1,36 @@ +# playbooks/setup-systemd-resolved.yml +- name: Ensure systemd-resolved is installed + package: + name: systemd-resolved + state: present + +- name: Enable and start systemd-resolved + systemd: + name: systemd-resolved + enabled: yes + state: started + +- name: Configure /etc/systemd/resolved.conf + ini_file: + path: /etc/systemd/resolved.conf + section: "Resolve" + option: "{{ item.option }}" + value: "{{ item.value }}" + mode: '0644' + loop: + - { option: "DNSStubListener", value: "no" } + - { option: "DNS", value: "" } + - { option: "FallbackDNS", value: "" } + +- name: Restart systemd-resolved + systemd: + name: systemd-resolved + state: restarted + daemon_reload: yes + +- name: Ensure /etc/resolv.conf points to /run/systemd/resolve/resolv.conf + file: + src: /run/systemd/resolve/resolv.conf + dest: /etc/resolv.conf + state: link + force: true diff --git a/roles/vhosts/common/templates/authorized_keys b/roles/vhosts/common/templates/authorized_keys new file mode 100755 index 0000000..f7bb4d5 --- /dev/null +++ b/roles/vhosts/common/templates/authorized_keys @@ -0,0 +1,3 @@ +{% for item in ssh_keys %} +{{ item }} +{% endfor %} diff --git a/roles/vhosts/common/templates/hostname b/roles/vhosts/common/templates/hostname new file mode 100755 index 0000000..1fad51f --- /dev/null +++ b/roles/vhosts/common/templates/hostname @@ -0,0 +1 @@ +{{ inventory_hostname }} diff --git a/roles/vhosts/common/templates/hosts b/roles/vhosts/common/templates/hosts new file mode 100644 index 0000000..2a13249 --- /dev/null +++ b/roles/vhosts/common/templates/hosts @@ -0,0 +1,26 @@ +# IPv4 localhost configuration +127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 + +# IPv6 localhost configuration +::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 + +# IPv6 Local addresses (desirable for IPv6 capable hosts) +::1 ip6-localhost ip6-loopback +fe00::0 ip6-localnet +ff00::0 ip6-mcastprefix +ff02::1 ip6-allnodes +ff02::2 ip6-allrouters + +{{ ansible_default_ipv4.address }} {{ inventory_hostname }} + +{% if enable_all_hosts_update is defined and enable_all_hosts_update %} + {% for item in groups['all'] %} + {{ hostvars[item]['ansible_host'] }} {{ item }} + {% endfor %} +{% endif %} + +{% if extra_domain is defined %} +{% for ip, domain_name in extra_domain.items() %} +{{ ip }} {{ domain_name }} +{% endfor %} +{% endif %} diff --git a/roles/vhosts/common/templates/journald_logrotate.j2 b/roles/vhosts/common/templates/journald_logrotate.j2 new file mode 100644 index 0000000..3bb8d1e --- /dev/null +++ b/roles/vhosts/common/templates/journald_logrotate.j2 @@ -0,0 +1,5 @@ +[Journal] +SystemMaxUse={{ journald_log_rotation.system_max_use }} # 设置最大日志使用空间 +SystemMaxFiles={{ journald_log_rotation.max_files }} # 设置最大日志文件数 +MaxFileSec={{ journald_log_rotation.max_file_sec }} # 设置日志文件的轮换频率(例如 weekly, daily, hourly) +RuntimeMaxUse={{ journald_log_rotation.runtime_max_use }} # 设置运行时日志最大使用空间 diff --git a/roles/vhosts/common/templates/logrotate-monitor-agent b/roles/vhosts/common/templates/logrotate-monitor-agent new file mode 100644 index 0000000..b4120ce --- /dev/null +++ b/roles/vhosts/common/templates/logrotate-monitor-agent @@ -0,0 +1,8 @@ +/var/log/prometheus-agent.log +/var/log/prometheus-transfer.log { + rotate 12 + monthly + compress + missingok + notifempty +} diff --git a/roles/vhosts/common/templates/rsyslog_logrotate.j2 b/roles/vhosts/common/templates/rsyslog_logrotate.j2 new file mode 100644 index 0000000..f31334b --- /dev/null +++ b/roles/vhosts/common/templates/rsyslog_logrotate.j2 @@ -0,0 +1,23 @@ +/var/log/syslog +/var/log/mail* # 包括所有以 mail 开头的日志文件 +/var/log/daemon.log +/var/log/kern.log +/var/log/auth.log +/var/log/user.log +/var/log/lpr.log +/var/log/cron.log +/var/log/debug +/var/log/messages +{ + rotate {{ rsyslog_log_rotation.rotate_count }} + {{ rsyslog_log_rotation.rotate_frequency }} + missingok + notifempty + compress + delaycompress + sharedscripts + postrotate + /usr/lib/rsyslog/rsyslog-rotate + endscript + maxsize {{ rsyslog_log_rotation.max_log_size }} +} diff --git a/roles/vhosts/k3s-cluster/files/set-registry.sh b/roles/vhosts/k3s-cluster/files/set-registry.sh new file mode 100644 index 0000000..e4c3884 --- /dev/null +++ b/roles/vhosts/k3s-cluster/files/set-registry.sh @@ -0,0 +1,300 @@ +#!/bin/bash + +#https://github.com/containerd/nerdctl/releases/download/v2.0.2/nerdctl-2.0.2-linux-amd64.tar.gz +#https://github.com/containerd/nerdctl/releases/download/v2.0.2/nerdctl-full-2.0.2-linux-amd64.tar.gz +#wget https://github.com/containernetworking/plugins/releases/download/v1.6.2/cni-plugins-linux-amd64-v1.6.2.tgz + +#!/bin/bash +set -e + +# ============================================= +# ✅ 环境变量检查(可配置) +# ============================================= +: "${REGISTRY_DOMAIN:=kube.registry.local}" +: "${REGISTRY_PORT:=5000}" +: "${NERDCTL_VERSION:=v2.0.2}" +: "${CNI_VERSION:=v1.6.2}" +: "${CNI_DIR:=/opt/cni/bin}" +: "${CERT_DIR:=/opt/registry/certs}" +: "${CONFIG_DIR:=/opt/registry/config}" +: "${REGISTRY_DATA:=/var/lib/registry}" +: "${REGISTRY_YAML:=registry.yaml}" +: "${COMPOSE_YAML:=compose.yaml}" +: "${TAR_FILE:=registry.tar}" + +# ============================================= +# ✅ 自动检测 containerd.sock +# ============================================= +if [[ -S "/run/k3s/containerd/containerd.sock" ]]; then + export CONTAINERD_ADDRESS="/run/k3s/containerd/containerd.sock" +elif [[ -S "/run/containerd/containerd.sock" ]]; then + export CONTAINERD_ADDRESS="/run/containerd/containerd.sock" +elif [[ -S "/var/run/containerd/containerd.sock" ]]; then + export CONTAINERD_ADDRESS="/var/run/containerd/containerd.sock" +else + echo "❌ 未检测到有效的 containerd.sock,请确认 containerd 是否正常运行。" + exit 1 +fi + +export NERDCTL_NAMESPACE="k8s.io" + +# ============================================= +echo "📦 准备 nerdctl 全功能版..." +if ! command -v nerdctl &>/dev/null; then + if [ ! -f /tmp/nerdctl-full.tgz ]; then + echo "⬇️ 下载 nerdctl..." + wget -O /tmp/nerdctl-full.tgz \ + "https://github.com/containerd/nerdctl/releases/download/${NERDCTL_VERSION}/nerdctl-full-${NERDCTL_VERSION#v}-linux-amd64.tar.gz" + else + echo "📦 已存在 nerdctl-full.tgz,跳过下载" + fi + + echo "📦 解压 nerdctl 到 /usr/local..." + sudo tar -C /usr/local -xzf /tmp/nerdctl-full.tgz + echo "✅ nerdctl 安装完成: $(nerdctl --version)" +else + echo "✅ nerdctl 已存在: $(nerdctl --version)" +fi + +# ============================================= +echo "📦 安装 CNI 插件..." +if [ ! -f "${CNI_DIR}/bridge" ]; then + if [ ! -f /tmp/cni.tgz ]; then + echo "⬇️ 下载 CNI 插件..." + wget -O /tmp/cni.tgz \ + "https://github.com/containernetworking/plugins/releases/download/${CNI_VERSION}/cni-plugins-linux-amd64-${CNI_VERSION}.tgz" + else + echo "📦 已存在 cni.tgz,跳过下载" + fi + + sudo mkdir -p "${CNI_DIR}" + sudo tar -C "${CNI_DIR}" -xzf /tmp/cni.tgz + echo "✅ CNI 插件已安装到: ${CNI_DIR}" +else + echo "✅ CNI 插件已存在: ${CNI_DIR}/bridge" +fi + +# ============================================= +echo "📦 解压 SSL 证书..." + +if [ ! -f "ssl_certificates.tar.gz" ]; then + echo "⬇️ 未找到 ssl_certificates.tar.gz,尝试从 GitHub 下载..." + wget -O ssl_certificates.tar.gz \ + "https://github.com/svc-design/ansible/releases/download/release-self-signed-cert_kube.registry.local/ssl_certificates.tar.gz" || { + echo "❌ 无法下载 ssl_certificates.tar.gz,终止执行" + exit 1 + } +else + if [ -f "ssl_certificates.tar.gz" ]; then + mkdir -p "$CERT_DIR" + tar -xvpf ssl_certificates.tar.gz + tar -xvpf ssl_certificates.tar.gz -C "$CERT_DIR" + echo "✅ 证书已解压至: $CERT_DIR" + fi +fi + +# ============================================= + +# ============ 生成 registry-config ============ +echo "⚙️ 准备 registry 配置..." +sudo mkdir -pv "$CONFIG_DIR" +sudo mkdir -pv "$REGISTRY_DATA" +echo "📝 写入 registry-config.yaml..." +sudo cat > "${CONFIG_DIR}/${REGISTRY_YAML}" < /dev/null +version: 0.1 +log: + fields: + service: registry +storage: + cache: + blobdescriptor: inmemory + filesystem: + rootdirectory: /var/lib/registry + delete: + enabled: true +http: + addr: :${REGISTRY_PORT} + headers: + X-Content-Type-Options: [nosniff] + tls: + certificate: /etc/docker/registry/domain.crt + key: /etc/docker/registry/domain.key +health: + storagedriver: + enabled: true + interval: 10s + threshold: 3 +EOF +echo "✅ registry.yaml 已创建" + +# ========== 生成 compose.yaml ========== +echo "🛠️ 生成 compose 配置..." +cat < /dev/null +services: + registry: + image: registry:latest + container_name: registry + restart: always + network_mode: host + volumes: + - /var/lib/registry:/var/lib/registry + - ${CONFIG_DIR}/registry.yaml:/etc/docker/registry/config.yml + - ${CERT_DIR}/kube.registry.local.cert:/etc/docker/registry/domain.crt + - ${CERT_DIR}/kube.registry.local.key:/etc/docker/registry/domain.key +EOF +echo "✅ compose.yaml 已创建" + +# ============================================= +echo "📦 导入本地 registry 镜像..." +if [ -f "/usr/local/deepflow/$TAR_FILE" ]; then + sudo CONTAINERD_ADDRESS="$CONTAINERD_ADDRESS" nerdctl --namespace $NERDCTL_NAMESPACE load -i "/usr/local/deepflow/$TAR_FILE" +else + echo "⚠️ 本地镜像文件不存在:/usr/local/deepflow/$TAR_FILE" +fi + +# ============================================= +echo "🔁 重启 registry 服务..." +sudo CONTAINERD_ADDRESS="$CONTAINERD_ADDRESS" nerdctl --namespace $NERDCTL_NAMESPACE compose -f "$CONFIG_DIR/compose.yaml" down || true +sudo CONTAINERD_ADDRESS="$CONTAINERD_ADDRESS" nerdctl --namespace $NERDCTL_NAMESPACE compose -f "$CONFIG_DIR/compose.yaml" up -d + +# ============================================= +echo "🔗 添加 hosts 映射..." +if ! grep -q "$REGISTRY_DOMAIN" /etc/hosts; then + echo "127.0.0.1 $REGISTRY_DOMAIN" | sudo tee -a /etc/hosts + echo "✅ /etc/hosts 已添加 $REGISTRY_DOMAIN" +else + echo "✅ hosts 中已存在 $REGISTRY_DOMAIN" +fi + +echo "✅ Registry 启动成功: https://$REGISTRY_DOMAIN:$REGISTRY_PORT" + +# ============================================= +echo "🔐 安装 CA 证书到系统信任目录..." + +CA_CERT="${CERT_DIR}/ca.cert" +if [ ! -f "$CA_CERT" ]; then + echo "❌ 未找到 CA 证书: $CA_CERT" +else + if grep -qi "ubuntu\|debian" /etc/os-release; then + sudo cp "$CA_CERT" "/usr/local/share/ca-certificates/kube-registry-ca.crt" + sudo update-ca-certificates + echo "✅ 已导入 CA 到 Ubuntu/Debian 系统信任目录" + elif grep -qi "rhel\|centos\|rocky" /etc/os-release; then + sudo cp "$CA_CERT" "/etc/pki/ca-trust/source/anchors/kube-registry-ca.crt" + sudo update-ca-trust extract + echo "✅ 已导入 CA 到 RHEL/CentOS 系统信任目录" + else + echo "⚠️ 未知发行版,跳过系统 CA 导入" + fi +fi + +# ============================================= +echo "🐳 安装 CA 到容器运行时 (Docker/Containerd)..." + +# --- Docker CA --- +if command -v docker &>/dev/null; then + echo "🔧 配置 Docker..." + DOCKER_CA_DIR="/etc/docker/certs.d/kube.registry.local" + sudo mkdir -p "$DOCKER_CA_DIR" + sudo cp "$CA_CERT" "${DOCKER_CA_DIR}/ca.crt" + echo "✅ 已导入 CA 到 Docker: $DOCKER_CA_DIR" + sudo systemctl restart docker +fi + +# --- Containerd CA --- +if command -v containerd &>/dev/null || [ -S "$CONTAINERD_SOCK" ]; then + echo "🔧 配置 Containerd..." + + # Alpine/K3s: /etc/containerd/certs.d + # cri-o/nerdctl: /etc/containerd/certs.d/kube.registry.local/ca.crt + CONTAINERD_CA_DIR="/etc/containerd/certs.d/kube.registry.local" + sudo mkdir -p "$CONTAINERD_CA_DIR" + sudo cp "$CA_CERT" "${CONTAINERD_CA_DIR}/ca.crt" + echo "✅ 已导入 CA 到 Containerd: $CONTAINERD_CA_DIR" + sudo systemctl restart containerd || echo "⚠️ containerd 重启失败,可能在 K3s 中不适用" +fi + +# --- K3s CA --- +if [[ -S "/run/k3s/containerd/containerd.sock" ]]; then + echo "🔧 检测到 K3s 环境,准备配置自定义 registry CA..." + + # === 配置参数 === + REGISTRY_DOMAIN="kube.registry.local" + REGISTRY_PORT="5000" + CA_CERT_PATH="/opt/registry/certs/ca.cert" + REGISTRIES_YAML="/etc/rancher/k3s/registries.yaml" + CA_DST_DIR="/etc/rancher/k3s/registries.d/${REGISTRY_DOMAIN}" + CA_DST_FILE="${CA_DST_DIR}/ca.crt" + + # === 准备目录并拷贝证书 === + sudo mkdir -p "${CA_DST_DIR}" + sudo cp "${CA_CERT_PATH}" "${CA_DST_FILE}" + + # === 写入 registries.yaml === + echo "[INFO] 写入 registries.yaml 配置..." + sudo tee "${REGISTRIES_YAML}" > /dev/null </dev/null | grep -q "coredns.*Running"; do + sleep 3 +done + +# === 设置本地 kubeconfig === +mkdir -p ~/.kube +cp /etc/rancher/k3s/k3s.yaml ~/.kube/config +chmod 600 ~/.kube/config +export KUBECONFIG=~/.kube/config + +curl -fsSL https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash + +echo "✅ K3s 安装完成,kubectl/helm 已就绪" + + diff --git a/roles/vhosts/k3s-cluster/tasks/main.yml b/roles/vhosts/k3s-cluster/tasks/main.yml new file mode 100644 index 0000000..e38cb1e --- /dev/null +++ b/roles/vhosts/k3s-cluster/tasks/main.yml @@ -0,0 +1,44 @@ +--- +- name: Ensure remote tmp directory exists + file: + path: /tmp/ansible-{{ ansible_user }} + state: directory + mode: '0755' + owner: "{{ ansible_user }}" + group: "{{ ansible_user }}" + +- name: Sync setup_k3s.sh to remote + synchronize: + src: files/setup_k3s.sh + dest: /tmp/ansible-{{ ansible_user }}/setup_k3s.sh + mode: push + delegate_to: localhost + become: false + +- name: Sync set-registry.sh to remote + synchronize: + src: files/set-registry.sh + dest: /tmp/ansible-{{ ansible_user }}/set-registry.sh + mode: push + delegate_to: localhost + become: false + +- name: Ensure setup_k3s.sh is executable + file: + path: /tmp/ansible-{{ ansible_user }}/setup_k3s.sh + mode: '0755' + +- name: Ensure set-registry.sh is executable + file: + path: /tmp/ansible-{{ ansible_user }}/set-registry.sh + mode: '0755' + +- name: Run setup_k3s.sh + command: ./setup_k3s.sh + args: + chdir: /tmp/ansible-{{ ansible_user }} + +- name: Run set-registry.sh + command: ./set-registry.sh + args: + chdir: /tmp/ansible-{{ ansible_user }} diff --git a/roles/vhosts/vpn-overlay/setup-dnat/defaults/main.yml b/roles/vhosts/vpn-overlay/setup-dnat/defaults/main.yml new file mode 100644 index 0000000..9a36a12 --- /dev/null +++ b/roles/vhosts/vpn-overlay/setup-dnat/defaults/main.yml @@ -0,0 +1,6 @@ +--- +# 从 vpn-overlay.yaml 加载 overlay 结构 +overlay_config_path: "{{ playbook_dir }}/../../config/sit/vpn-overlay.yaml" + +# 脚本默认路径 +dnat_script_path: /usr/local/bin/setup-dnat.sh diff --git a/roles/vhosts/vpn-overlay/setup-dnat/tasks/main.yml b/roles/vhosts/vpn-overlay/setup-dnat/tasks/main.yml new file mode 100644 index 0000000..cdf8718 --- /dev/null +++ b/roles/vhosts/vpn-overlay/setup-dnat/tasks/main.yml @@ -0,0 +1,40 @@ +--- +- name: 加载 overlay 配置(标准 YAML) + set_fact: + overlay_data: "{{ lookup('file', overlay_config_path) | from_yaml }}" + +- name: 提取当前节点信息(作为 current_node) + set_fact: + current_node: >- + {{ (overlay_data.sites + overlay_data.hubs) + | selectattr('name', 'equalto', inventory_hostname) + | list | first }} + +- name: 设置本节点 DNAT 所需变量 + set_fact: + dnat_public_ip: "{{ current_node.public_ip }}" + dnat_internal_ip: "{{ current_node.wg_ip }}" + pod_cidr: "{{ current_node.pod_cidr }}" + wireguard_cidr: "{{ current_node.wireguard_cidr }}" + +- name: 模板渲染 DNAT 脚本 + template: + src: setup-dnat.sh.j2 + dest: "{{ dnat_script_path }}" + mode: "0755" + +- name: 安装 systemd 服务 + template: + src: dnat-rules.service.j2 + dest: /etc/systemd/system/dnat-rules.service + mode: "0644" + +- name: Reload systemd daemon + command: systemctl daemon-reexec + changed_when: false + +- name: 启动并启用 DNAT 服务 + systemd: + name: dnat-rules.service + enabled: true + state: started diff --git a/roles/vhosts/vpn-overlay/setup-dnat/templates/dnat-rules.service.j2 b/roles/vhosts/vpn-overlay/setup-dnat/templates/dnat-rules.service.j2 new file mode 100644 index 0000000..07fdc16 --- /dev/null +++ b/roles/vhosts/vpn-overlay/setup-dnat/templates/dnat-rules.service.j2 @@ -0,0 +1,12 @@ +[Unit] +Description=Setup DNAT rules for exposing services via WireGuard +After=network-online.target +Wants=network-online.target + +[Service] +Type=oneshot +ExecStart={{ dnat_script_path }} +RemainAfterExit=true + +[Install] +WantedBy=multi-user.target diff --git a/roles/vhosts/vpn-overlay/setup-dnat/templates/setup-dnat.sh.j2 b/roles/vhosts/vpn-overlay/setup-dnat/templates/setup-dnat.sh.j2 new file mode 100644 index 0000000..e118dd1 --- /dev/null +++ b/roles/vhosts/vpn-overlay/setup-dnat/templates/setup-dnat.sh.j2 @@ -0,0 +1,26 @@ +#!/bin/bash + +ACTION=$1 + +if [[ "$ACTION" == "clean" ]]; then + echo "[DNAT] 清理规则..." + + iptables -t nat -D PREROUTING -p tcp -d {{ dnat_public_ip }} --dport 80 -j DNAT --to-destination {{ dnat_internal_ip }}:80 + iptables -t nat -D PREROUTING -p tcp -d {{ dnat_public_ip }} --dport 443 -j DNAT --to-destination {{ dnat_internal_ip }}:443 + + iptables -D FORWARD -p tcp -d {{ pod_cidr }} --dport 80 -j ACCEPT + iptables -D FORWARD -p tcp -d {{ pod_cidr }} --dport 443 -j ACCEPT + iptables -D FORWARD -p tcp -d {{ wireguard_cidr }} --dport 80 -j ACCEPT + iptables -D FORWARD -p tcp -d {{ wireguard_cidr }} --dport 443 -j ACCEPT + +else + echo "[DNAT] 添加规则..." + + iptables -t nat -A PREROUTING -p tcp -d {{ dnat_public_ip }} --dport 80 -j DNAT --to-destination {{ dnat_internal_ip }}:80 + iptables -t nat -A PREROUTING -p tcp -d {{ dnat_public_ip }} --dport 443 -j DNAT --to-destination {{ dnat_internal_ip }}:443 + + iptables -A FORWARD -p tcp -d {{ pod_cidr }} --dport 80 -j ACCEPT + iptables -A FORWARD -p tcp -d {{ pod_cidr }} --dport 443 -j ACCEPT + iptables -A FORWARD -p tcp -d {{ wireguard_cidr }} --dport 80 -j ACCEPT + iptables -A FORWARD -p tcp -d {{ wireguard_cidr }} --dport 443 -j ACCEPT +fi diff --git a/roles/vhosts/vpn-overlay/vxlan/hub/defaults/main.yml b/roles/vhosts/vpn-overlay/vxlan/hub/defaults/main.yml new file mode 100644 index 0000000..6d9fb4f --- /dev/null +++ b/roles/vhosts/vpn-overlay/vxlan/hub/defaults/main.yml @@ -0,0 +1,7 @@ +--- +# Default VXLAN settings for site nodes +vxlan_dev_if: wg0 +vxlan_vni: 100 +vxlan_cidr_suffix: 16 +overlay_config_path: config/sit/vpn-overlay.yaml + diff --git a/roles/vhosts/vpn-overlay/vxlan/hub/files/setup_sit_vxlan.sh b/roles/vhosts/vpn-overlay/vxlan/hub/files/setup_sit_vxlan.sh new file mode 100644 index 0000000..992620b --- /dev/null +++ b/roles/vhosts/vpn-overlay/vxlan/hub/files/setup_sit_vxlan.sh @@ -0,0 +1,83 @@ +#!/bin/bash +# 安全增强版 VXLAN Overlay 脚本(支持 wg0 作为通道设备 + 可选公网 DNAT 映射) +# 用法: ./setup_sit_vxlan.sh [cidr_suffix] [vxlan_id] [mtu] [expose_port] + +set -e + +DEV_IF="$1" +LOCAL_IP="$2" +REMOTE_IP="$3" +BRIDGE_IP="$4" +CIDR_SUFFIX="${5:-16}" +VNI="${6:-100}" +MTU="${7:-1400}" +EXPOSE_PORT="${8:-443}" + +if [[ -z "$DEV_IF" || -z "$LOCAL_IP" || -z "$REMOTE_IP" || -z "$BRIDGE_IP" ]]; then + echo "Usage: $0 [cidr_suffix] [vxlan_id] [mtu] [expose_port]" + exit 1 +fi + +VXLAN_IF="vxlan${VNI}" +BR_IF="br0" +BRIDGE_CIDR="${BRIDGE_IP}/${CIDR_SUFFIX}" +SUBNET="$(echo "$BRIDGE_IP" | cut -d. -f1-2).0.0/${CIDR_SUFFIX}" + +# 自动判断 dev 是否能用于 VXLAN(需支持广播) +function is_vxlan_dev_usable() { + [[ -d "/sys/class/net/$1" ]] && grep -q "broadcast" "/sys/class/net/$1/flags" +} + +echo "🔍 检查 $DEV_IF 是否可用于 VXLAN..." +USE_DEV_PARAM=true +if ! is_vxlan_dev_usable "$DEV_IF"; then + echo "⚠️ $DEV_IF 不支持广播,将省略 dev 参数(通过路由走隧道)" + USE_DEV_PARAM=false +fi + +# 清理旧接口 +for iface in "$VXLAN_IF" "$BR_IF"; do + ip link show "$iface" &>/dev/null && ip link set "$iface" down && ip link del "$iface" +done + +# 创建 VXLAN 接口 +echo "🛠️ 创建 VXLAN 接口 $VXLAN_IF ..." +if $USE_DEV_PARAM; then + ip link add "$VXLAN_IF" type vxlan id "$VNI" dstport 4789 local "$LOCAL_IP" remote "$REMOTE_IP" dev "$DEV_IF" +else + ip link add "$VXLAN_IF" type vxlan id "$VNI" dstport 4789 local "$LOCAL_IP" remote "$REMOTE_IP" +fi +ip link set "$VXLAN_IF" mtu "$MTU" +ip link set "$VXLAN_IF" up + +# 创建 br0 桥 +ip link add "$BR_IF" type bridge +ip link set "$BR_IF" mtu "$MTU" +ip link set "$VXLAN_IF" master "$BR_IF" +ip link set "$BR_IF" up + +# 配置 IP +ip addr add "$BRIDGE_CIDR" dev "$BR_IF" + +# 启用转发 + SNAT(仅主机出网时) +sysctl -w net.ipv4.ip_forward=1 +iptables -t nat -C POSTROUTING -s "$SUBNET" -o "$DEV_IF" -j MASQUERADE 2>/dev/null || \ +iptables -t nat -A POSTROUTING -s "$SUBNET" -o "$DEV_IF" -j MASQUERADE + +# ⚠️ 可选:仅在 EXPOSE_PORT 被定义时启用 DNAT 公网端口映射 +if [[ -n "$EXPOSE_PORT" ]]; then + echo "🌐 添加 DNAT 映射规则:公网:$EXPOSE_PORT → ${BRIDGE_IP}:443" + + iptables -t nat -C PREROUTING -p tcp -m tcp --dport "$EXPOSE_PORT" -j DNAT --to-destination "${BRIDGE_IP}:443" 2>/dev/null || \ + iptables -t nat -A PREROUTING -p tcp -m tcp --dport "$EXPOSE_PORT" -j DNAT --to-destination "${BRIDGE_IP}:443" +fi + +# 展示结果 +echo "" +echo "✅ VXLAN Overlay 已建立" +echo " - bridge: $BR_IF ($BRIDGE_CIDR)" +echo " - vxlan: $VXLAN_IF ($LOCAL_IP ⇄ $REMOTE_IP, id=$VNI, mtu=$MTU)" +echo " - SNAT: $SUBNET → $DEV_IF" +if [[ -n "$EXPOSE_PORT" ]]; then +echo " - DNAT: 公网:$EXPOSE_PORT → ${BRIDGE_IP}:443" +fi diff --git a/roles/vhosts/vpn-overlay/vxlan/hub/tasks/main.yml b/roles/vhosts/vpn-overlay/vxlan/hub/tasks/main.yml new file mode 100644 index 0000000..55025c8 --- /dev/null +++ b/roles/vhosts/vpn-overlay/vxlan/hub/tasks/main.yml @@ -0,0 +1,50 @@ +--- +- name: Load site overlay config + set_fact: + overlay_data: "{{ lookup('file', overlay_config_path) | from_yaml }}" + +- name: Select current site from config + set_fact: + current_hub: "{{ overlay_data.hubs | selectattr('name', 'equalto', inventory_hostname) | list | first }}" + +- name: Fail if no matching site found + fail: + msg: "当前主机 {{ inventory_hostname }} 未在 config 中定义" + when: current_hub is not defined + +- name: Set VXLAN parameters + set_fact: + vxlan_dev_if: "{{ current_hub.interface}}" + vxlan_local_ip: "{{ current_hub.local_ip }}" + vxlan_remote_ip: "{{ current_hub.remote_ip }}" + vxlan_br_ip: "{{ current_hub.br_ip }}" + vxlan_cidr_suffix: "{{ overlay_data.vxlan_cidr_suffix | default(16) }}" + vxlan_vni: "{{ overlay_data.vxlan_id | default(100) }}" + +- name: 使用 rsync 分发 VXLAN 脚本 + synchronize: + src: "files/setup_sit_vxlan.sh" + dest: /tmp/setup_sit_vxlan.sh + mode: push + +- name: 移动脚本并赋权到 /usr/local/bin + shell: | + mv /tmp/setup_sit_vxlan.sh /usr/local/bin/setup_sit_vxlan.sh + chmod +x /usr/local/bin/setup_sit_vxlan.sh + become: true + +- name: Render systemd unit for VXLAN + template: + src: vxlan-setup.service.j2 + dest: /etc/systemd/system/vxlan-setup.service + mode: '0644' + +- name: Reload systemd daemon + systemd: + daemon_reload: true + +- name: Enable and start VXLAN overlay setup + systemd: + name: vxlan-setup + enabled: true + state: started diff --git a/roles/vhosts/vpn-overlay/vxlan/hub/templates/vxlan-setup.service.j2 b/roles/vhosts/vpn-overlay/vxlan/hub/templates/vxlan-setup.service.j2 new file mode 100644 index 0000000..d9313f0 --- /dev/null +++ b/roles/vhosts/vpn-overlay/vxlan/hub/templates/vxlan-setup.service.j2 @@ -0,0 +1,12 @@ +[Unit] +Description=VXLAN Overlay Setup for {{ inventory_hostname }} +After=network-online.target +Wants=network-online.target + +[Service] +Type=oneshot +ExecStart=/usr/local/bin/setup_sit_vxlan.sh {{ vxlan_dev_if }} {{ vxlan_local_ip }} {{ vxlan_remote_ip }} {{ vxlan_br_ip }} {{ vxlan_cidr_suffix }} {{ vxlan_vni }} +RemainAfterExit=true + +[Install] +WantedBy=multi-user.target diff --git a/roles/vhosts/vpn-overlay/vxlan/site/defaults/main.yml b/roles/vhosts/vpn-overlay/vxlan/site/defaults/main.yml new file mode 100644 index 0000000..6d9fb4f --- /dev/null +++ b/roles/vhosts/vpn-overlay/vxlan/site/defaults/main.yml @@ -0,0 +1,7 @@ +--- +# Default VXLAN settings for site nodes +vxlan_dev_if: wg0 +vxlan_vni: 100 +vxlan_cidr_suffix: 16 +overlay_config_path: config/sit/vpn-overlay.yaml + diff --git a/roles/vhosts/vpn-overlay/vxlan/site/files/setup_sit_vxlan.sh b/roles/vhosts/vpn-overlay/vxlan/site/files/setup_sit_vxlan.sh new file mode 100644 index 0000000..d2747cd --- /dev/null +++ b/roles/vhosts/vpn-overlay/vxlan/site/files/setup_sit_vxlan.sh @@ -0,0 +1,104 @@ +#!/bin/bash +# 多 peer 自动化 VXLAN Overlay 脚本(读取 /etc/vxlan-config.yaml) +# 用法: ./setup_sit_vxlan.sh [reset] + +set -e + +CONFIG_FILE="/etc/vxlan-config.yaml" +BR_IF="br0" + +# 需要 yq 解析 yaml +command -v yq >/dev/null 2>&1 || { echo >&2 "❌ 请安装 yq 命令(https://github.com/mikefarah/yq)"; exit 1; } + +if [[ "$1" == "reset" ]]; then + echo "🔄 正在清理 VXLAN Overlay 配置..." + + # 删除所有 vxlan 接口 + ip -o link show | awk -F': ' '/vxlan[0-9]+/ {print $2}' | while read -r iface; do + ip link set "$iface" down + ip link del "$iface" + echo "🧹 已删除接口 $iface" + done + + ip link show "$BR_IF" &>/dev/null && { + ip link set "$BR_IF" down + ip link del "$BR_IF" + echo "🧹 已删除桥接器 $BR_IF" + } + + echo "✅ 清理完成" + exit 0 +fi + +# 解析 config +DEV_IF="$(yq e '.dev_if' "$CONFIG_FILE")" +BRIDGE_IP="$(yq e '.bridge_ip' "$CONFIG_FILE")" +CIDR_SUFFIX="$(yq e '.cidr_suffix' "$CONFIG_FILE")" +PEER_COUNT=$(yq e '.peers | length' "$CONFIG_FILE") + +if [[ -z "$DEV_IF" || -z "$BRIDGE_IP" || "$PEER_COUNT" -eq 0 ]]; then + echo "❌ 配置错误:请检查 $CONFIG_FILE" + exit 1 +fi + +BRIDGE_CIDR="${BRIDGE_IP}/${CIDR_SUFFIX}" + +# 检查 dev_if 是否可用于 VXLAN +function is_vxlan_dev_usable() { + [[ -d "/sys/class/net/$1" ]] && grep -q "broadcast" "/sys/class/net/$1/flags" +} + +echo "🔍 检查 $DEV_IF 是否可用于 VXLAN..." +USE_DEV_PARAM=true +if ! is_vxlan_dev_usable "$DEV_IF"; then + echo "⚠️ $DEV_IF 不支持广播,将省略 dev 参数(通过路由走隧道)" + USE_DEV_PARAM=false +fi + +# 创建 bridge +if ! ip link show "$BR_IF" &>/dev/null; then + echo "🛠️ 创建桥接器 $BR_IF" + ip link add "$BR_IF" type bridge + ip link set "$BR_IF" up + ip addr add "$BRIDGE_CIDR" dev "$BR_IF" +fi + +# 启用转发 +sysctl -w net.ipv4.ip_forward=1 + +# 遍历 peers +for i in $(seq 0 $((PEER_COUNT - 1))); do + LOCAL_IP=$(yq e ".peers[$i].local_ip" "$CONFIG_FILE") + REMOTE_IP=$(yq e ".peers[$i].remote_ip" "$CONFIG_FILE") + VNI=$(yq e ".peers[$i].vxlan_id" "$CONFIG_FILE") + MTU=$(yq e ".peers[$i].mtu" "$CONFIG_FILE") + EXPOSE_PORT=$(yq e ".peers[$i].expose_port" "$CONFIG_FILE") + + VXLAN_IF="vxlan${VNI}" + + echo "🛠️ 创建 VXLAN 接口 $VXLAN_IF (local: $LOCAL_IP, remote: $REMOTE_IP, vni: $VNI)" + + # 清理旧接口 + ip link show "$VXLAN_IF" &>/dev/null && ip link set "$VXLAN_IF" down && ip link del "$VXLAN_IF" + + # 创建 vxlan 接口 + if $USE_DEV_PARAM; then + ip link add "$VXLAN_IF" type vxlan id "$VNI" dstport 4789 local "$LOCAL_IP" remote "$REMOTE_IP" dev "$DEV_IF" + else + ip link add "$VXLAN_IF" type vxlan id "$VNI" dstport 4789 local "$LOCAL_IP" remote "$REMOTE_IP" + fi + ip link set "$VXLAN_IF" mtu "$MTU" + ip link set "$VXLAN_IF" up + ip link set "$VXLAN_IF" master "$BR_IF" + + # 可选添加 DNAT + if [[ -n "$EXPOSE_PORT" && "$EXPOSE_PORT" != "null" ]]; then + echo "🌐 添加 DNAT 规则:公网:$EXPOSE_PORT → ${BRIDGE_IP}:443" + iptables -t nat -C PREROUTING -p tcp --dport "$EXPOSE_PORT" -j DNAT --to-destination "${BRIDGE_IP}:443" 2>/dev/null || \ + iptables -t nat -A PREROUTING -p tcp --dport "$EXPOSE_PORT" -j DNAT --to-destination "${BRIDGE_IP}:443" + fi + +done + +echo "" +echo "✅ 所有 VXLAN Overlay 配置完成" diff --git a/roles/vhosts/vpn-overlay/vxlan/site/tasks/main.yml b/roles/vhosts/vpn-overlay/vxlan/site/tasks/main.yml new file mode 100644 index 0000000..691a3aa --- /dev/null +++ b/roles/vhosts/vpn-overlay/vxlan/site/tasks/main.yml @@ -0,0 +1,54 @@ +--- +- name: Load site overlay config + set_fact: + overlay_data: "{{ lookup('file', overlay_config_path) | from_yaml }}" + +- name: Select current site from config + set_fact: + current_site: "{{ overlay_data.sites | selectattr('name', 'equalto', inventory_hostname) | list | first }}" + +- name: Fail if no matching site found + fail: + msg: "当前主机 {{ inventory_hostname }} 未在 config 中定义" + when: current_site is not defined + +- name: Select first hub as default + set_fact: + selected_hub: "{{ overlay_data.hubs[0] }}" + +- name: Set VXLAN parameters + set_fact: + vxlan_dev_if: "{{ current_site.interface}}" + vxlan_local_ip: "{{ current_site.local_ip }}" + vxlan_remote_ip: "{{ current_site.remote_ip }}" + vxlan_br_ip: "{{ current_site.br_ip }}" + vxlan_cidr_suffix: "{{ overlay_data.vxlan_cidr_suffix | default(16) }}" + vxlan_vni: "{{ overlay_data.vxlan_id | default(100) }}" + +- name: 使用 rsync 分发 VXLAN 脚本 + synchronize: + src: "files/setup_sit_vxlan.sh" + dest: /tmp/setup_sit_vxlan.sh + mode: push + +- name: 移动脚本并赋权到 /usr/local/bin + shell: | + mv /tmp/setup_sit_vxlan.sh /usr/local/bin/setup_sit_vxlan.sh + chmod +x /usr/local/bin/setup_sit_vxlan.sh + become: true + +- name: Render systemd unit for VXLAN + template: + src: vxlan-setup.service.j2 + dest: /etc/systemd/system/vxlan-setup.service + mode: '0644' + +- name: Reload systemd daemon + systemd: + daemon_reload: true + +- name: Enable and start VXLAN overlay setup + systemd: + name: vxlan-setup + enabled: true + state: started diff --git a/roles/vhosts/vpn-overlay/vxlan/site/templates/vxlan-config.yaml.j2 b/roles/vhosts/vpn-overlay/vxlan/site/templates/vxlan-config.yaml.j2 new file mode 100644 index 0000000..666111e --- /dev/null +++ b/roles/vhosts/vpn-overlay/vxlan/site/templates/vxlan-config.yaml.j2 @@ -0,0 +1,12 @@ +dev_if: eth0 +bridge_ip: 10.253.253.1 +cidr_suffix: 16 +peers: + - local_ip: 172.30.0.1 + remote_ip: 172.30.0.10 + vxlan_id: 100 + mtu: 1400 + - local_ip: 172.30.0.1 + remote_ip: 172.31.0.1 + vxlan_id: 100 + mtu: 1400 diff --git a/roles/vhosts/vpn-overlay/vxlan/site/templates/vxlan-setup.service.j2 b/roles/vhosts/vpn-overlay/vxlan/site/templates/vxlan-setup.service.j2 new file mode 100644 index 0000000..52f7e37 --- /dev/null +++ b/roles/vhosts/vpn-overlay/vxlan/site/templates/vxlan-setup.service.j2 @@ -0,0 +1,12 @@ +[Unit] +Description=VXLAN Overlay Setup for {{ inventory_hostname }} +After=network-online.target +Wants=network-online.target + +[Service] +Type=oneshot +ExecStart=/usr/local/bin/setup_sit_vxlan.sh add {{ vxlan_dev_if }} {{ vxlan_local_ip }} {{ vxlan_remote_ip }} {{ vxlan_br_ip }} {{ vxlan_cidr_suffix }} {{ vxlan_vni }} +RemainAfterExit=true + +[Install] +WantedBy=multi-user.target diff --git a/roles/vhosts/vpn-overlay/wireguard/hub/defaults/main.yml b/roles/vhosts/vpn-overlay/wireguard/hub/defaults/main.yml new file mode 100644 index 0000000..116c449 --- /dev/null +++ b/roles/vhosts/vpn-overlay/wireguard/hub/defaults/main.yml @@ -0,0 +1,4 @@ +wg_interface: "wg0" +overlay_config_path: "{{ playbook_dir }}/../../config/sit/vpn-overlay.yaml" +overlay_keys_path: "{{ playbook_dir }}/../../config/sit/vpn-keys.yaml" +wg_port: "51820" diff --git a/roles/vhosts/vpn-overlay/wireguard/hub/tasks/main.yml b/roles/vhosts/vpn-overlay/wireguard/hub/tasks/main.yml new file mode 100644 index 0000000..b1b6504 --- /dev/null +++ b/roles/vhosts/vpn-overlay/wireguard/hub/tasks/main.yml @@ -0,0 +1,56 @@ +--- +- name: 加载 overlay 配置(标准 YAML) + set_fact: + overlay_data: "{{ lookup('file', overlay_config_path) | from_yaml }}" + +- name: 加载密钥配置(支持 !vault) + include_vars: + file: "{{ overlay_keys_path }}" + name: overlay_keys + +- name: 提取当前 Hub 节点信息 + set_fact: + current_node: >- + {{ overlay_data.hubs | selectattr('name', 'equalto', inventory_hostname) | list | first }} + current_key: >- + {{ overlay_keys['keys'] | selectattr('name', 'equalto', inventory_hostname) | list | first }} + +- name: 提取所有对端 Peer 信息 + set_fact: + peer_nodes: >- + {{ (overlay_data.sites + overlay_data.hubs) + | selectattr('name', 'in', current_node.wireguard_peer) | list }} + peer_keys: >- + {{ overlay_keys['keys'] + | selectattr('name', 'in', current_node.wireguard_peer) | list }} + +- name: 校验 Peer 节点数量 + fail: + msg: "没有找到任何对端节点或对应密钥,请检查 wireguard_peer 设置" + when: peer_nodes | length == 0 or peer_keys | length == 0 + +- name: Ensure wireguard-tools is installed (Debian/Ubuntu) + apt: + name: wireguard-tools + state: present + when: ansible_os_family == 'Debian' + +- name: Ensure wireguard-tools is installed (RHEL/CentOS) + yum: + name: wireguard-tools + state: present + when: ansible_os_family == 'RedHat' + +- name: 渲染 wg0.conf + template: + src: wg0.conf.j2 + dest: /etc/wireguard/wg0.conf + mode: '0600' + become: true + +- name: 启用并启动 wg-quick@wg0 + systemd: + name: wg-quick@wg0 + enabled: true + state: started + become: true diff --git a/roles/vhosts/vpn-overlay/wireguard/hub/templates/wg0.conf.j2 b/roles/vhosts/vpn-overlay/wireguard/hub/templates/wg0.conf.j2 new file mode 100644 index 0000000..952866f --- /dev/null +++ b/roles/vhosts/vpn-overlay/wireguard/hub/templates/wg0.conf.j2 @@ -0,0 +1,16 @@ +[Interface] +PrivateKey = {{ current_key.private_key }} +Address = {{ current_node.wg_ip }}/32 +ListenPort = {{ wg_port }} +DNS = 8.8.8.8 +MTU = 1400 + +{% for peer, key in peer_nodes | zip(peer_keys) %} +{% if peer.name != inventory_hostname %} +[Peer] +PublicKey = {{ key.public_key }} +AllowedIPs = {{ peer.wg_ip }}/32 +Endpoint = {{ peer.public_ip }}:{{ overlay_data.hub_port | default(wg_port) }} +PersistentKeepalive = 25 +{% endif %} +{% endfor %} diff --git a/roles/vhosts/vpn-overlay/wireguard/site/defaults/main.yml b/roles/vhosts/vpn-overlay/wireguard/site/defaults/main.yml new file mode 100644 index 0000000..d61f1ba --- /dev/null +++ b/roles/vhosts/vpn-overlay/wireguard/site/defaults/main.yml @@ -0,0 +1,8 @@ +wg_interface: "wg0" + +# 默认配置文件路径,可在 playbook 中覆盖 +overlay_config_path: "{{ playbook_dir }}/../../config/sit/vpn-overlay.yaml" +overlay_keys_path: "{{ playbook_dir }}/../../config/sit/vpn-keys.yaml" + +# WireGuard 默认端口(若 overlay_data.hub_port 未定义) +wg_port: "51820" diff --git a/roles/vhosts/vpn-overlay/wireguard/site/tasks/main.yml b/roles/vhosts/vpn-overlay/wireguard/site/tasks/main.yml new file mode 100644 index 0000000..af26eec --- /dev/null +++ b/roles/vhosts/vpn-overlay/wireguard/site/tasks/main.yml @@ -0,0 +1,71 @@ +--- +- name: 加载 overlay 配置(标准 YAML) + set_fact: + overlay_data: "{{ lookup('file', overlay_config_path) | from_yaml }}" + +- name: 加载密钥配置(支持 !vault) + include_vars: + file: "{{ overlay_keys_path }}" + name: overlay_keys + +- name: 提取当前节点信息(作为 current) + set_fact: + current_node: >- + {{ (overlay_data.sites + overlay_data.hubs) + | selectattr('name', 'equalto', inventory_hostname) + | list | first }} + current_key: >- + {{ overlay_keys['keys'] + | selectattr('name', 'equalto', inventory_hostname) + | list | first }} + features: "{{ overlay_data.features }}" + +- name: 标准化 wireguard_peer 为列表 + set_fact: + wireguard_peers: >- + {{ [current_node.wireguard_peer] if current_node.wireguard_peer is string else current_node.wireguard_peer }} + +- name: 提取对端 peer 节点列表 + set_fact: + peer_node_list: >- + {{ (overlay_data.sites + overlay_data.hubs) + | selectattr('name', 'in', wireguard_peers) + | list }} + peer_key_list: >- + {{ overlay_keys['keys'] + | selectattr('name', 'in', wireguard_peers) + | list }} + +- name: 校验 wireguard_peer 是否匹配成功 + fail: + msg: "未找到对端节点 '{{ current_node.wireguard_peer }}' 或其密钥" + when: peer_node_list | length == 0 or peer_key_list | length == 0 + +- name: 设置对端节点与密钥 + set_fact: + peer_nodes: "{{ peer_node_list }}" + peer_keys: "{{ peer_key_list }}" + +- name: 提取最终配置变量(私钥、公钥、端口等) + set_fact: + wg_port: "{{ wg_port }}" + current_wg_ip: "{{ current_node.wg_ip }}" + current_interface: "{{ current_node.interface }}" + current_private_key: "{{ current_key.private_key }}" + current_allowed_ips: "{{ current_node.allowed_ips }}" + peer_public_key: "{{ peer_keys[0].public_key }}" + peer_endpoint: "{{ peer_nodes[0].public_ip }}:{{ overlay_data.hub_port | default(wg_port) }}" + +- name: 渲染 wg0.conf + template: + src: wg0.conf.j2 + dest: /etc/wireguard/wg0.conf + mode: '0600' + become: true + +- name: 启用并启动 wg-quick@wg0 + systemd: + name: wg-quick@wg0 + enabled: true + state: started + become: true diff --git a/roles/vhosts/vpn-overlay/wireguard/site/templates/wg0.conf.j2 b/roles/vhosts/vpn-overlay/wireguard/site/templates/wg0.conf.j2 new file mode 100644 index 0000000..02372fb --- /dev/null +++ b/roles/vhosts/vpn-overlay/wireguard/site/templates/wg0.conf.j2 @@ -0,0 +1,24 @@ +[Interface] +PrivateKey = {{ current_private_key }} +Address = {{ current_wg_ip }}/32 +ListenPort = {{ wg_port }} +DNS = 8.8.8.8 +MTU = 1400 + +PostUp = iptables -I FORWARD -o %i -j ACCEPT +PostUp = iptables -A FORWARD -i wg0 -j ACCEPT +PostUp = iptables -t nat -A POSTROUTING -o {{ current_interface }} -j MASQUERADE + +PostDown = iptables -D FORWARD -o %i -j ACCEPT +PostDown = iptables -D FORWARD -i wg0 -j ACCEPT +PostDown = iptables -t nat -D POSTROUTING -o {{ current_interface }} -j MASQUERADE + +[Peer] +PublicKey = {{ peer_public_key }} +AllowedIPs = {{ current_allowed_ips }} +{% if features.enable_vless %} +Endpoint = 127.0.0.1:51830 +{% else %} +Endpoint = {{ peer_endpoint }} +{% endif %} +PersistentKeepalive = 25 diff --git a/roles/vhosts/vpn-overlay/xray/hub/defaults/main.yml b/roles/vhosts/vpn-overlay/xray/hub/defaults/main.yml new file mode 100644 index 0000000..4a74ded --- /dev/null +++ b/roles/vhosts/vpn-overlay/xray/hub/defaults/main.yml @@ -0,0 +1,5 @@ +xray_main_port: 1443 +xray_cert_path: "/etc/ssl/onwalk.net.pem" +xray_key_path: "/etc/ssl/onwalk.net.key" +xray_bin_path: /usr/local/bin/xray +xray_config_dir: /usr/local/etc/xray diff --git a/roles/vhosts/vpn-overlay/xray/hub/handlers/main.yml b/roles/vhosts/vpn-overlay/xray/hub/handlers/main.yml new file mode 100644 index 0000000..e01f19a --- /dev/null +++ b/roles/vhosts/vpn-overlay/xray/hub/handlers/main.yml @@ -0,0 +1,6 @@ +--- +- name: Restart xray service + systemd: + name: xray.service + state: restarted + enabled: yes diff --git a/roles/vhosts/vpn-overlay/xray/hub/tasks/main.yml b/roles/vhosts/vpn-overlay/xray/hub/tasks/main.yml new file mode 100644 index 0000000..b4f4362 --- /dev/null +++ b/roles/vhosts/vpn-overlay/xray/hub/tasks/main.yml @@ -0,0 +1,70 @@ +--- +- name: Load overlay config from file + set_fact: + overlay_config: "{{ lookup('file', overlay_config_path) | from_yaml }}" + +- name: Convert overlay_config.hubs list to dict (hubs_map) + set_fact: + hubs_map: "{{ dict(overlay_config.hubs | map(attribute='name') | zip(overlay_config.hubs)) }}" + when: overlay_config.hubs is defined + +- name: Convert overlay_config.sites list to dict (sites_map) + set_fact: + sites_map: "{{ dict(overlay_config.sites | map(attribute='name') | zip(overlay_config.sites)) }}" + when: overlay_config.sites is defined + +- name: 显示主机名 + debug: + var: overlay_config + when: debug | default(false) + +- set_fact: + xray_uuid: "{{ hubs_map[inventory_hostname].xray.uuid }}" + xray_remote_domain: "{{ hubs_map[inventory_hostname].xray.remote_domain }}" + xray_cert_path: "{{ hubs_map[inventory_hostname].xray.cert_path }}" + xray_key_path: "{{ hubs_map[inventory_hostname].xray.key_path }}" + +- name: Install Xray using official script + shell: | + bash -c "$(curl -L https://github.com/XTLS/Xray-install/raw/main/install-release.sh)" + args: + creates: /usr/local/bin/xray + notify: + - Restart xray service + +- name: Ensure required directories exist + file: + path: "{{ item }}" + state: directory + mode: '0755' + loop: + - "{{ xray_bin_path | dirname }}" + - "{{ xray_config_dir }}" + +- name: Deploy Xray config templates + template: + src: "{{ item.src }}" + dest: "{{ item.dest }}" + mode: '0644' + loop: + - { src: "config.json.j2", dest: "{{ xray_config_dir }}/config.json" } + +- name: Deploy systemd service templates + template: + src: "{{ item.src }}" + dest: "{{ item.dest }}" + mode: '0644' + loop: + - { src: "xray.service.j2", dest: "/etc/systemd/system/xray.service" } + +- name: Reload systemd + systemd: + daemon_reload: yes + +- name: Enable and start xray services + systemd: + name: "{{ item }}" + enabled: yes + state: started + loop: + - xray.service diff --git a/roles/vhosts/vpn-overlay/xray/hub/templates/config.json.j2 b/roles/vhosts/vpn-overlay/xray/hub/templates/config.json.j2 new file mode 100644 index 0000000..84921b1 --- /dev/null +++ b/roles/vhosts/vpn-overlay/xray/hub/templates/config.json.j2 @@ -0,0 +1,84 @@ +{ + "log": { + "loglevel": "warning" + }, + "routing": { + "domainStrategy": "IPIfNonMatch", + "rules": [ + { + "type": "field", + "ip": [ + "geoip:cn" + ], + "outboundTag": "block" + } + ] + }, + "inbounds": [ + { + "listen": "0.0.0.0", + "port": {{ xray_main_port }}, + "protocol": "vless", + "settings": { + "clients": [ + { + "id": "{{ xray_uuid }}", + "flow": "xtls-rprx-vision" + } + ], + "decryption": "none", + "fallbacks": [ + { + "dest": "8001", + "xver": 1 + }, + { + "alpn": "h2", + "dest": "8002", + "xver": 1 + } + ] + }, + "streamSettings": { + "network": "tcp", + "security": "tls", + "tlsSettings": { + "rejectUnknownSni": true, + "minVersion": "1.2", + "certificates": [ + { + "ocspStapling": 3600, + "certificateFile": "{{ xray_cert_path }}", + "keyFile": "{{ xray_key_path }}" + } + ] + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + } + ], + "outbounds": [ + { + "protocol": "freedom", + "tag": "direct" + }, + { + "protocol": "blackhole", + "tag": "block" + } + ], + "policy": { + "levels": { + "0": { + "handshake": 2, + "connIdle": 120 + } + } + } +} diff --git a/roles/vhosts/vpn-overlay/xray/hub/templates/xray.service.j2 b/roles/vhosts/vpn-overlay/xray/hub/templates/xray.service.j2 new file mode 100644 index 0000000..978fbbd --- /dev/null +++ b/roles/vhosts/vpn-overlay/xray/hub/templates/xray.service.j2 @@ -0,0 +1,18 @@ +[Unit] +Description=Xray Service +Documentation=https://github.com/xtls +After=network.target nss-lookup.target + +[Service] +User=nobody +CapabilityBoundingSet=CAP_NET_ADMIN CAP_NET_BIND_SERVICE +AmbientCapabilities=CAP_NET_ADMIN CAP_NET_BIND_SERVICE +NoNewPrivileges=true +ExecStart=/usr/local/bin/xray run -config /usr/local/etc/xray/config.json +Restart=on-failure +RestartPreventExitStatus=23 +LimitNPROC=10000 +LimitNOFILE=1000000 + +[Install] +WantedBy=multi-user.target diff --git a/roles/vhosts/vpn-overlay/xray/site/defaults/main.yml b/roles/vhosts/vpn-overlay/xray/site/defaults/main.yml new file mode 100644 index 0000000..856b5d7 --- /dev/null +++ b/roles/vhosts/vpn-overlay/xray/site/defaults/main.yml @@ -0,0 +1,6 @@ +xray_main_port: 1443 +xray_tproxy_port: 51830 +xray_cert_path: "/etc/ssl/onwalk.net.pem" +xray_key_path: "/etc/ssl/onwalk.net.key" +xray_bin_path: /usr/local/bin/xray +xray_config_dir: /usr/local/etc/xray diff --git a/roles/vhosts/vpn-overlay/xray/site/handlers/main.yml b/roles/vhosts/vpn-overlay/xray/site/handlers/main.yml new file mode 100644 index 0000000..032a52c --- /dev/null +++ b/roles/vhosts/vpn-overlay/xray/site/handlers/main.yml @@ -0,0 +1,6 @@ +--- +- name: Restart Xray-client service + systemd: + name: xray-client.service + state: restarted + enabled: yes diff --git a/roles/vhosts/vpn-overlay/xray/site/tasks/main.yml b/roles/vhosts/vpn-overlay/xray/site/tasks/main.yml new file mode 100644 index 0000000..9759f6d --- /dev/null +++ b/roles/vhosts/vpn-overlay/xray/site/tasks/main.yml @@ -0,0 +1,70 @@ +--- +- name: Load overlay config from file + set_fact: + overlay_config: "{{ lookup('file', overlay_config_path) | from_yaml }}" + +- name: Convert overlay_config.hubs list to dict (hubs_map) + set_fact: + hubs_map: "{{ dict(overlay_config.hubs | map(attribute='name') | zip(overlay_config.hubs)) }}" + when: overlay_config.hubs is defined + +- name: Convert overlay_config.sites list to dict (sites_map) + set_fact: + sites_map: "{{ dict(overlay_config.sites | map(attribute='name') | zip(overlay_config.sites)) }}" + when: overlay_config.sites is defined + +- name: 显示主机名 + debug: + var: overlay_config + when: debug | default(false) + +- set_fact: + xray_uuid: "{{ sites_map[inventory_hostname].xray.uuid }}" + xray_remote_domain: "{{ sites_map[inventory_hostname].xray.remote_domain }}" + xray_cert_path: "{{ sites_map[inventory_hostname].xray.cert_path }}" + xray_key_path: "{{ sites_map[inventory_hostname].xray.key_path }}" + +- name: Install Xray using official script + shell: | + bash -c "$(curl -L https://github.com/XTLS/Xray-install/raw/main/install-release.sh)" + args: + creates: /usr/local/bin/xray + notify: + - Restart xray service + +- name: Ensure required directories exist + file: + path: "{{ item }}" + state: directory + mode: '0755' + loop: + - "{{ xray_bin_path | dirname }}" + - "{{ xray_config_dir }}" + +- name: Deploy Xray config templates + template: + src: "{{ item.src }}" + dest: "{{ item.dest }}" + mode: '0644' + loop: + - { src: "client-config.json.j2", dest: "{{ xray_config_dir }}/client-config.json" } + +- name: Deploy systemd service templates + template: + src: "{{ item.src }}" + dest: "{{ item.dest }}" + mode: '0644' + loop: + - { src: "xray-client.service.j2", dest: "/etc/systemd/system/xray-client.service" } + +- name: Reload systemd + systemd: + daemon_reload: yes + +- name: Enable and start xray services + systemd: + name: "{{ item }}" + enabled: yes + state: started + loop: + - xray-client.service diff --git a/roles/vhosts/vpn-overlay/xray/site/templates/client-config.json.j2 b/roles/vhosts/vpn-overlay/xray/site/templates/client-config.json.j2 new file mode 100644 index 0000000..25a79e0 --- /dev/null +++ b/roles/vhosts/vpn-overlay/xray/site/templates/client-config.json.j2 @@ -0,0 +1,94 @@ +{ + "log": { + "loglevel": "debug" + }, + "routing": { + "domainStrategy": "IPIfNonMatch", + "rules": [ + { + "type": "field", + "domain": [ + "geosite:cn", + "geosite:private" + ], + "outboundTag": "direct" + }, + { + "type": "field", + "ip": [ + "geoip:cn", + "geoip:private" + ], + "outboundTag": "direct" + } + ] + }, + "inbounds": [ + { + "listen": "127.0.0.1", + "port": 1080, + "protocol": "socks", + "settings": { + "udp": true + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + }, + { + "listen": "127.0.0.1", + "port": 1081, + "protocol": "http", + "settings": {}, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + } + ], + "outbounds": [ + { + "protocol": "vless", + "settings": { + "vnext": [ + { + "address": "{{ xray_remote_domain }}", + "port": {{ xray_main_port }}, + "users": [ + { + "id": "{{ xray_uuid }}", + "encryption": "none", + "flow": "xtls-rprx-vision" + } + ] + } + ] + }, + "streamSettings": { + "network": "tcp", + "security": "tls", + "tlsSettings": { + "serverName": "{{ xray_remote_domain }}", + "allowInsecure": false, + "fingerprint": "chrome" + } + }, + "tag": "proxy" + }, + { + "protocol": "freedom", + "tag": "direct" + }, + { + "protocol": "blackhole", + "tag": "block" + } + ] +} diff --git a/roles/vhosts/vpn-overlay/xray/site/templates/xray-client.service.j2 b/roles/vhosts/vpn-overlay/xray/site/templates/xray-client.service.j2 new file mode 100644 index 0000000..6046de4 --- /dev/null +++ b/roles/vhosts/vpn-overlay/xray/site/templates/xray-client.service.j2 @@ -0,0 +1,18 @@ +[Unit] +Description=Xray Client Service +Documentation=https://github.com/xtls +After=network.target nss-lookup.target + +[Service] +User=nobody +CapabilityBoundingSet=CAP_NET_ADMIN CAP_NET_BIND_SERVICE +AmbientCapabilities=CAP_NET_ADMIN CAP_NET_BIND_SERVICE +NoNewPrivileges=true +ExecStart=/usr/local/bin/xray run -config /usr/local/etc/xray/client-config.json +Restart=on-failure +RestartPreventExitStatus=23 +LimitNPROC=10000 +LimitNOFILE=1000000 + +[Install] +WantedBy=multi-user.target diff --git a/roles/vhosts/vpn-overlay/xray/tproxy/defaults/main.yml b/roles/vhosts/vpn-overlay/xray/tproxy/defaults/main.yml new file mode 100644 index 0000000..856b5d7 --- /dev/null +++ b/roles/vhosts/vpn-overlay/xray/tproxy/defaults/main.yml @@ -0,0 +1,6 @@ +xray_main_port: 1443 +xray_tproxy_port: 51830 +xray_cert_path: "/etc/ssl/onwalk.net.pem" +xray_key_path: "/etc/ssl/onwalk.net.key" +xray_bin_path: /usr/local/bin/xray +xray_config_dir: /usr/local/etc/xray diff --git a/roles/vhosts/vpn-overlay/xray/tproxy/handlers/main.yml b/roles/vhosts/vpn-overlay/xray/tproxy/handlers/main.yml new file mode 100644 index 0000000..f94d871 --- /dev/null +++ b/roles/vhosts/vpn-overlay/xray/tproxy/handlers/main.yml @@ -0,0 +1,6 @@ +--- +- name: Restart xray-tproxy service + systemd: + name: xray-tproxy.service + state: restarted + enabled: yes diff --git a/roles/vhosts/vpn-overlay/xray/tproxy/tasks/main.yml b/roles/vhosts/vpn-overlay/xray/tproxy/tasks/main.yml new file mode 100644 index 0000000..03c5f5d --- /dev/null +++ b/roles/vhosts/vpn-overlay/xray/tproxy/tasks/main.yml @@ -0,0 +1,82 @@ +--- +- name: Load overlay config from file + set_fact: + overlay_config: "{{ lookup('file', overlay_config_path) | from_yaml }}" + +- name: Convert overlay_config.hubs list to dict (hubs_map) + set_fact: + hubs_map: "{{ dict(overlay_config.hubs | map(attribute='name') | zip(overlay_config.hubs)) }}" + when: overlay_config.hubs is defined + +- name: Convert overlay_config.sites list to dict (sites_map) + set_fact: + sites_map: "{{ dict(overlay_config.sites | map(attribute='name') | zip(overlay_config.sites)) }}" + when: overlay_config.sites is defined + +- name: Convert all nodes (hubs + sites) to one dict as node_map + set_fact: + node_map: >- + {{ dict((overlay_config.hubs + overlay_config.sites) + | map(attribute='name') + | zip(overlay_config.hubs + overlay_config.sites)) }} + +- name: 显示主机名 + debug: + var: node_map + when: debug | default(true) + +- name: Show value for this node + debug: + msg: "{{ node_map[inventory_hostname] }}" + when: debug | default(true) + +- set_fact: + xray_uuid: "{{ node_map[inventory_hostname].xray.uuid }}" + xray_remote_domain: "{{ node_map[inventory_hostname].xray.remote_domain }}" + xray_cert_path: "{{ node_map[inventory_hostname].xray.cert_path }}" + xray_key_path: "{{ node_map[inventory_hostname].xray.key_path }}" + +- name: Install Xray using official script + shell: | + bash -c "$(curl -L https://github.com/XTLS/Xray-install/raw/main/install-release.sh)" + args: + creates: /usr/local/bin/xray + notify: + - Restart xray-tproxy service + +- name: Ensure required directories exist + file: + path: "{{ item }}" + state: directory + mode: '0755' + loop: + - "{{ xray_bin_path | dirname }}" + - "{{ xray_config_dir }}" + +- name: Deploy Xray config templates + template: + src: "{{ item.src }}" + dest: "{{ item.dest }}" + mode: '0644' + loop: + - { src: "tproxy-config.json.j2", dest: "{{ xray_config_dir }}/tproxy-config.json" } + +- name: Deploy systemd service templates + template: + src: "{{ item.src }}" + dest: "{{ item.dest }}" + mode: '0644' + loop: + - { src: "xray-tproxy.service.j2", dest: "/etc/systemd/system/xray-tproxy.service" } + +- name: Reload systemd + systemd: + daemon_reload: yes + +- name: Enable and start xray services + systemd: + name: "{{ item }}" + enabled: yes + state: started + loop: + - xray-tproxy.service diff --git a/roles/vhosts/vpn-overlay/xray/tproxy/templates/tproxy-config.json.j2 b/roles/vhosts/vpn-overlay/xray/tproxy/templates/tproxy-config.json.j2 new file mode 100644 index 0000000..9c54e7a --- /dev/null +++ b/roles/vhosts/vpn-overlay/xray/tproxy/templates/tproxy-config.json.j2 @@ -0,0 +1,58 @@ +{ + "log": { + "loglevel": "info" + }, + "routing": { + "rules": [] + }, + "inbounds": [ + { + "listen": "127.0.0.1", + "port": 51830, + "protocol": "dokodemo-door", + "settings": { + "address": "{{ xray_remote_domain }}", + "port": 51820, + "network": "udp" + } + } + ], + "outbounds": [ + { + "protocol": "vless", + "settings": { + "vnext": [ + { + "address": "{{ xray_remote_domain }}", + "port": 1443, + "users": [ + { + "id": "{{ xray_uuid }}", + "encryption": "none", + "flow": "xtls-rprx-vision" + } + ] + } + ] + }, + "streamSettings": { + "network": "tcp", + "security": "tls", + "tlsSettings": { + "serverName": "{{ xray_remote_domain }}", + "allowInsecure": false, + "fingerprint": "chrome" + } + }, + "tag": "proxy" + }, + { + "protocol": "freedom", + "tag": "direct" + }, + { + "protocol": "blackhole", + "tag": "block" + } + ] +} diff --git a/roles/vhosts/vpn-overlay/xray/tproxy/templates/xray-tproxy.service.j2 b/roles/vhosts/vpn-overlay/xray/tproxy/templates/xray-tproxy.service.j2 new file mode 100644 index 0000000..f440158 --- /dev/null +++ b/roles/vhosts/vpn-overlay/xray/tproxy/templates/xray-tproxy.service.j2 @@ -0,0 +1,18 @@ +[Unit] +Description=Xray Tproxy Service +Documentation=https://github.com/xtls +After=network.target nss-lookup.target + +[Service] +User=nobody +CapabilityBoundingSet=CAP_NET_ADMIN CAP_NET_BIND_SERVICE +AmbientCapabilities=CAP_NET_ADMIN CAP_NET_BIND_SERVICE +NoNewPrivileges=true +ExecStart=/usr/local/bin/xray run -config /usr/local/etc/xray/tproxy-config.json +Restart=on-failure +RestartPreventExitStatus=23 +LimitNPROC=10000 +LimitNOFILE=1000000 + +[Install] +WantedBy=multi-user.target diff --git a/vpn-overlay-dnat.yaml b/vpn-overlay-dnat.yaml new file mode 100644 index 0000000..c09c17e --- /dev/null +++ b/vpn-overlay-dnat.yaml @@ -0,0 +1,8 @@ +- name: Setup DNAT rules + hosts: all + become: yes + gather_facts: no + vars: + overlay_config_path: "{{ playbook_dir }}/../../config/sit/vpn-overlay.yaml" + roles: + - vhosts/vpn-overlay/setup-dnat diff --git a/vpn-overlay-vxlan-hub.yaml b/vpn-overlay-vxlan-hub.yaml new file mode 100644 index 0000000..4399f42 --- /dev/null +++ b/vpn-overlay-vxlan-hub.yaml @@ -0,0 +1,8 @@ +- name: Run infrastructure setup + hosts: all + become: yes + gather_facts: yes + vars: + overlay_config_path: "{{ playbook_dir }}/../../config/sit/vpn-overlay.yaml" + roles: + - vhosts/vpn-overlay/vxlan/hub diff --git a/vpn-overlay-vxlan-site.yaml b/vpn-overlay-vxlan-site.yaml new file mode 100644 index 0000000..1a64ec7 --- /dev/null +++ b/vpn-overlay-vxlan-site.yaml @@ -0,0 +1,8 @@ +- name: Run infrastructure setup + hosts: all + become: yes + gather_facts: yes + vars: + overlay_config_path: "{{ playbook_dir }}/../../config/sit/vpn-overlay.yaml" + roles: + - vhosts/vpn-overlay/vxlan/site diff --git a/vpn-wireguard-hub.yaml b/vpn-wireguard-hub.yaml new file mode 100644 index 0000000..ecf2d9d --- /dev/null +++ b/vpn-wireguard-hub.yaml @@ -0,0 +1,8 @@ +- name: Setup WireGuard for hub + hosts: all + become: true + vars: + overlay_config_path: "{{ playbook_dir }}/../../config/sit/vpn-overlay.yaml" + overlay_keys_path: "{{ playbook_dir }}/../../config/sit/vpn-keys.yaml" + roles: + - role: vhosts/vpn-overlay/wireguard/hub diff --git a/vpn-wireguard-site.yaml b/vpn-wireguard-site.yaml new file mode 100644 index 0000000..cf5bdaf --- /dev/null +++ b/vpn-wireguard-site.yaml @@ -0,0 +1,8 @@ +- name: Setup WireGuard for site + hosts: all + become: true + vars: + overlay_config_path: "{{ playbook_dir }}/../../config/sit/vpn-overlay.yaml" + overlay_keys_path: "{{ playbook_dir }}/../../config/sit/vpn-keys.yaml" + roles: + - vhosts/vpn-overlay/wireguard/site diff --git a/vpn-xray-client.yaml b/vpn-xray-client.yaml new file mode 100644 index 0000000..5cc1b1e --- /dev/null +++ b/vpn-xray-client.yaml @@ -0,0 +1,8 @@ +- name: Setup Xray for hub + hosts: all + become: true + vars: + overlay_config_path: "{{ playbook_dir }}/../../config/sit/vpn-overlay.yaml" + overlay_keys_path: "{{ playbook_dir }}/../../config/sit/vpn-keys.yaml" + roles: + - role: vhosts/vpn-overlay/xray/site diff --git a/vpn-xray-hub.yaml b/vpn-xray-hub.yaml new file mode 100644 index 0000000..e1d8820 --- /dev/null +++ b/vpn-xray-hub.yaml @@ -0,0 +1,8 @@ +- name: Setup Xray for hub + hosts: all + become: true + vars: + overlay_config_path: "{{ playbook_dir }}/../../config/sit/vpn-overlay.yaml" + overlay_keys_path: "{{ playbook_dir }}/../../config/sit/vpn-keys.yaml" + roles: + - role: vhosts/vpn-overlay/xray/hub diff --git a/vpn-xray-tproxy.yaml b/vpn-xray-tproxy.yaml new file mode 100644 index 0000000..1eaceee --- /dev/null +++ b/vpn-xray-tproxy.yaml @@ -0,0 +1,8 @@ +- name: Setup Xray for hub + hosts: all + become: true + vars: + overlay_config_path: "{{ playbook_dir }}/../../config/sit/vpn-overlay.yaml" + overlay_keys_path: "{{ playbook_dir }}/../../config/sit/vpn-keys.yaml" + roles: + - role: vhosts/vpn-overlay/xray/tproxy/