Unnamed repository; edit this file 'description' to name the repository.
Find a file
2024-11-03 15:12:52 +02:00
restic_exporter fix tuple for array 2024-11-03 15:12:52 +02:00
.gitignore increase python version and not ignore .cfg 2022-12-26 19:48:41 +02:00
LICENSE Initial commit 2022-12-26 14:51:27 +02:00
pyproject.toml increase version 2022-12-29 16:13:19 +02:00
README.md Add email, update README and include job in labels 2022-12-26 18:22:56 +02:00
requirements.txt Add option for reading the journal 2024-11-03 14:29:14 +02:00
setup.cfg increase version 2022-12-29 16:13:19 +02:00
setup.py increase version 2022-12-29 16:13:19 +02:00

restic_exporter

Convert the JSON output of a restic backup job to metrics that Prometheus Node Exporter would understand. The metrics will be shown in the standard output, so then you have to direct them to a file in the Prometheus Node Exporter folder specify with the textfile-collector.

Requirements

Installation

Linux

sudo python3 setup.py install

Windows (from PowerShell)

& $(where.exe python).split()[0] setup.py install

Usage

restic_exporter.py [OPTIONS]

Options:
-d, --debug-level [CRITICAL|ERROR|WARNING|INFO|DEBUG|NOTSET]
                                Set the debug level for the standard output.
-l, --log-file TEXT             File to store all debug messages.
-j, --json-file TEXT            JSON file containing the output of restic
                                [required]
-n, --job-name TEXT             Restic job name to attach to the exported
                                metrics  [required]
-a, --extra-labels TEXT         Pairs key=value separated by commas with
                                extra labels to add to the summary
-m, --metric-name TEXT          Metric name. Spaces will be replaced with
                                underscore (_).
-d, --metric-description TEXT   Metric description.
--config FILE                   Read configuration from FILE.
--help                          Show this message and exit.

For example, you run:

restic backup --repo /var/restic_backups --json /home > /tmp/my_restic_result.json

Then assume your Prometheus Node Exporter is running with --collector.textfile.directory=/var/lib/node_exporter (this is set in /etc/default/prometheus-node-exporter in Ubuntu for example. In this case of using the folder /var/lib/node_exporter, then you would run restic_exporter.py with this parameters:

restic_exporter.py --json-file /tmp/my_restic_result.json --job-name 'home_folders' > /var/lib/node_exporter/restic_home_folders.prom