Files
ljwx-k8s/fix-dashboard-quick.sh
2026-02-20 22:50:45 +08:00

79 lines
2.9 KiB
Bash
Executable File
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/bin/bash
# 快速修复 Dashboard - 直接在 Grafana 中配置 Prometheus 数据源指向 Exporter
set -e
echo "=========================================="
echo "快速修复 Grafana Dashboard"
echo "=========================================="
echo ""
GRAFANA_URL="${GRAFANA_URL:-http://localhost:30300}"
GRAFANA_USER="${GRAFANA_USER:-admin}"
GRAFANA_PASS="${GRAFANA_PASS:-admin123}"
echo "方案:使用 Grafana Infinity 插件直接查询 Exporter"
echo ""
echo "1. 简化版 Dashboard 已导入"
echo " URL: $GRAFANA_URL/d/af901k0wj05q8c/gitea-runner-autoscaling-simplified"
echo ""
echo "2. 当前可用的面板:"
echo " ✅ Gitea Runner 副本数"
echo " ✅ Gitea Runner Pod 状态"
echo " ✅ HPA 期望副本数"
echo " ✅ Pod 重启次数"
echo " ✅ CPU/内存资源请求"
echo " ✅ 状态概览"
echo ""
echo "3. 待修复的问题:"
echo " ⚠️ Gitea Actions 队列指标(需要 Prometheus 采集 Exporter)"
echo " ⚠️ 实时 CPU/内存使用率(需要 cAdvisor 指标)"
echo ""
echo "=========================================="
echo "解决方案选项"
echo "=========================================="
echo ""
echo "选项 A: 手动刷新 Prometheus 配置(推荐)⭐⭐⭐⭐⭐"
echo "----------------------------------------"
echo "重启 Prometheus Operator 以重新加载配置:"
echo ""
echo " kubectl delete pod -n monitoring -l app.kubernetes.io/name=prometheus-operator"
echo " kubectl delete pod -n monitoring -l app.kubernetes.io/name=prometheus"
echo ""
echo "等待 2-3 分钟后检查:"
echo " curl -s 'http://localhost:9090/api/v1/targets' | grep gitea"
echo ""
echo "选项 B: 验证当前 Dashboard"
echo "----------------------------------------"
echo "打开简化版 Dashboard:"
echo " open $GRAFANA_URL/d/af901k0wj05q8c/gitea-runner-autoscaling-simplified"
echo ""
echo "选项 C: 查看 Prometheus 配置详情"
echo "----------------------------------------"
echo " kubectl get prometheus monitoring-kube-prometheus-prometheus -n observability -o yaml"
echo ""
echo "=========================================="
echo "自动打开简化版 Dashboard..."
echo "=========================================="
if command -v open &> /dev/null; then
open "$GRAFANA_URL/d/af901k0wj05q8c/gitea-runner-autoscaling-simplified"
echo "✅ Dashboard 已在浏览器中打开"
else
echo "请手动访问: $GRAFANA_URL/d/af901k0wj05q8c/gitea-runner-autoscaling-simplified"
fi
echo ""
echo "=========================================="
echo "当前状态总结"
echo "=========================================="
echo ""
echo "✅ Gitea Actions Exporter: 运行中"
echo "✅ Exporter 暴露指标: http://gitea-actions-exporter.gitea-runner:9999/metrics"
echo "✅ 简化版 Dashboard: 已导入(使用 kube-state-metrics 指标)"
echo "⚠️ Prometheus 采集: 等待配置生效"
echo ""
echo "预计 2-3 分钟后,Prometheus 将开始采集 Exporter 指标"
echo "届时可以添加队列监控面板"
echo ""