This project provides a Prometheus exporter for monitoring Restic snapshots. It collects details about Restic snapshots, such as ID, date, host, tags, directory, and size, and exposes them as Prometheus metrics.
- Exports the number of Restic snapshots.
- Exports detailed information about each snapshot, including:
- Snapshot ID
- Date
- Host
- Tags
- Directory
- Size (in bytes)
- Python 3.6 or higher
- Restic installed and accessible in your
PATH - Prometheus installed and configured to scrape metrics
-
Clone this repository:
git clone https://github.com/your-repo/restic-exporter.git cd restic-exporter -
Install required Python dependencies:
pip install prometheus_client
-
Configure your Restic repository and credentials in the
config.inifile:[restic] repository = password = [aws] access_key_id = secret_access_key =
-
Run the exporter:
python restic_prometheus_exporter.py config.ini
-
The exporter will start a Prometheus metrics server on port
9150and expose metrics at:http://localhost:9150/metrics -
Add the following scrape configuration to your Prometheus configuration file (
prometheus.yml):scrape_configs: - job_name: "restic_exporter" static_configs: - targets: ["localhost:9150"]
-
Restart Prometheus to apply the changes.
The following metrics are exposed:
restic_snapshot_count: The total number of Restic snapshots.restic_snapshot_details: Details of each Restic snapshot, with the following labels:id: Snapshot IDdate: Snapshot date and timehost: Hostname of the snapshottags: Tags associated with the snapshotdirectory: Directory included in the snapshotsize: Size of the snapshot in bytes
Example Prometheus metrics:
# HELP restic_snapshot_count Number of restic snapshots
# TYPE restic_snapshot_count gauge
restic_snapshot_count 2
# HELP restic_snapshot_details Details of each restic snapshot
# TYPE restic_snapshot_details gauge
restic_snapshot_details{id="6c69486e",date="2024-11-07 16:26:17",host="metrics",tags="manual,prometheus",directory="/var/lib/prometheus",size="3670511616"} 1
restic_snapshot_details{id="bbfc4e6d",date="2024-11-07 16:26:17",host="logs",tags="manual,graylog-server",directory="/usr/share/graylog-server/plugin",size="66074316"} 1
- If you encounter errors, ensure that:
- Restic is installed and accessible in your
PATH. - The
config.inifile is correctly configured with your repository and credentials. - The Prometheus server is running and configured to scrape the exporter.
- Restic is installed and accessible in your
This project is licensed under the MIT License. See the LICENSE file for details.