Include metric label client_version. Resolves #5

This commit is contained in:
ngosang 2023-10-14 23:00:13 +02:00
parent d90f46a4d1
commit a4243a8554
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",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_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",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_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",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_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",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_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

@ -40,6 +40,7 @@ class ResticCollector(object):
common_label_names = [ common_label_names = [
"client_hostname", "client_hostname",
"client_username", "client_username",
"client_version",
"snapshot_hash", "snapshot_hash",
"snapshot_tag", "snapshot_tag",
"snapshot_paths", "snapshot_paths",
@ -94,6 +95,7 @@ class ResticCollector(object):
common_label_values = [ common_label_values = [
client["hostname"], client["hostname"],
client["username"], client["username"],
client["version"],
client["snapshot_hash"], client["snapshot_hash"],
client["snapshot_tag"], client["snapshot_tag"],
client["snapshot_paths"], client["snapshot_paths"],
@ -179,6 +181,7 @@ class ResticCollector(object):
{ {
"hostname": snap["hostname"], "hostname": snap["hostname"],
"username": snap["username"], "username": snap["username"],
"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_paths": ",".join(snap["paths"]) if self.include_paths else "", "snapshot_paths": ",".join(snap["paths"]) if self.include_paths else "",