{
  "annotations": {
    "list": [
      {
        "builtIn": 1,
        "datasource": {
          "type": "grafana",
          "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": "Investibook 服务运行健康：K8s 副本与重启、HTTP/Chat；「2) CPU / Memory」按 **Deployment**（Pod 前缀）过滤：**kube-state-metrics** 指标用 **exported_namespace / exported_pod**；**kubelet cAdvisor** 与由其衍生的 recording（如 node_namespace_pod_container:*）用 **namespace / pod**。Namespace 为文本框；无 Cluster/Pod 变量。流量类默认 1h 窗口。",
  "editable": true,
  "fiscalYearStartMonth": 0,
  "graphTooltip": 1,
  "id": 9430,
  "links": [],
  "liveNow": false,
  "panels": [
    {
      "collapsed": false,
      "gridPos": {
        "h": 1,
        "w": 24,
        "x": 0,
        "y": 0
      },
      "id": 2,
      "panels": [],
      "title": "1) 健康摘要",
      "type": "row"
    },
    {
      "datasource": {
        "type": "prometheus",
        "uid": "${datasource}"
      },
      "description": "可用副本数 / 期望副本数（Deployment）",
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "thresholds"
          },
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "red",
                "value": null
              },
              {
                "color": "yellow",
                "value": 0.99
              },
              {
                "color": "green",
                "value": 1
              }
            ]
          },
          "unit": "percentunit"
        },
        "overrides": []
      },
      "gridPos": {
        "h": 5,
        "w": 4,
        "x": 0,
        "y": 1
      },
      "id": 10,
      "options": {
        "colorMode": "value",
        "graphMode": "none",
        "justifyMode": "auto",
        "orientation": "auto",
        "reduceOptions": {
          "calcs": ["lastNotNull"],
          "fields": "",
          "values": false
        },
        "textMode": "auto"
      },
      "pluginVersion": "9.2.4",
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${datasource}"
          },
          "editorMode": "code",
          "expr": "min(\n  kube_deployment_status_replicas_available{exported_namespace=~\"$namespace\"}\n  / clamp_min(kube_deployment_spec_replicas{exported_namespace=~\"$namespace\"}, 1)\n)",
          "range": true,
          "refId": "A"
        }
      ],
      "title": "副本 可用/期望（min）",
      "type": "stat"
    },
    {
      "datasource": {
        "type": "prometheus",
        "uid": "${datasource}"
      },
      "description": "非 5xx 请求占比（1h increase）。无 HTTP 请求时不显示比例（避免 0/分母钳位 带来的误导）。",
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "thresholds"
          },
          "decimals": 0,
          "mappings": [],
          "max": 1,
          "min": 0,
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "red",
                "value": null
              },
              {
                "color": "yellow",
                "value": 0.95
              },
              {
                "color": "green",
                "value": 0.99
              }
            ]
          },
          "unit": "percentunit"
        },
        "overrides": []
      },
      "gridPos": {
        "h": 5,
        "w": 4,
        "x": 4,
        "y": 1
      },
      "id": 11,
      "options": {
        "colorMode": "value",
        "graphMode": "area",
        "justifyMode": "auto",
        "orientation": "auto",
        "reduceOptions": {
          "calcs": ["lastNotNull"],
          "fields": "",
          "values": false
        },
        "textMode": "auto"
      },
      "pluginVersion": "9.2.4",
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${datasource}"
          },
          "editorMode": "code",
          "exemplar": false,
          "expr": "(\n  sum(increase(investibook_http_requests_total{status_code!~\"5..\"}[1h]))\n  / sum(increase(investibook_http_requests_total[1h]))\n)\nand\n(\n  sum(increase(investibook_http_requests_total[1h])) > 0\n)",
          "instant": true,
          "range": false,
          "refId": "A"
        }
      ],
      "title": "HTTP 成功率（非 5xx）",
      "type": "stat"
    },
    {
      "datasource": {
        "type": "prometheus",
        "uid": "${datasource}"
      },
      "description": "finish_reason=completed 的 completions 占比（1h）。过去 1h 无 chat completion 时不显示（分母为 0 不算 100% 也不算 0% 失败）。",
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "thresholds"
          },
          "decimals": 0,
          "mappings": [],
          "max": 1,
          "min": 0,
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "red",
                "value": null
              },
              {
                "color": "yellow",
                "value": 0.85
              },
              {
                "color": "green",
                "value": 0.95
              }
            ]
          },
          "unit": "percentunit"
        },
        "overrides": []
      },
      "gridPos": {
        "h": 5,
        "w": 4,
        "x": 8,
        "y": 1
      },
      "id": 12,
      "options": {
        "colorMode": "value",
        "graphMode": "area",
        "justifyMode": "auto",
        "orientation": "auto",
        "reduceOptions": {
          "calcs": ["lastNotNull"],
          "fields": "",
          "values": false
        },
        "textMode": "auto"
      },
      "pluginVersion": "9.2.4",
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${datasource}"
          },
          "editorMode": "code",
          "exemplar": false,
          "expr": "(\n  sum(increase(investibook_ai_chat_completions_total{finish_reason=\"completed\"}[1h]))\n  / sum(increase(investibook_ai_chat_completions_total[1h]))\n)\nand\n(\n  sum(increase(investibook_ai_chat_completions_total[1h])) > 0\n)",
          "instant": false,
          "range": true,
          "refId": "A"
        }
      ],
      "title": "Chat 完成率（completed）",
      "type": "stat"
    },
    {
      "datasource": {
        "type": "prometheus",
        "uid": "${datasource}"
      },
      "description": "最近 1h 内容器重启次数增量",
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "thresholds"
          },
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              },
              {
                "color": "yellow",
                "value": 1
              },
              {
                "color": "red",
                "value": 3
              }
            ]
          },
          "unit": "short"
        },
        "overrides": []
      },
      "gridPos": {
        "h": 5,
        "w": 4,
        "x": 12,
        "y": 1
      },
      "id": 13,
      "options": {
        "colorMode": "value",
        "graphMode": "none",
        "justifyMode": "auto",
        "orientation": "auto",
        "reduceOptions": {
          "calcs": ["lastNotNull"],
          "fields": "",
          "values": false
        },
        "textMode": "auto"
      },
      "pluginVersion": "9.2.4",
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${datasource}"
          },
          "editorMode": "code",
          "expr": "sum(increase(kube_pod_container_status_restarts_total{exported_namespace=~\"$namespace\"}[1h]))",
          "range": true,
          "refId": "A"
        }
      ],
      "title": "容器重启（1h Δ）",
      "type": "stat"
    },
    {
      "datasource": {
        "type": "prometheus",
        "uid": "${datasource}"
      },
      "description": "phase=Running 的 Pod 数（应等于工作负载副本）",
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "thresholds"
          },
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "red",
                "value": null
              },
              {
                "color": "green",
                "value": 1
              }
            ]
          },
          "unit": "short"
        },
        "overrides": []
      },
      "gridPos": {
        "h": 5,
        "w": 4,
        "x": 16,
        "y": 1
      },
      "id": 14,
      "options": {
        "colorMode": "value",
        "graphMode": "none",
        "justifyMode": "auto",
        "orientation": "auto",
        "reduceOptions": {
          "calcs": ["lastNotNull"],
          "fields": "",
          "values": false
        },
        "textMode": "auto"
      },
      "pluginVersion": "9.2.4",
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${datasource}"
          },
          "editorMode": "code",
          "expr": "sum(kube_pod_status_phase{exported_namespace=~\"$namespace\", phase=\"Running\"})",
          "range": true,
          "refId": "A"
        }
      ],
      "title": "Running Pod 数",
      "type": "stat"
    },
    {
      "datasource": {
        "type": "prometheus",
        "uid": "${datasource}"
      },
      "description": "Waiting 原因（如 CrashLoopBackOff）",
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "thresholds"
          },
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              },
              {
                "color": "red",
                "value": 1
              }
            ]
          },
          "unit": "short"
        },
        "overrides": []
      },
      "gridPos": {
        "h": 5,
        "w": 4,
        "x": 20,
        "y": 1
      },
      "id": 15,
      "options": {
        "colorMode": "value",
        "graphMode": "none",
        "justifyMode": "auto",
        "orientation": "auto",
        "reduceOptions": {
          "calcs": ["lastNotNull"],
          "fields": "",
          "values": false
        },
        "textMode": "auto"
      },
      "pluginVersion": "9.2.4",
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${datasource}"
          },
          "editorMode": "code",
          "expr": "sum(kube_pod_container_status_waiting_reason{exported_namespace=~\"$namespace\", reason!=\"ContainerCreating\"}) or vector(0)",
          "range": true,
          "refId": "A"
        }
      ],
      "title": "异常 Waiting（非 Creating）",
      "type": "stat"
    },
    {
      "collapsed": false,
      "gridPos": {
        "h": 1,
        "w": 24,
        "x": 0,
        "y": 6
      },
      "id": 60,
      "panels": [],
      "title": "2) CPU / Memory",
      "type": "row"
    },
    {
      "aliasColors": {},
      "bars": false,
      "dashLength": 10,
      "dashes": false,
      "datasource": {
        "type": "prometheus",
        "uid": "${datasource}"
      },
      "fill": 10,
      "fillGradient": 0,
      "gridPos": {
        "h": 7,
        "w": 9,
        "x": 0,
        "y": 7
      },
      "hiddenSeries": false,
      "id": 61,
      "interval": "1m",
      "legend": {
        "alignAsTable": true,
        "avg": false,
        "current": false,
        "max": false,
        "min": false,
        "rightSide": true,
        "show": true,
        "total": false,
        "values": false
      },
      "lines": true,
      "linewidth": 0,
      "links": [],
      "nullPointMode": "null as zero",
      "options": {
        "alertThreshold": true
      },
      "percentage": false,
      "pluginVersion": "9.2.4",
      "pointradius": 5,
      "points": false,
      "renderer": "flot",
      "seriesOverrides": [
        {
          "alias": "requests",
          "color": "#F2495C",
          "fill": 0,
          "hideTooltip": true,
          "legend": true,
          "linewidth": 2,
          "stack": false
        },
        {
          "alias": "limits",
          "color": "#FF9830",
          "fill": 0,
          "hideTooltip": true,
          "legend": true,
          "linewidth": 2,
          "stack": false
        }
      ],
      "spaceLength": 10,
      "stack": true,
      "steppedLine": false,
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${datasource}"
          },
          "editorMode": "code",
          "expr": "sum(node_namespace_pod_container:container_cpu_usage_seconds_total:sum_rate{namespace=~\"$namespace\", pod=~\"${deployment:regex}-.*\"}) by (container)",
          "format": "time_series",
          "legendFormat": "{{container}}",
          "range": true,
          "refId": "A"
        },
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${datasource}"
          },
          "editorMode": "code",
          "expr": "sum(kube_pod_container_resource_requests{job=\"kube-state-metrics\", exported_namespace=~\"$namespace\", exported_pod=~\"${deployment:regex}-.*\", resource=\"cpu\"})",
          "format": "time_series",
          "legendFormat": "requests",
          "range": true,
          "refId": "B"
        },
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${datasource}"
          },
          "editorMode": "code",
          "expr": "sum(kube_pod_container_resource_limits{job=\"kube-state-metrics\", exported_namespace=~\"$namespace\", exported_pod=~\"${deployment:regex}-.*\", resource=\"cpu\"})",
          "format": "time_series",
          "legendFormat": "limits",
          "range": true,
          "refId": "C"
        }
      ],
      "thresholds": [],
      "timeRegions": [],
      "title": "CPU Usage",
      "tooltip": {
        "shared": false,
        "sort": 2,
        "value_type": "individual"
      },
      "type": "graph",
      "xaxis": {
        "mode": "time",
        "show": true,
        "values": []
      },
      "yaxes": [
        {
          "$$hashKey": "object:146",
          "format": "short",
          "logBase": 1,
          "min": 0,
          "show": true
        },
        {
          "$$hashKey": "object:147",
          "format": "short",
          "logBase": 1,
          "show": false
        }
      ],
      "yaxis": {
        "align": false
      }
    },
    {
      "datasource": {
        "type": "prometheus",
        "uid": "${datasource}"
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "palette-classic"
          },
          "custom": {
            "axisCenteredZero": false,
            "axisColorMode": "text",
            "axisLabel": "",
            "axisPlacement": "auto",
            "barAlignment": 0,
            "drawStyle": "line",
            "fillOpacity": 100,
            "gradientMode": "none",
            "hideFrom": {
              "legend": false,
              "tooltip": false,
              "viz": false
            },
            "lineInterpolation": "linear",
            "lineWidth": 0,
            "pointSize": 5,
            "scaleDistribution": {
              "type": "linear"
            },
            "showPoints": "never",
            "spanNulls": false,
            "stacking": {
              "group": "A",
              "mode": "normal"
            },
            "thresholdsStyle": {
              "mode": "line+area"
            }
          },
          "mappings": [],
          "max": 1,
          "min": 0,
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "transparent",
                "value": null
              },
              {
                "color": "red",
                "value": 0.25
              }
            ]
          },
          "unit": "percentunit"
        },
        "overrides": []
      },
      "gridPos": {
        "h": 7,
        "w": 9,
        "x": 9,
        "y": 7
      },
      "id": 62,
      "interval": "1m",
      "links": [],
      "options": {
        "legend": {
          "calcs": [],
          "displayMode": "table",
          "placement": "right",
          "showLegend": true
        },
        "tooltip": {
          "mode": "single",
          "sort": "none"
        }
      },
      "pluginVersion": "9.2.4",
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${datasource}"
          },
          "editorMode": "code",
          "expr": "sum(increase(container_cpu_cfs_throttled_periods_total{job=\"kubelet-cadvisor\", metrics_path=\"/metrics/cadvisor\", namespace=~\"$namespace\", pod=~\"${deployment:regex}-.*\", container!=\"\"}[$__rate_interval])) by (container) / clamp_min(sum(increase(container_cpu_cfs_periods_total{job=\"kubelet-cadvisor\", metrics_path=\"/metrics/cadvisor\", namespace=~\"$namespace\", pod=~\"${deployment:regex}-.*\", container!=\"\"}[$__rate_interval])) by (container), 1e-9)",
          "format": "time_series",
          "legendFormat": "{{container}}",
          "range": true,
          "refId": "A"
        }
      ],
      "title": "CPU Throttling",
      "type": "timeseries"
    },
    {
      "aliasColors": {},
      "bars": false,
      "columns": [],
      "dashLength": 10,
      "dashes": false,
      "datasource": {
        "type": "prometheus",
        "uid": "${datasource}"
      },
      "description": "cAdvisor 用量：namespace/pod 上取数后复制为 **exported_pod**、**exported_container**（与工作负载一致）。KSM request/limit：按 **exported_pod**、**exported_container** 聚合（联邦下 `container` 常为抓取端 kube-state-metrics 容器名，不可用）。 cAdvisor job job=~\"kubelet(-cadvisor)?\"。",
      "fill": 1,
      "fontSize": "100%",
      "gridPos": {
        "h": 7,
        "w": 6,
        "x": 18,
        "y": 7
      },
      "id": 63,
      "interval": "1m",
      "legend": {
        "alignAsTable": true,
        "avg": false,
        "current": false,
        "max": false,
        "min": false,
        "rightSide": true,
        "show": true,
        "total": false,
        "values": false
      },
      "lines": true,
      "linewidth": 1,
      "links": [],
      "nullPointMode": "null as zero",
      "percentage": false,
      "pointradius": 5,
      "points": false,
      "renderer": "flot",
      "seriesOverrides": [],
      "showHeader": true,
      "sort": {
        "col": 0,
        "desc": true
      },
      "spaceLength": 10,
      "stack": false,
      "steppedLine": false,
      "styles": [
        {
          "alias": "Time",
          "align": "auto",
          "dateFormat": "YYYY-MM-DD HH:mm:ss",
          "pattern": "Time",
          "type": "hidden"
        },
        {
          "alias": "CPU Usage",
          "align": "auto",
          "colors": [],
          "dateFormat": "YYYY-MM-DD HH:mm:ss",
          "decimals": 2,
          "link": false,
          "linkTargetBlank": false,
          "linkTooltip": "Drill down",
          "linkUrl": "",
          "pattern": "Value #A",
          "thresholds": [],
          "type": "number",
          "unit": "short"
        },
        {
          "alias": "CPU Requests",
          "align": "auto",
          "colors": [],
          "dateFormat": "YYYY-MM-DD HH:mm:ss",
          "decimals": 2,
          "link": false,
          "linkTargetBlank": false,
          "linkTooltip": "Drill down",
          "linkUrl": "",
          "pattern": "Value #B",
          "thresholds": [],
          "type": "number",
          "unit": "short"
        },
        {
          "alias": "CPU Requests %",
          "align": "auto",
          "colors": [],
          "dateFormat": "YYYY-MM-DD HH:mm:ss",
          "decimals": 2,
          "link": false,
          "linkTargetBlank": false,
          "linkTooltip": "Drill down",
          "linkUrl": "",
          "pattern": "Value #C",
          "thresholds": [],
          "type": "number",
          "unit": "percentunit"
        },
        {
          "alias": "CPU Limits",
          "align": "auto",
          "colors": [],
          "dateFormat": "YYYY-MM-DD HH:mm:ss",
          "decimals": 2,
          "link": false,
          "linkTargetBlank": false,
          "linkTooltip": "Drill down",
          "linkUrl": "",
          "pattern": "Value #D",
          "thresholds": [],
          "type": "number",
          "unit": "short"
        },
        {
          "alias": "CPU Limits %",
          "align": "auto",
          "colors": [],
          "dateFormat": "YYYY-MM-DD HH:mm:ss",
          "decimals": 2,
          "link": false,
          "linkTargetBlank": false,
          "linkTooltip": "Drill down",
          "linkUrl": "",
          "pattern": "Value #E",
          "thresholds": [],
          "type": "number",
          "unit": "percentunit"
        },
        {
          "alias": "Pod",
          "align": "auto",
          "colors": [],
          "dateFormat": "YYYY-MM-DD HH:mm:ss",
          "decimals": 2,
          "link": false,
          "linkTargetBlank": false,
          "linkTooltip": "Drill down",
          "linkUrl": "",
          "pattern": "exported_pod",
          "thresholds": [],
          "type": "string",
          "unit": "short"
        },
        {
          "alias": "",
          "align": "auto",
          "colors": [],
          "dateFormat": "YYYY-MM-DD HH:mm:ss",
          "decimals": 2,
          "pattern": "pod",
          "thresholds": [],
          "type": "hidden",
          "unit": "short"
        },
        {
          "alias": "Container",
          "align": "auto",
          "colors": [],
          "dateFormat": "YYYY-MM-DD HH:mm:ss",
          "decimals": 2,
          "link": false,
          "linkTargetBlank": false,
          "linkTooltip": "Drill down",
          "linkUrl": "",
          "pattern": "exported_container",
          "thresholds": [],
          "type": "string",
          "unit": "short"
        },
        {
          "alias": "",
          "align": "auto",
          "colors": [],
          "dateFormat": "YYYY-MM-DD HH:mm:ss",
          "decimals": 2,
          "pattern": "container",
          "thresholds": [],
          "type": "hidden",
          "unit": "short"
        },
        {
          "alias": "",
          "align": "auto",
          "colors": [],
          "dateFormat": "YYYY-MM-DD HH:mm:ss",
          "decimals": 2,
          "pattern": "/.*/",
          "thresholds": [],
          "type": "string",
          "unit": "short"
        }
      ],
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${datasource}"
          },
          "editorMode": "code",
          "expr": "(sum(\n  label_replace(\n    label_replace(\n      sum(node_namespace_pod_container:container_cpu_usage_seconds_total:sum_rate{namespace=~\"$namespace\", pod=~\"${deployment:regex}-.*\"}) by (pod, container),\n      \"exported_pod\", \"$1\", \"pod\", \"(.+)\"\n    ),\n    \"exported_container\", \"$1\", \"container\", \"(.+)\"\n  )\n) by (exported_pod, exported_container))\nor\n(sum(\n  label_replace(\n    label_replace(\n      sum(rate(container_cpu_usage_seconds_total{job=~\"kubelet(-cadvisor)?\", metrics_path=\"/metrics/cadvisor\", namespace=~\"$namespace\", pod=~\"${deployment:regex}-.*\", container!=\"\", container!=\"POD\"}[5m])) by (pod, container),\n      \"exported_pod\", \"$1\", \"pod\", \"(.+)\"\n    ),\n    \"exported_container\", \"$1\", \"container\", \"(.+)\"\n  )\n) by (exported_pod, exported_container))",
          "format": "table",
          "instant": true,
          "legendFormat": "",
          "refId": "A"
        },
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${datasource}"
          },
          "editorMode": "code",
          "expr": "sum(kube_pod_container_resource_requests{job=\"kube-state-metrics\", exported_namespace=~\"$namespace\", exported_pod=~\"${deployment:regex}-.*\", exported_pod!~\"kube-state-metrics-.*\", resource=\"cpu\"}) by (exported_pod, exported_container)",
          "format": "table",
          "instant": true,
          "legendFormat": "",
          "refId": "B"
        },
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${datasource}"
          },
          "editorMode": "code",
          "expr": "((sum(\n  label_replace(\n    label_replace(\n      sum(node_namespace_pod_container:container_cpu_usage_seconds_total:sum_rate{namespace=~\"$namespace\", pod=~\"${deployment:regex}-.*\"}) by (pod, container),\n      \"exported_pod\", \"$1\", \"pod\", \"(.+)\"\n    ),\n    \"exported_container\", \"$1\", \"container\", \"(.+)\"\n  )\n) by (exported_pod, exported_container)) or (sum(\n  label_replace(\n    label_replace(\n      sum(rate(container_cpu_usage_seconds_total{job=~\"kubelet(-cadvisor)?\", metrics_path=\"/metrics/cadvisor\", namespace=~\"$namespace\", pod=~\"${deployment:regex}-.*\", container!=\"\", container!=\"POD\"}[5m])) by (pod, container),\n      \"exported_pod\", \"$1\", \"pod\", \"(.+)\"\n    ),\n    \"exported_container\", \"$1\", \"container\", \"(.+)\"\n  )\n) by (exported_pod, exported_container))) / on(exported_pod, exported_container) (clamp_min((sum(kube_pod_container_resource_requests{job=\"kube-state-metrics\", exported_namespace=~\"$namespace\", exported_pod=~\"${deployment:regex}-.*\", exported_pod!~\"kube-state-metrics-.*\", resource=\"cpu\"}) by (exported_pod, exported_container)), 1e-9))",
          "format": "table",
          "instant": true,
          "legendFormat": "",
          "refId": "C"
        },
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${datasource}"
          },
          "editorMode": "code",
          "expr": "sum(kube_pod_container_resource_limits{job=\"kube-state-metrics\", exported_namespace=~\"$namespace\", exported_pod=~\"${deployment:regex}-.*\", exported_pod!~\"kube-state-metrics-.*\", resource=\"cpu\"}) by (exported_pod, exported_container)",
          "format": "table",
          "instant": true,
          "legendFormat": "",
          "refId": "D"
        },
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${datasource}"
          },
          "editorMode": "code",
          "expr": "((sum(\n  label_replace(\n    label_replace(\n      sum(node_namespace_pod_container:container_cpu_usage_seconds_total:sum_rate{namespace=~\"$namespace\", pod=~\"${deployment:regex}-.*\"}) by (pod, container),\n      \"exported_pod\", \"$1\", \"pod\", \"(.+)\"\n    ),\n    \"exported_container\", \"$1\", \"container\", \"(.+)\"\n  )\n) by (exported_pod, exported_container)) or (sum(\n  label_replace(\n    label_replace(\n      sum(rate(container_cpu_usage_seconds_total{job=~\"kubelet(-cadvisor)?\", metrics_path=\"/metrics/cadvisor\", namespace=~\"$namespace\", pod=~\"${deployment:regex}-.*\", container!=\"\", container!=\"POD\"}[5m])) by (pod, container),\n      \"exported_pod\", \"$1\", \"pod\", \"(.+)\"\n    ),\n    \"exported_container\", \"$1\", \"container\", \"(.+)\"\n  )\n) by (exported_pod, exported_container))) / on(exported_pod, exported_container) (clamp_min((sum(kube_pod_container_resource_limits{job=\"kube-state-metrics\", exported_namespace=~\"$namespace\", exported_pod=~\"${deployment:regex}-.*\", exported_pod!~\"kube-state-metrics-.*\", resource=\"cpu\"}) by (exported_pod, exported_container)), 1e-9))",
          "format": "table",
          "instant": true,
          "legendFormat": "",
          "refId": "E"
        }
      ],
      "thresholds": [],
      "title": "CPU Quota",
      "tooltip": {
        "shared": false,
        "sort": 2,
        "value_type": "individual"
      },
      "transform": "table",
      "type": "table-old",
      "xaxis": {
        "mode": "time",
        "show": true,
        "values": []
      },
      "yaxes": [
        {
          "format": "short",
          "logBase": 1,
          "min": 0,
          "show": true
        },
        {
          "format": "short",
          "logBase": 1,
          "show": false
        }
      ]
    },
    {
      "aliasColors": {},
      "bars": false,
      "dashLength": 10,
      "dashes": false,
      "datasource": {
        "type": "prometheus",
        "uid": "${datasource}"
      },
      "fill": 10,
      "fillGradient": 0,
      "gridPos": {
        "h": 7,
        "w": 14,
        "x": 0,
        "y": 14
      },
      "hiddenSeries": false,
      "id": 64,
      "interval": "1m",
      "legend": {
        "alignAsTable": true,
        "avg": false,
        "current": false,
        "max": false,
        "min": false,
        "rightSide": true,
        "show": true,
        "total": false,
        "values": false
      },
      "lines": true,
      "linewidth": 0,
      "links": [],
      "nullPointMode": "null as zero",
      "options": {
        "alertThreshold": true
      },
      "percentage": false,
      "pluginVersion": "9.2.4",
      "pointradius": 5,
      "points": false,
      "renderer": "flot",
      "seriesOverrides": [
        {
          "$$hashKey": "object:168",
          "alias": "requests",
          "color": "#F2495C",
          "dashes": true,
          "fill": 0,
          "hideTooltip": true,
          "legend": true,
          "linewidth": 2,
          "stack": false
        },
        {
          "$$hashKey": "object:169",
          "alias": "limits",
          "color": "#FF9830",
          "dashes": true,
          "fill": 0,
          "hideTooltip": true,
          "legend": true,
          "linewidth": 2,
          "stack": false
        }
      ],
      "spaceLength": 10,
      "stack": true,
      "steppedLine": false,
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${datasource}"
          },
          "editorMode": "code",
          "expr": "sum(container_memory_working_set_bytes{job=\"kubelet-cadvisor\", metrics_path=\"/metrics/cadvisor\", namespace=~\"$namespace\", pod=~\"${deployment:regex}-.*\", container!=\"\", image!=\"\"}) by (container)",
          "format": "time_series",
          "legendFormat": "{{container}}",
          "range": true,
          "refId": "A"
        },
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${datasource}"
          },
          "editorMode": "code",
          "expr": "sum(kube_pod_container_resource_requests{job=\"kube-state-metrics\", exported_namespace=~\"$namespace\", exported_pod=~\"${deployment:regex}-.*\", resource=\"memory\"})",
          "format": "time_series",
          "legendFormat": "requests",
          "range": true,
          "refId": "B"
        },
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${datasource}"
          },
          "editorMode": "code",
          "expr": "sum(kube_pod_container_resource_limits{job=\"kube-state-metrics\", exported_namespace=~\"$namespace\", exported_pod=~\"${deployment:regex}-.*\", resource=\"memory\"})",
          "format": "time_series",
          "legendFormat": "limits",
          "range": true,
          "refId": "C"
        }
      ],
      "thresholds": [],
      "timeRegions": [],
      "title": "Memory Usage (WSS)",
      "tooltip": {
        "shared": false,
        "sort": 2,
        "value_type": "individual"
      },
      "type": "graph",
      "xaxis": {
        "mode": "time",
        "show": true,
        "values": []
      },
      "yaxes": [
        {
          "$$hashKey": "object:206",
          "format": "bytes",
          "logBase": 1,
          "min": 0,
          "show": true
        },
        {
          "$$hashKey": "object:207",
          "format": "short",
          "logBase": 1,
          "show": false
        }
      ],
      "yaxis": {
        "align": false
      }
    },
    {
      "aliasColors": {},
      "bars": false,
      "columns": [],
      "dashLength": 10,
      "dashes": false,
      "datasource": {
        "type": "prometheus",
        "uid": "${datasource}"
      },
      "fill": 1,
      "fontSize": "100%",
      "gridPos": {
        "h": 7,
        "w": 10,
        "x": 14,
        "y": 14
      },
      "id": 65,
      "interval": "1m",
      "legend": {
        "alignAsTable": true,
        "avg": false,
        "current": false,
        "max": false,
        "min": false,
        "rightSide": true,
        "show": true,
        "total": false,
        "values": false
      },
      "lines": true,
      "linewidth": 1,
      "links": [],
      "nullPointMode": "null as zero",
      "percentage": false,
      "pointradius": 5,
      "points": false,
      "renderer": "flot",
      "seriesOverrides": [],
      "showHeader": true,
      "sort": {
        "col": 0,
        "desc": true
      },
      "spaceLength": 10,
      "stack": false,
      "steppedLine": false,
      "styles": [
        {
          "alias": "Time",
          "align": "auto",
          "dateFormat": "YYYY-MM-DD HH:mm:ss",
          "pattern": "Time",
          "type": "hidden"
        },
        {
          "alias": "Memory Usage (WSS)",
          "align": "auto",
          "colors": [],
          "dateFormat": "YYYY-MM-DD HH:mm:ss",
          "decimals": 2,
          "link": false,
          "linkTargetBlank": false,
          "linkTooltip": "Drill down",
          "linkUrl": "",
          "pattern": "Value #A",
          "thresholds": [],
          "type": "number",
          "unit": "bytes"
        },
        {
          "alias": "Memory Requests",
          "align": "auto",
          "colors": [],
          "dateFormat": "YYYY-MM-DD HH:mm:ss",
          "decimals": 2,
          "link": false,
          "linkTargetBlank": false,
          "linkTooltip": "Drill down",
          "linkUrl": "",
          "pattern": "Value #B",
          "thresholds": [],
          "type": "number",
          "unit": "bytes"
        },
        {
          "alias": "Memory Requests %",
          "align": "auto",
          "colors": [],
          "dateFormat": "YYYY-MM-DD HH:mm:ss",
          "decimals": 2,
          "link": false,
          "linkTargetBlank": false,
          "linkTooltip": "Drill down",
          "linkUrl": "",
          "pattern": "Value #C",
          "thresholds": [],
          "type": "number",
          "unit": "percentunit"
        },
        {
          "alias": "Memory Limits",
          "align": "auto",
          "colors": [],
          "dateFormat": "YYYY-MM-DD HH:mm:ss",
          "decimals": 2,
          "link": false,
          "linkTargetBlank": false,
          "linkTooltip": "Drill down",
          "linkUrl": "",
          "pattern": "Value #D",
          "thresholds": [],
          "type": "number",
          "unit": "bytes"
        },
        {
          "alias": "Memory Limits %",
          "align": "auto",
          "colors": [],
          "dateFormat": "YYYY-MM-DD HH:mm:ss",
          "decimals": 2,
          "link": false,
          "linkTargetBlank": false,
          "linkTooltip": "Drill down",
          "linkUrl": "",
          "pattern": "Value #E",
          "thresholds": [],
          "type": "number",
          "unit": "percentunit"
        },
        {
          "alias": "Memory Usage (RSS)",
          "align": "auto",
          "colors": [],
          "dateFormat": "YYYY-MM-DD HH:mm:ss",
          "decimals": 2,
          "link": false,
          "linkTargetBlank": false,
          "linkTooltip": "Drill down",
          "linkUrl": "",
          "pattern": "Value #F",
          "thresholds": [],
          "type": "number",
          "unit": "bytes"
        },
        {
          "alias": "Memory Usage (Cache)",
          "align": "auto",
          "colors": [],
          "dateFormat": "YYYY-MM-DD HH:mm:ss",
          "decimals": 2,
          "link": false,
          "linkTargetBlank": false,
          "linkTooltip": "Drill down",
          "linkUrl": "",
          "pattern": "Value #G",
          "thresholds": [],
          "type": "number",
          "unit": "bytes"
        },
        {
          "alias": "Memory Usage (Swap)",
          "align": "auto",
          "colors": [],
          "dateFormat": "YYYY-MM-DD HH:mm:ss",
          "decimals": 2,
          "link": false,
          "linkTargetBlank": false,
          "linkTooltip": "Drill down",
          "linkUrl": "",
          "pattern": "Value #H",
          "thresholds": [],
          "type": "number",
          "unit": "bytes"
        },
        {
          "alias": "Container",
          "align": "auto",
          "colors": [],
          "dateFormat": "YYYY-MM-DD HH:mm:ss",
          "decimals": 2,
          "link": false,
          "linkTargetBlank": false,
          "linkTooltip": "Drill down",
          "linkUrl": "",
          "pattern": "container",
          "thresholds": [],
          "type": "number",
          "unit": "short"
        },
        {
          "alias": "",
          "align": "auto",
          "colors": [],
          "dateFormat": "YYYY-MM-DD HH:mm:ss",
          "decimals": 2,
          "pattern": "/.*/",
          "thresholds": [],
          "type": "string",
          "unit": "short"
        }
      ],
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${datasource}"
          },
          "editorMode": "code",
          "expr": "sum(container_memory_working_set_bytes{job=\"kubelet-cadvisor\", metrics_path=\"/metrics/cadvisor\", namespace=~\"$namespace\", pod=~\"${deployment:regex}-.*\", container!=\"\", image!=\"\"}) by (container)",
          "format": "table",
          "instant": true,
          "legendFormat": "",
          "refId": "A"
        },
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${datasource}"
          },
          "editorMode": "code",
          "expr": "sum(cluster:namespace:pod_memory:active:kube_pod_container_resource_requests{exported_namespace=~\"$namespace\", exported_pod=~\"${deployment:regex}-.*\"}) by (container)",
          "format": "table",
          "instant": true,
          "legendFormat": "",
          "refId": "B"
        },
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${datasource}"
          },
          "editorMode": "code",
          "expr": "(sum(container_memory_working_set_bytes{job=\"kubelet-cadvisor\", metrics_path=\"/metrics/cadvisor\", namespace=~\"$namespace\", pod=~\"${deployment:regex}-.*\", container!=\"\", image!=\"\"}) by (container)) / clamp_min((sum(cluster:namespace:pod_memory:active:kube_pod_container_resource_requests{exported_namespace=~\"$namespace\", exported_pod=~\"${deployment:regex}-.*\"}) by (container)), 1e-9)",
          "format": "table",
          "instant": true,
          "legendFormat": "",
          "refId": "C"
        },
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${datasource}"
          },
          "editorMode": "code",
          "expr": "sum(cluster:namespace:pod_memory:active:kube_pod_container_resource_limits{exported_namespace=~\"$namespace\", exported_pod=~\"${deployment:regex}-.*\"}) by (container)",
          "format": "table",
          "instant": true,
          "legendFormat": "",
          "refId": "D"
        },
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${datasource}"
          },
          "editorMode": "code",
          "expr": "(sum(container_memory_working_set_bytes{job=\"kubelet-cadvisor\", metrics_path=\"/metrics/cadvisor\", namespace=~\"$namespace\", pod=~\"${deployment:regex}-.*\", container!=\"\", image!=\"\"}) by (container)) / clamp_min((sum(cluster:namespace:pod_memory:active:kube_pod_container_resource_limits{exported_namespace=~\"$namespace\", exported_pod=~\"${deployment:regex}-.*\"}) by (container)), 1e-9)",
          "format": "table",
          "instant": true,
          "legendFormat": "",
          "refId": "E"
        },
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${datasource}"
          },
          "editorMode": "code",
          "expr": "sum(container_memory_rss{job=\"kubelet-cadvisor\", metrics_path=\"/metrics/cadvisor\", namespace=~\"$namespace\", pod=~\"${deployment:regex}-.*\", container!=\"\", container!=\"POD\"}) by (container)",
          "format": "table",
          "instant": true,
          "legendFormat": "",
          "refId": "F"
        },
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${datasource}"
          },
          "editorMode": "code",
          "expr": "sum(container_memory_cache{job=\"kubelet-cadvisor\", metrics_path=\"/metrics/cadvisor\", namespace=~\"$namespace\", pod=~\"${deployment:regex}-.*\", container!=\"\", container!=\"POD\"}) by (container)",
          "format": "table",
          "instant": true,
          "legendFormat": "",
          "refId": "G"
        },
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${datasource}"
          },
          "editorMode": "code",
          "expr": "sum(container_memory_swap{job=\"kubelet-cadvisor\", metrics_path=\"/metrics/cadvisor\", namespace=~\"$namespace\", pod=~\"${deployment:regex}-.*\", container!=\"\", container!=\"POD\"}) by (container)",
          "format": "table",
          "instant": true,
          "legendFormat": "",
          "refId": "H"
        }
      ],
      "thresholds": [],
      "title": "Memory Quota",
      "tooltip": {
        "shared": false,
        "sort": 2,
        "value_type": "individual"
      },
      "transform": "table",
      "type": "table-old",
      "xaxis": {
        "mode": "time",
        "show": true,
        "values": []
      },
      "yaxes": [
        {
          "format": "short",
          "logBase": 1,
          "min": 0,
          "show": true
        },
        {
          "format": "short",
          "logBase": 1,
          "show": false
        }
      ]
    },
    {
      "collapsed": false,
      "gridPos": {
        "h": 1,
        "w": 24,
        "x": 0,
        "y": 21
      },
      "id": 4,
      "panels": [],
      "title": "3) HTTP 请求与成功率",
      "type": "row"
    },
    {
      "datasource": {
        "type": "prometheus",
        "uid": "${datasource}"
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "palette-classic"
          },
          "custom": {
            "axisCenteredZero": false,
            "axisColorMode": "text",
            "axisLabel": "",
            "axisPlacement": "auto",
            "barAlignment": 0,
            "drawStyle": "line",
            "fillOpacity": 15,
            "gradientMode": "none",
            "hideFrom": {
              "legend": false,
              "tooltip": false,
              "viz": false
            },
            "lineInterpolation": "linear",
            "lineWidth": 1,
            "pointSize": 5,
            "scaleDistribution": {
              "type": "linear"
            },
            "showPoints": "never",
            "spanNulls": false,
            "stacking": {
              "group": "A",
              "mode": "normal"
            },
            "thresholdsStyle": {
              "mode": "off"
            }
          },
          "mappings": [],
          "max": 1,
          "min": 0,
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              },
              {
                "color": "red",
                "value": 80
              }
            ]
          },
          "unit": "percentunit"
        },
        "overrides": []
      },
      "gridPos": {
        "h": 8,
        "w": 12,
        "x": 0,
        "y": 22
      },
      "id": 30,
      "options": {
        "legend": {
          "calcs": [],
          "displayMode": "list",
          "placement": "bottom",
          "showLegend": true
        },
        "tooltip": {
          "mode": "multi",
          "sort": "desc"
        }
      },
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${datasource}"
          },
          "expr": "(\n  sum(rate(investibook_http_requests_total{status_code!~\"5..\"}[1h]))\n  / sum(rate(investibook_http_requests_total[1h]))\n)\nand\n(\n  sum(rate(investibook_http_requests_total[1h])) > 0\n)",
          "legendFormat": "success (non-5xx)",
          "range": true,
          "refId": "A"
        }
      ],
      "title": "HTTP 成功率时间序列（1h rate）",
      "type": "timeseries"
    },
    {
      "datasource": {
        "type": "prometheus",
        "uid": "${datasource}"
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "palette-classic"
          },
          "custom": {
            "axisCenteredZero": false,
            "axisColorMode": "text",
            "axisLabel": "",
            "axisPlacement": "auto",
            "barAlignment": 0,
            "drawStyle": "line",
            "fillOpacity": 10,
            "gradientMode": "none",
            "hideFrom": {
              "legend": false,
              "tooltip": false,
              "viz": false
            },
            "lineInterpolation": "linear",
            "lineWidth": 1,
            "pointSize": 5,
            "scaleDistribution": {
              "type": "linear"
            },
            "showPoints": "never",
            "spanNulls": false,
            "stacking": {
              "group": "A",
              "mode": "normal"
            },
            "thresholdsStyle": {
              "mode": "off"
            }
          },
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              },
              {
                "color": "red",
                "value": 80
              }
            ]
          },
          "unit": "short"
        },
        "overrides": []
      },
      "gridPos": {
        "h": 8,
        "w": 12,
        "x": 12,
        "y": 22
      },
      "id": 31,
      "options": {
        "legend": {
          "calcs": [],
          "displayMode": "list",
          "placement": "bottom",
          "showLegend": true
        },
        "tooltip": {
          "mode": "multi",
          "sort": "desc"
        }
      },
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${datasource}"
          },
          "editorMode": "code",
          "expr": "sum by (status_code) (increase(investibook_http_requests_total[1h]))",
          "legendFormat": "{{status_code}}",
          "range": true,
          "refId": "A"
        }
      ],
      "title": "HTTP QPH 按 status_code（滑动 1h 计数）",
      "type": "timeseries"
    },
    {
      "collapsed": false,
      "gridPos": {
        "h": 1,
        "w": 24,
        "x": 0,
        "y": 30
      },
      "id": 5,
      "panels": [],
      "title": "4) Chat 完成与 finish_reason",
      "type": "row"
    },
    {
      "datasource": {
        "type": "prometheus",
        "uid": "${datasource}"
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "palette-classic"
          },
          "custom": {
            "axisCenteredZero": false,
            "axisColorMode": "text",
            "axisLabel": "",
            "axisPlacement": "auto",
            "barAlignment": 0,
            "drawStyle": "line",
            "fillOpacity": 15,
            "gradientMode": "none",
            "hideFrom": {
              "legend": false,
              "tooltip": false,
              "viz": false
            },
            "lineInterpolation": "linear",
            "lineWidth": 1,
            "pointSize": 5,
            "scaleDistribution": {
              "type": "linear"
            },
            "showPoints": "never",
            "spanNulls": false,
            "stacking": {
              "group": "A",
              "mode": "none"
            },
            "thresholdsStyle": {
              "mode": "off"
            }
          },
          "mappings": [],
          "max": 1,
          "min": 0,
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              },
              {
                "color": "red",
                "value": 80
              }
            ]
          },
          "unit": "percentunit"
        },
        "overrides": []
      },
      "gridPos": {
        "h": 8,
        "w": 12,
        "x": 0,
        "y": 31
      },
      "id": 40,
      "options": {
        "legend": {
          "calcs": [],
          "displayMode": "list",
          "placement": "bottom",
          "showLegend": true
        },
        "tooltip": {
          "mode": "multi",
          "sort": "desc"
        }
      },
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${datasource}"
          },
          "expr": "(\n  sum(rate(investibook_ai_chat_completions_total{finish_reason=\"completed\"}[1h]))\n  / sum(rate(investibook_ai_chat_completions_total[1h]))\n)\nand\n(\n  sum(rate(investibook_ai_chat_completions_total[1h])) > 0\n)",
          "legendFormat": "completed ratio",
          "range": true,
          "refId": "A"
        }
      ],
      "title": "Chat completed 占比（1h rate）",
      "type": "timeseries"
    },
    {
      "datasource": {
        "type": "prometheus",
        "uid": "${datasource}"
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "palette-classic"
          },
          "custom": {
            "axisCenteredZero": false,
            "axisColorMode": "text",
            "axisLabel": "",
            "axisPlacement": "auto",
            "barAlignment": 0,
            "drawStyle": "line",
            "fillOpacity": 10,
            "gradientMode": "none",
            "hideFrom": {
              "legend": false,
              "tooltip": false,
              "viz": false
            },
            "lineInterpolation": "linear",
            "lineWidth": 1,
            "pointSize": 5,
            "scaleDistribution": {
              "type": "linear"
            },
            "showPoints": "never",
            "spanNulls": false,
            "stacking": {
              "group": "A",
              "mode": "normal"
            },
            "thresholdsStyle": {
              "mode": "off"
            }
          },
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              },
              {
                "color": "red",
                "value": 80
              }
            ]
          },
          "unit": "short"
        },
        "overrides": []
      },
      "gridPos": {
        "h": 8,
        "w": 12,
        "x": 12,
        "y": 31
      },
      "id": 41,
      "options": {
        "legend": {
          "calcs": [],
          "displayMode": "list",
          "placement": "bottom",
          "showLegend": true
        },
        "tooltip": {
          "mode": "multi",
          "sort": "desc"
        }
      },
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${datasource}"
          },
          "expr": "sum by (finish_reason) (increase(investibook_ai_chat_completions_total[1h]))",
          "legendFormat": "{{finish_reason}}",
          "range": true,
          "refId": "A"
        }
      ],
      "title": "Chat completions QPH 按 finish_reason（滑动 1h 计数）",
      "type": "timeseries"
    },
    {
      "collapsed": false,
      "gridPos": {
        "h": 1,
        "w": 24,
        "x": 0,
        "y": 39
      },
      "id": 6,
      "panels": [],
      "title": "5) Pod 重启与终止原因（kube-state-metrics）",
      "type": "row"
    },
    {
      "datasource": {
        "type": "prometheus",
        "uid": "${datasource}"
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "palette-classic"
          },
          "custom": {
            "axisCenteredZero": false,
            "axisColorMode": "text",
            "axisLabel": "",
            "axisPlacement": "auto",
            "barAlignment": 0,
            "drawStyle": "bars",
            "fillOpacity": 80,
            "gradientMode": "none",
            "hideFrom": {
              "legend": false,
              "tooltip": false,
              "viz": false
            },
            "lineInterpolation": "linear",
            "lineWidth": 1,
            "pointSize": 5,
            "scaleDistribution": {
              "type": "linear"
            },
            "showPoints": "never",
            "spanNulls": false,
            "stacking": {
              "group": "A",
              "mode": "normal"
            },
            "thresholdsStyle": {
              "mode": "off"
            }
          },
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              },
              {
                "color": "red",
                "value": 80
              }
            ]
          },
          "unit": "short"
        },
        "overrides": []
      },
      "gridPos": {
        "h": 7,
        "w": 7,
        "x": 0,
        "y": 40
      },
      "id": 50,
      "options": {
        "legend": {
          "calcs": [],
          "displayMode": "list",
          "placement": "bottom",
          "showLegend": true
        },
        "tooltip": {
          "mode": "multi",
          "sort": "desc"
        }
      },
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${datasource}"
          },
          "editorMode": "code",
          "expr": "sum by (deployment) (\n  increase(\n    label_replace(\n      kube_pod_container_status_restarts_total{exported_namespace=~\"$namespace\", exported_pod=~\"${deployment:regex}-.*\"}[1h],\n      \"deployment\",\n      \"$1\",\n      \"exported_pod\",\n      \"^([^-]+)-.+$\"\n    )\n  )\n)",
          "legendFormat": "{{deployment}} ",
          "range": true,
          "refId": "A"
        }
      ],
      "title": "按 Pod 的容器重启次数（1h increase）",
      "type": "timeseries"
    },
    {
      "datasource": {
        "type": "prometheus",
        "uid": "${datasource}"
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "palette-classic"
          },
          "custom": {
            "align": "auto",
            "displayMode": "auto",
            "inspect": false
          },
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              },
              {
                "color": "red",
                "value": 80
              }
            ]
          },
          "unit": "short"
        },
        "overrides": []
      },
      "gridPos": {
        "h": 7,
        "w": 8,
        "x": 7,
        "y": 40
      },
      "id": 52,
      "options": {
        "footer": {
          "countRows": false,
          "fields": "",
          "reducer": ["sum"],
          "show": false
        },
        "showHeader": true
      },
      "pluginVersion": "9.2.4",
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${datasource}"
          },
          "editorMode": "code",
          "expr": "kube_pod_container_status_restarts_total{exported_namespace=~\"$namespace\", exported_pod=~\"${deployment:regex}-.*\"}",
          "format": "table",
          "instant": true,
          "refId": "A"
        }
      ],
      "title": "容器累计重启次数（当前值）",
      "transformations": [
        {
          "id": "organize",
          "options": {
            "excludeByName": {
              "Time": true,
              "__name__": true,
              "cluster": true,
              "container": true,
              "control_plane_info": true,
              "endpoint": true,
              "exported_namespace": true,
              "instance": true,
              "job": true,
              "namespace": true,
              "o11y_id": true,
              "pod": true,
              "prometheus": true,
              "provider": true,
              "region": true,
              "service": true,
              "uid": true
            },
            "indexByName": {
              "Time": 0,
              "Value": 19,
              "__name__": 1,
              "cluster": 2,
              "container": 3,
              "control_plane_info": 4,
              "endpoint": 5,
              "exported_container": 7,
              "exported_namespace": 8,
              "exported_pod": 6,
              "instance": 9,
              "job": 10,
              "namespace": 11,
              "o11y_id": 12,
              "pod": 13,
              "prometheus": 14,
              "provider": 15,
              "region": 16,
              "service": 17,
              "uid": 18
            },
            "renameByName": {
              "Value": "restarts_total",
              "exported_container": "container",
              "exported_namespace": "",
              "exported_pod": "pod"
            }
          }
        }
      ],
      "type": "table"
    },
    {
      "datasource": {
        "type": "prometheus",
        "uid": "${datasource}"
      },
      "description": "kube-state-metrics：上次退出原因（OOMKilled、Error、Completed 等）。需 KSM 暴露该指标。",
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "palette-classic"
          },
          "custom": {
            "align": "auto",
            "displayMode": "auto",
            "inspect": false
          },
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              },
              {
                "color": "red",
                "value": 80
              }
            ]
          },
          "unit": "short"
        },
        "overrides": []
      },
      "gridPos": {
        "h": 7,
        "w": 9,
        "x": 15,
        "y": 40
      },
      "id": 51,
      "options": {
        "footer": {
          "countRows": false,
          "fields": "",
          "reducer": ["sum"],
          "show": false
        },
        "showHeader": true,
        "sortBy": [
          {
            "desc": true,
            "displayName": "Value"
          }
        ]
      },
      "pluginVersion": "9.2.4",
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${datasource}"
          },
          "editorMode": "code",
          "exemplar": false,
          "expr": "kube_pod_container_status_last_terminated_reason{exported_namespace=~\"$namespace\", exported_pod=~\"${deployment:regex}-.*\"} == 1",
          "format": "table",
          "instant": true,
          "legendFormat": "",
          "range": false,
          "refId": "A"
        }
      ],
      "title": "上次容器终止原因（last_terminated_reason）",
      "transformations": [
        {
          "id": "organize",
          "options": {
            "excludeByName": {
              "Time": true,
              "__name__": true,
              "cluster": true,
              "container": true,
              "control_plane_info": true,
              "endpoint": true,
              "exported_namespace": true,
              "instance": true,
              "job": true,
              "namespace": true,
              "o11y_id": true,
              "pod": true,
              "prometheus": true,
              "provider": true,
              "region": true,
              "service": true,
              "uid": true
            },
            "indexByName": {
              "Time": 0,
              "Value": 20,
              "__name__": 1,
              "cluster": 2,
              "container": 3,
              "control_plane_info": 4,
              "endpoint": 5,
              "exported_container": 7,
              "exported_namespace": 8,
              "exported_pod": 6,
              "instance": 9,
              "job": 10,
              "namespace": 11,
              "o11y_id": 12,
              "pod": 13,
              "prometheus": 14,
              "provider": 15,
              "reason": 16,
              "region": 17,
              "service": 18,
              "uid": 19
            },
            "renameByName": {
              "Value": "active",
              "container": "container",
              "exported_container": "container",
              "exported_namespace": "",
              "exported_pod": "pod",
              "pod": "pod",
              "reason": "reason"
            }
          }
        }
      ],
      "type": "table"
    }
  ],
  "refresh": "30s",
  "schemaVersion": 37,
  "style": "dark",
  "tags": ["investibook", "sre", "kube-state-metrics"],
  "templating": {
    "list": [
      {
        "current": {
          "selected": false,
          "text": "DevOps-prometheus",
          "value": "DevOps-prometheus"
        },
        "hide": 0,
        "includeAll": false,
        "label": "数据源",
        "multi": false,
        "name": "datasource",
        "options": [],
        "query": "prometheus",
        "queryValue": "",
        "refresh": 1,
        "regex": "",
        "skipUrlSync": false,
        "type": "datasource"
      },
      {
        "current": {
          "selected": true,
          "text": "investibook",
          "value": "investibook"
        },
        "description": "Investibook 所在 namespace",
        "hide": 0,
        "label": "Namespace",
        "name": "namespace",
        "options": [
          {
            "selected": true,
            "text": "investibook",
            "value": "investibook"
          }
        ],
        "query": "investibook",
        "skipUrlSync": false,
        "type": "textbox"
      },
      {
        "allValue": ".*",
        "current": {
          "selected": true,
          "text": ["All"],
          "value": ["$__all"]
        },
        "datasource": {
          "type": "prometheus",
          "uid": "${datasource}"
        },
        "definition": "label_values(kube_deployment_status_replicas_available{exported_namespace=~\"$namespace\"}, deployment)",
        "description": "按 Kubernetes Deployment 聚合；Pod 名需符合 {deployment}-* 前缀（默认 ReplicaSet 命名）。",
        "hide": 0,
        "includeAll": true,
        "label": "Deployment",
        "multi": true,
        "name": "deployment",
        "options": [],
        "query": {
          "query": "label_values(kube_deployment_status_replicas_available{exported_namespace=~\"$namespace\"}, deployment)",
          "refId": "StandardVariableQuery"
        },
        "refresh": 2,
        "regex": "",
        "skipUrlSync": false,
        "sort": 1,
        "type": "query"
      }
    ]
  },
  "time": {
    "from": "now-2d",
    "to": "now"
  },
  "timepicker": {},
  "timezone": "browser",
  "title": "Investibook — 服务健康 (SRE)",
  "uid": "investibook-sre",
  "version": 21,
  "weekStart": ""
}
