Interview Prep/Monitoring & Observability/Long-Term Storage, Scale and Cost

How do you back up Prometheus data before a risky migration?

BeginnerScenarioLong-Term Storage, Scale and Cost
Answer

Situation read → Prometheus data is usually re-creatable, but history may be important.

What I'd do →

  1. Enable the admin API temporarily (--web.enable-admin-api).
  2. Create a snapshot:
    curl -XPOST http://localhost:9090/api/v1/admin/tsdb/snapshot
    # data goes to <data-dir>/snapshots/<timestamp>-<id>
    
  3. Copy the snapshot to object storage (aws s3 sync).
  4. To restore, start Prometheus with the snapshot directory as --storage.tsdb.path.
  5. Disable the admin API afterwards.

Why → Snapshots use hard links, so they are instant and consistent.

Interview tip → With Thanos or a remote store, object storage is already the backup.

All Monitoring & Observability questions

More on Long-Term Storage, Scale and Cost