Add email, update README and include job in labels

This commit is contained in:
Antonio J. Delgado 2022-12-26 18:22:56 +02:00
parent e7724789c6
commit e56dd86161
3 changed files with 44 additions and 8 deletions

View file

@ -1,17 +1,53 @@
# 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](https://github.com/prometheus/node_exporter#textfile-collector).
## Requirements
## Installation
### Linux
`sudo python3 setup.py install`
```bash
sudo python3 setup.py install
```
### Windows (from PowerShell)
`& $(where.exe python).split()[0] setup.py install`
```powershell
& $(where.exe python).split()[0] setup.py install
```
## Usage
`restic_exporter.py [--debug-level|-d CRITICAL|ERROR|WARNING|INFO|DEBUG|NOTSET] # Other parameters`
```
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:
```bash
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:
```bash
restic_exporter.py --json-file /tmp/my_restic_result.json --job-name 'home_folders' > /var/lib/node_exporter/restic_home_folders.prom
```

View file

@ -3,14 +3,14 @@ requires = ["setuptools", "wheel"]
build-backend = "setuptools.build_meta"
[project.urls]
Homepage = ""
Homepage = "https://susurrando.com"
[project]
name = "restic_exporter"
version = "0.0.1"
version = "0.0.2"
description = "Export to node exporter the summary of a restic backup"
readme = "README.md"
authors = [{ name = "Antonio J. Delgado", email = "" }]
authors = [{ name = "Antonio J. Delgado", email = "ad@susurrando.com" }]
license = { file = "LICENSE" }
classifiers = [
"License :: OSI Approved :: GPLv3 License",
@ -22,4 +22,4 @@ dependencies = [
"click",
"click_config_file",
]
requires-python = ">=3"
requires-python = ">=3"

View file

@ -26,7 +26,7 @@ class restic_exporter:
self.metric_name = metric_name.replace(' ', '_')
self.metric_description = metric_description
self.labels= {}
self.labels= {"job_name": job_name}
if extra_labels:
self.labels = {