summaryrefslogtreecommitdiff
path: root/scripts/backfill-historic-data.sh
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/backfill-historic-data.sh')
-rw-r--r--scripts/backfill-historic-data.sh63
1 files changed, 63 insertions, 0 deletions
diff --git a/scripts/backfill-historic-data.sh b/scripts/backfill-historic-data.sh
new file mode 100644
index 0000000..c755da7
--- /dev/null
+++ b/scripts/backfill-historic-data.sh
@@ -0,0 +1,63 @@
+#!/bin/bash
+# Backfill historic data to Prometheus for Epimetheus dashboard
+# Run from repo root: ./scripts/backfill-historic-data.sh
+
+set -e
+
+SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
+REPO_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
+cd "$REPO_ROOT"
+
+echo "=== Epimetheus Historic Data Backfill ==="
+echo ""
+echo "This script will populate Prometheus with historic test data"
+echo "going back 7 days, with data points every 12 hours."
+echo ""
+
+# Port-forward to Prometheus
+echo "Step 1: Setting up port-forward to Prometheus..."
+kubectl port-forward -n monitoring svc/prometheus-kube-prometheus-prometheus 9090:9090 > /tmp/epimetheus-prom-pf.log 2>&1 &
+PF_PID=$!
+echo "Port-forward started (PID: $PF_PID)"
+
+# Wait for port-forward to be ready
+sleep 5
+
+# Run backfill
+echo ""
+echo "Step 2: Backfilling data from 7 days ago to now (12-hour intervals)..."
+echo ""
+./epimetheus -mode=backfill \
+ -prometheus=http://localhost:9090/api/v1/write \
+ -start-hours=168 \
+ -end-hours=0 \
+ -interval=12
+
+EXIT_CODE=$?
+
+# Clean up
+echo ""
+echo "Step 3: Cleaning up port-forward..."
+kill $PF_PID 2>/dev/null || true
+
+if [ $EXIT_CODE -eq 0 ]; then
+ echo ""
+ echo "✅ Historic data backfill complete!"
+ echo ""
+ echo "The Grafana dashboard timeline should now show data from:"
+ echo " - 7 days ago"
+ echo " - 6 days ago"
+ echo " - 5 days ago"
+ echo " - 4 days ago"
+ echo " - 3 days ago"
+ echo " - 2 days ago"
+ echo " - 1 day ago"
+ echo " - 12 hours ago"
+ echo " - Now (from previous realtime push)"
+else
+ echo ""
+ echo "❌ Backfill failed with exit code $EXIT_CODE"
+ echo "Check /tmp/epimetheus-prom-pf.log for port-forward logs"
+fi
+
+exit $EXIT_CODE