fix(monitoring): 恢復 exporter scrape 目標
All checks were successful
CD Pipeline / deploy (push) Successful in 1m41s
All checks were successful
CD Pipeline / deploy (push) Successful in 1m41s
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
|
||||
> 本文件定義專案開發的核心準則與不可違反的規範
|
||||
> **建立日期**: 2026-01-12
|
||||
> **當前版本**: V10.24 (EDM Dashboard blueprint endpoint 修復版)
|
||||
> **當前版本**: V10.25 (Monitoring blackbox/cAdvisor scrape 修復版)
|
||||
> **最後更新**: 2026-04-30
|
||||
|
||||
---
|
||||
|
||||
4
app.py
4
app.py
@@ -95,8 +95,8 @@ except Exception as e:
|
||||
sys_log.error(f"無法檢測磁碟空間: {e}")
|
||||
|
||||
# 🚩 系統版本定義 (備份與顯示用)
|
||||
# 🚩 2026-04-30 V10.24: EDM dashboard blueprint endpoint sort link fix
|
||||
SYSTEM_VERSION = "V10.24"
|
||||
# 🚩 2026-04-30 V10.25: Monitoring blackbox/cAdvisor scrape recovery
|
||||
SYSTEM_VERSION = "V10.25"
|
||||
|
||||
# ==========================================
|
||||
# 🔒 SQL Injection 防護函數
|
||||
|
||||
@@ -254,7 +254,7 @@ YOUTUBE_API_KEY = os.getenv('YOUTUBE_API_KEY', '')
|
||||
# ==========================================
|
||||
# 系統版本與路徑
|
||||
# ==========================================
|
||||
SYSTEM_VERSION = "V10.24"
|
||||
SYSTEM_VERSION = "V10.25"
|
||||
LOG_FILE_PATH = os.path.join(BASE_DIR, 'logs/system.log')
|
||||
public_url = PUBLIC_URL # 用於模板顯示
|
||||
|
||||
|
||||
@@ -47,6 +47,7 @@
|
||||
- Daily summary API:`POST /api/ai-automation/smoke/daily-summary/send`。
|
||||
- Grafana dashboard 檔案:`docker/grafana/provisioning/dashboards/json/ai-automation-overview.json`;provider 會載入 JSON 目錄,不需要修改 dashboard provider。
|
||||
- Active monitoring 使用 `monitoring/prometheus.yml`,不是 `docker/prometheus/prometheus.yml`;若線上 panel 無資料,先查 Prometheus 是否有 `momo-app` target。
|
||||
- Monitoring compose 的 cAdvisor 只需在 `monitoring` network 內提供 `cadvisor:8080` 給 Prometheus,不應綁定 host `8080`,避免與其他服務衝突;blackbox target 需要 `blackbox-exporter` 容器存在於同一 network。
|
||||
- App container 的 runtime `gunicorn.conf.py` 由 `docker-compose.yml` bind mount;若未來改 gunicorn 設定,不應再手動 `docker cp` 作為常態流程。
|
||||
|
||||
## 驗證紀錄
|
||||
@@ -60,6 +61,7 @@
|
||||
- 2026-04-29 AI Grafana observability + AI core 回歸:`36 passed`,collect-only:`36 tests collected`。
|
||||
- 2026-04-30 Gunicorn LocalProxy 修復:新增 `tests/test_gunicorn_config.py`。
|
||||
- 2026-04-30 Prometheus scrape 修復:新增 `tests/test_prometheus_ai_automation_scrape.py`。
|
||||
- 2026-04-30 Monitoring exporter 修復:`tests/test_prometheus_ai_automation_scrape.py` 覆蓋 cAdvisor internal-only 與 blackbox exporter 宣告。
|
||||
- 2026-04-30 CD health check hardening:新增 `tests/test_cd_health_check.py`。
|
||||
- 2026-04-30 CD Gunicorn mount hardening:新增 `tests/test_docker_compose_runtime_mounts.py`。
|
||||
- 2026-04-30 Metrics schema drift 降噪:`tests/test_ai_automation_metrics.py` 覆蓋 raw sales count query。
|
||||
|
||||
@@ -46,6 +46,7 @@
|
||||
- **Legacy 5888 入口清理**: 刪除 `tests/main_test.py` standalone Flask 死碼,測試與自動匯入文件改用 Port 80 `/auto_import` 入口。
|
||||
- **OpenClaw Bot 第一刀拆分**: Telegram API send/retry/file upload helper 移到 `services/openclaw_bot/telegram_api.py`,`routes/openclaw_bot_routes.py` 往 thin Blueprint 收斂。
|
||||
- **EDM Dashboard endpoint 修復**: 部署後健康檢查抓到活動看板排序連結少 `edm.` blueprint 前綴,修正模板 endpoint 推導並補 5 個活動頁排序連結回歸測試。
|
||||
- **Monitoring exporter 修復**: Prometheus 已能 scrape `momo-app` V10.24,但 target 檢查發現 `blackbox-exporter` 未啟動、`cadvisor` 因 host `8080` 衝突未進入 monitoring DNS;改為 cAdvisor internal-only 並補 monitoring compose 守門測試。
|
||||
|
||||
### 2026-04-28~29:Phase 3e 重構大戰 + daily_sales cache 隱形 bug 根除
|
||||
- **app.py 縮減 -10.8%**: 7,386 → 6,590 行,11 commits 全綠零 502。
|
||||
|
||||
@@ -6,8 +6,6 @@ services:
|
||||
image: gcr.io/cadvisor/cadvisor:latest
|
||||
container_name: cadvisor
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- "8080:8080"
|
||||
volumes:
|
||||
- /:/rootfs:ro
|
||||
- /var/run:/var/run:ro
|
||||
|
||||
@@ -20,6 +20,23 @@ def test_monitoring_stack_connects_prometheus_to_momo_network():
|
||||
assert "name: momo-network" in compose
|
||||
|
||||
|
||||
def test_monitoring_cadvisor_uses_internal_network_only():
|
||||
compose = (ROOT / "monitoring/docker-compose.yml").read_text(encoding="utf-8")
|
||||
cadvisor_block = compose.split(" # Prometheus - 時序資料庫", 1)[0]
|
||||
|
||||
assert "container_name: cadvisor" in cadvisor_block
|
||||
assert "ports:" not in cadvisor_block
|
||||
assert "cadvisor:8080" in (ROOT / "monitoring/prometheus.yml").read_text(encoding="utf-8")
|
||||
|
||||
|
||||
def test_monitoring_stack_declares_blackbox_exporter():
|
||||
compose = (ROOT / "monitoring/docker-compose.yml").read_text(encoding="utf-8")
|
||||
|
||||
assert "blackbox-exporter:" in compose
|
||||
assert "container_name: blackbox-exporter" in compose
|
||||
assert "blackbox-exporter:9115" in (ROOT / "monitoring/prometheus.yml").read_text(encoding="utf-8")
|
||||
|
||||
|
||||
def test_compose_prometheus_uses_container_dns_for_momo_app():
|
||||
config = (ROOT / "docker/prometheus/prometheus.yml").read_text(encoding="utf-8")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user