From 10dae8da3a7a055d9755fa46969443f0febd097f Mon Sep 17 00:00:00 2001 From: ngosang Date: Sat, 20 Jan 2024 15:28:45 +0100 Subject: [PATCH] Add new label "snapshot_tags" in the list of tags separated by comma --- README.md | 8 ++++---- restic-exporter.py | 3 +++ 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index b1c432a..107f522 100644 --- a/README.md +++ b/README.md @@ -164,16 +164,16 @@ restic_locks_total 1.0 restic_snapshots_total 100.0 # HELP restic_backup_timestamp Timestamp of the last backup # TYPE restic_backup_timestamp gauge -restic_backup_timestamp{client_hostname="product.example.com",client_username="root",client_version="restic 0.16.0",snapshot_hash="20795072cba0953bcdbe52e9cf9d75e5726042f5bbf2584bb2999372398ee835",snapshot_tag="mysql",snapshot_paths="/mysql/data,/mysql/config"} 1.666273638e+09 +restic_backup_timestamp{client_hostname="product.example.com",client_username="root",client_version="restic 0.16.0",snapshot_hash="20795072cba0953bcdbe52e9cf9d75e5726042f5bbf2584bb2999372398ee835",snapshot_tag="mysql",snapshot_tags="mysql,tag2",snapshot_paths="/mysql/data,/mysql/config"} 1.666273638e+09 # HELP restic_backup_files_total Number of files in the backup # TYPE restic_backup_files_total counter -restic_backup_files_total{client_hostname="product.example.com",client_username="root",client_version="restic 0.16.0",snapshot_hash="20795072cba0953bcdbe52e9cf9d75e5726042f5bbf2584bb2999372398ee835",snapshot_tag="mysql",snapshot_paths="/mysql/data,/mysql/config"} 8.0 +restic_backup_files_total{client_hostname="product.example.com",client_username="root",client_version="restic 0.16.0",snapshot_hash="20795072cba0953bcdbe52e9cf9d75e5726042f5bbf2584bb2999372398ee835",snapshot_tag="mysql",snapshot_tags="mysql,tag2",snapshot_paths="/mysql/data,/mysql/config"} 8.0 # HELP restic_backup_size_total Total size of backup in bytes # TYPE restic_backup_size_total counter -restic_backup_size_total{client_hostname="product.example.com",client_username="root",client_version="restic 0.16.0",snapshot_hash="20795072cba0953bcdbe52e9cf9d75e5726042f5bbf2584bb2999372398ee835",snapshot_tag="mysql",snapshot_paths="/mysql/data,/mysql/config"} 4.3309562e+07 +restic_backup_size_total{client_hostname="product.example.com",client_username="root",client_version="restic 0.16.0",snapshot_hash="20795072cba0953bcdbe52e9cf9d75e5726042f5bbf2584bb2999372398ee835",snapshot_tag="mysql",snapshot_tags="mysql,tag2",snapshot_paths="/mysql/data,/mysql/config"} 4.3309562e+07 # HELP restic_backup_snapshots_total Total number of snapshots # TYPE restic_backup_snapshots_total counter -restic_backup_snapshots_total{client_hostname="product.example.com",client_username="root",client_version="restic 0.16.0",snapshot_hash="20795072cba0953bcdbe52e9cf9d75e5726042f5bbf2584bb2999372398ee835",snapshot_tag="mysql",snapshot_paths="/mysql/data,/mysql/config"} 1.0 +restic_backup_snapshots_total{client_hostname="product.example.com",client_username="root",client_version="restic 0.16.0",snapshot_hash="20795072cba0953bcdbe52e9cf9d75e5726042f5bbf2584bb2999372398ee835",snapshot_tag="mysql",snapshot_tags="mysql,tag2",snapshot_paths="/mysql/data,/mysql/config"} 1.0 # HELP restic_scrape_duration_seconds Amount of time each scrape takes # TYPE restic_scrape_duration_seconds gauge restic_scrape_duration_seconds 166.9411084651947 diff --git a/restic-exporter.py b/restic-exporter.py index 74d5526..27f9fab 100644 --- a/restic-exporter.py +++ b/restic-exporter.py @@ -43,6 +43,7 @@ class ResticCollector(object): "client_version", "snapshot_hash", "snapshot_tag", + "snapshot_tags", "snapshot_paths", ] @@ -98,6 +99,7 @@ class ResticCollector(object): client["version"], client["snapshot_hash"], client["snapshot_tag"], + client["snapshot_tags"], client["snapshot_paths"], ] @@ -184,6 +186,7 @@ class ResticCollector(object): "version": snap["program_version"] if "program_version" in snap else "", "snapshot_hash": snap["hash"], "snapshot_tag": snap["tags"][0] if "tags" in snap else "", + "snapshot_tags": ",".join(snap["tags"]) if "tags" in snap else "", "snapshot_paths": ",".join(snap["paths"]) if self.include_paths else "", "timestamp": snap["timestamp"], "size_total": stats["total_size"],