]> git.openstreetmap.org Git - chef.git/blobdiff - cookbooks/prometheus/templates/default/backup-data.erb
Backup prometheus data to S3
[chef.git] / cookbooks / prometheus / templates / default / backup-data.erb
diff --git a/cookbooks/prometheus/templates/default/backup-data.erb b/cookbooks/prometheus/templates/default/backup-data.erb
new file mode 100644 (file)
index 0000000..e6dabd4
--- /dev/null
@@ -0,0 +1,9 @@
+#!/bin/sh
+
+# DO NOT EDIT - This file is being maintained by Chef
+
+SNAPSHOT=$(curl -XPOST http://localhost:9090/prometheus/api/v1/admin/tsdb/snapshot | jq -r .data.name)
+
+/opt/awscli/v2/current/bin/aws --profile osm-prometheus-data-upload s3 sync --storage-class=INTELLIGENT_TIERING --no-progress /var/lib/prometheus/metrics2/snapshots/${SNAPSHOT} s3://openstreetmap-prometheus-data
+
+rm -rf /var/lib/prometheus/metrics2/snapshots/${SNAPSHOT}