Add new label "snapshot_tags" in the list of tags separated by comma

This commit is contained in:
ngosang 2024-01-20 15:28:45 +01:00
parent 71fb2a6695
commit 10dae8da3a
2 changed files with 7 additions and 4 deletions

View file

@ -164,16 +164,16 @@ restic_locks_total 1.0
restic_snapshots_total 100.0 restic_snapshots_total 100.0
# HELP restic_backup_timestamp Timestamp of the last backup # HELP restic_backup_timestamp Timestamp of the last backup
# TYPE restic_backup_timestamp gauge # 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 # HELP restic_backup_files_total Number of files in the backup
# TYPE restic_backup_files_total counter # 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 # HELP restic_backup_size_total Total size of backup in bytes
# TYPE restic_backup_size_total counter # 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 # HELP restic_backup_snapshots_total Total number of snapshots
# TYPE restic_backup_snapshots_total counter # 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 # HELP restic_scrape_duration_seconds Amount of time each scrape takes
# TYPE restic_scrape_duration_seconds gauge # TYPE restic_scrape_duration_seconds gauge
restic_scrape_duration_seconds 166.9411084651947 restic_scrape_duration_seconds 166.9411084651947

View file

@ -43,6 +43,7 @@ class ResticCollector(object):
"client_version", "client_version",
"snapshot_hash", "snapshot_hash",
"snapshot_tag", "snapshot_tag",
"snapshot_tags",
"snapshot_paths", "snapshot_paths",
] ]
@ -98,6 +99,7 @@ class ResticCollector(object):
client["version"], client["version"],
client["snapshot_hash"], client["snapshot_hash"],
client["snapshot_tag"], client["snapshot_tag"],
client["snapshot_tags"],
client["snapshot_paths"], client["snapshot_paths"],
] ]
@ -184,6 +186,7 @@ class ResticCollector(object):
"version": snap["program_version"] if "program_version" in snap else "", "version": snap["program_version"] if "program_version" in snap else "",
"snapshot_hash": snap["hash"], "snapshot_hash": snap["hash"],
"snapshot_tag": snap["tags"][0] if "tags" in snap else "", "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 "", "snapshot_paths": ",".join(snap["paths"]) if self.include_paths else "",
"timestamp": snap["timestamp"], "timestamp": snap["timestamp"],
"size_total": stats["total_size"], "size_total": stats["total_size"],