#!/bin/bash # Backfill historic data to Prometheus for Epimetheus dashboard set -e 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)" echo "" echo "View the dashboard at: https://grafana.f3s.buetow.org/d/epimetheus-test/epimetheus-test-metrics" 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