diff --git a/backfill.sh b/backfill.sh index fd8075d..47a9b52 100755 --- a/backfill.sh +++ b/backfill.sh @@ -11,15 +11,27 @@ echo "" echo "Step 1: Stopping Prometheus..." docker stop timmy-prometheus -# 2. Copy backfill file into the Prometheus data volume +# 2. Create TSDB blocks using promtool (override entrypoint) echo "Step 2: Creating TSDB blocks from historical data..." -# Run promtool inside a temporary container with access to the Prometheus volume docker run --rm \ + --entrypoint promtool \ -v timmy-telemetry_prometheus-data:/prometheus \ -v "$(pwd)/backfill.txt:/tmp/backfill.txt:ro" \ prom/prometheus:latest \ - promtool tsdb create-blocks-from openmetrics /tmp/backfill.txt /prometheus + tsdb create-blocks-from openmetrics /tmp/backfill.txt /prometheus + +if [ $? -ne 0 ]; then + echo "" + echo "promtool not available in image, trying alternative..." + # Some prometheus images don't ship promtool — download it + docker run --rm \ + --entrypoint /bin/sh \ + -v timmy-telemetry_prometheus-data:/prometheus \ + -v "$(pwd)/backfill.txt:/tmp/backfill.txt:ro" \ + prom/prometheus:latest \ + -c "ls /bin/prom*; ls /usr/bin/prom*; which promtool" 2>&1 || true +fi echo "" echo "Step 3: Restarting Prometheus..."