Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Prometheus export / import data for backup

How do you export and import data in Prometheus? How do you make sure the data is backed up if the instance gets down?

It does not seem that there is a such feature yet, how do you do then?

like image 660
Arkon Avatar asked Sep 21 '17 16:09

Arkon


People also ask

How do I backup my data on Prometheus?

Backup Prometheus dataFind the snapshot and copy it to locally. The default folder is /prometheus/snapshots/ but you can find the data folder by finding the --storage. tsdb. path config in your deployment.


3 Answers

Since Prometheus version 2.1 it is possible to ask the server for a snapshot. The documentation provides more details - https://web.archive.org/web/20200101000000/https://prometheus.io/docs/prometheus/2.1/querying/api/#snapshot

Once a snapshot is created, it can be copied somewhere for safe keeping and if required a new server can be created using this snapshot as its database.

The documentation website constantly changes all the URLs, this links to fairly recent documentation on this - https://prometheus.io/docs/prometheus/latest/querying/api/#tsdb-admin-apis

like image 76
Evgeny Avatar answered Nov 11 '22 21:11

Evgeny


There is no export and especially no import feature for Prometheus.

If you need to keep data collected by prometheus for some reason, consider using the remote write interface to write it somewhere suitable for archival, such as InfluxDB (configured as a time-series database).

Prometheus isn't a long term storage: if the database is lost, the user is expected to shrug, mumble "oh well", and restart Prometheus.

credits and many thanks to amorken from IRC #prometheus.

like image 39
Arkon Avatar answered Nov 11 '22 22:11

Arkon


There is an option to enable Prometheus data replication to remote storage backend. Later the data collected from multiple Prometheus instances could be backed up in one place on the remote storage backend. See, for example, how VictoriaMetrics remote storage can save time and network bandwidth when creating backups to S3 or GCS with vmbackup utility.

like image 34
valyala Avatar answered Nov 11 '22 22:11

valyala