Skip to content

Instantly share code, notes, and snippets.

@aojea
Last active February 1, 2022 10:46
Show Gist options
  • Save aojea/afddbcb819100d40f6d3ef8540da7679 to your computer and use it in GitHub Desktop.
Save aojea/afddbcb819100d40f6d3ef8540da7679 to your computer and use it in GitHub Desktop.
restore prometheus dump
  1. create a snapshot of the db
curl -XPOST http://${PROMETHEUS_IP}:8080/api/v1/admin/tsdb/snapshot
  1. get the prometheus database
tar cvf prometheus.tar /prometheus/snapshots 
  1. create a fake prometheus config so it does not complain
touch prometheus.yaml
  1. init the container mounting the folder with the metrics
$ tar xvf prometheus.tar 
 prometheus/snapshots/
 prometheus/snapshots/20210413T203151Z-3f4863bc7872c82f/

$  docker run --rm -p 9090:9090 -uroot \
       -v $PWD/prometheus/snapshots/20210413T203151Z-3f4863bc7872c82f:/prometheus \
       -v $PWD/prometheus.yml:/prometheus/prometheus.yml \
       prom/prometheus --storage.tsdb.path=/prometheus
  1. bonus use grafana (admin:admin) and add prometheus as source
docker run -d -p 3000:3000 grafana/grafana
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment