Como instalar, fazer backup e restore do Prometheus

Neste artigo, vamos explorar como realizar backup e restauração no Prometheus, garantindo assim a segurança e a integridade das informações monitoradas. Confira no passo a passo.

Habilitar API ADMIN

    • kubectl -n monitoring patch prometheus k8s  –type merge –patch ‘{“spec”:{“enableAdminAPI”:true}}’

    • kubectl -n monitoring get sts prometheus-k8s -o yaml | grep admin

Backup

    • kubectl port-forward -n monitoring service/prometheus-k8s 9090

    • curl -X POST http://localhost:9090/api/v1/admin/tsdb/snapshot

    • kubectl -n monitoring exec -it prometheus-k8s-1 -c prometheus — /bin/sh –

    • cd snapshot

    • ls

 

    • kubectl cp -n monitoring prometheus-k8s-1:/prometheus/snapshots/20240121T182958Z-472ad4111ae05434 -c prometheus .

    • ls

 Restore

    • kubectl -n monitoring exec -it prometheus-k8s-1 — /bin/sh -c “rm -rf /prometheus/*”

    • kubectl -n monitoring exec -it prometheus-k8s-1 -c prometheus — /bin/sh –

    • ls

 

    • kubectl -n monitoring cp .  prometheus-k8s-1:/prometheus/ -c prometheus

    • kubectl -n monitoring exec -it prometheus-k8s-1 -c prometheus — /bin/sh –

    • ls

Rolar para cima