From a8785ed4f1347028f69cff8078898d876ae06198 Mon Sep 17 00:00:00 2001 From: Antigravity Date: Sat, 30 May 2026 11:54:30 +0000 Subject: [PATCH] fix(monitoring): fix Grafana datasource UID to 'Prometheus' and handle metrics-token directory mount issue in deploy script --- .../datasources/datasource.yaml | 2 ++ scripts/deploy-prod.sh | 30 +++++++------------ 2 files changed, 13 insertions(+), 19 deletions(-) diff --git a/monitoring/grafana-provisioning/datasources/datasource.yaml b/monitoring/grafana-provisioning/datasources/datasource.yaml index 1a57b69..e7860d8 100644 --- a/monitoring/grafana-provisioning/datasources/datasource.yaml +++ b/monitoring/grafana-provisioning/datasources/datasource.yaml @@ -7,3 +7,5 @@ datasources: url: http://prometheus:9090 isDefault: true editable: true + uid: Prometheus + diff --git a/scripts/deploy-prod.sh b/scripts/deploy-prod.sh index 62fc37d..5a1917b 100755 --- a/scripts/deploy-prod.sh +++ b/scripts/deploy-prod.sh @@ -147,6 +147,13 @@ for i in $(seq 1 "$HEALTH_CHECK_MAX_ITERATIONS"); do if [ "$ACTUAL" = "$GIT_COMMIT" ]; then echo "OK build-info commit=$ACTUAL" echo "=== Updating monitoring stack ===" + # Fix potential Docker directory/file mount corruption for metrics-token + if [ -d monitoring/metrics-token ]; then + echo "WARN: monitoring/metrics-token is a directory on host, removing it" + rm -rf monitoring/metrics-token + git checkout monitoring/metrics-token || echo "default-token-value" > monitoring/metrics-token + fi + if [ -f /opt/memento/.env.docker ]; then export $(cat /opt/memento/.env.docker | grep -v '^#' | xargs) fi @@ -158,27 +165,12 @@ for i in $(seq 1 "$HEALTH_CHECK_MAX_ITERATIONS"); do docker compose -f monitoring/docker-compose.monitoring.yml up -d --remove-orphans 2>&1 || echo "WARN: Failed to bring up monitoring stack" fi - # Force recreation of Grafana to reload physical JSON dashboards mounted from the host - echo "=== Recreating Grafana to load updated dashboards ===" - docker compose -f monitoring/docker-compose.monitoring.yml up -d --force-recreate grafana 2>&1 || true + # Force recreation of Grafana, Prometheus and Alertmanager to apply config changes and fix mounts + echo "=== Recreating Grafana, Prometheus and Alertmanager containers ===" + docker compose -f monitoring/docker-compose.monitoring.yml up -d --force-recreate grafana prometheus alertmanager 2>&1 || true - # Diagnostics for Grafana dashboard loading - echo "=== Waiting for Grafana initialization ===" - sleep 4 - echo "=== Grafana Mounted Dashboards ===" - docker exec memento-grafana ls -la /etc/grafana/dashboards || true - echo "=== Grafana Container Logs (Provisioning/Errors) ===" - docker logs memento-grafana --tail=100 || true - - if docker ps --format '{{.Names}}' | grep -q "^memento-prometheus$"; then - echo "=== Reloading Prometheus configuration ===" - docker compose -f monitoring/docker-compose.monitoring.yml exec -T prometheus kill -SIGHUP 1 2>/dev/null || true - fi - if docker ps --format '{{.Names}}' | grep -q "^memento-alertmanager$"; then - echo "=== Reloading Alertmanager configuration ===" - docker compose -f monitoring/docker-compose.monitoring.yml exec -T alertmanager kill -SIGHUP 1 2>/dev/null || true - fi docker compose ps + telegram_notify "success" "Deployment successful — app is healthy" exit 0 fi