Prometheus
resticprofile can generate a prometheus file, or send the report to a push gateway. For now, only a backup
command will generate a report.
Here’s a configuration example with both options to generate a file and send to a push gateway:
[root]
inherit = "default"
prometheus-save-to-file = "root.prom"
prometheus-push = "http://localhost:9091/"
[root.backup]
extended-status = true
no-error-on-warning = true
source = [ "/" ]
root:
inherit: default
prometheus-save-to-file: "root.prom"
prometheus-push: "http://localhost:9091/"
backup:
extended-status: true
no-error-on-warning: true
source:
- /
"root" = {
"inherit" = "default"
"prometheus-save-to-file" = "root.prom"
"prometheus-push" = "http://localhost:9091/"
"backup" = {
"extended-status" = true
"no-error-on-warning" = true
"source" = ["/"]
}
}
{
"root": {
"inherit": "default",
"prometheus-save-to-file": "root.prom",
"prometheus-push": "http://localhost:9091/",
"backup": {
"extended-status": true,
"no-error-on-warning": true,
"source": [
"/"
]
}
}
}
Note
Please note you need to set extended-status
to true
if you want all the available metrics. See Extended status for more information.
Here’s an example of the generated prometheus file:
# HELP resticprofile_backup_added_bytes Total number of bytes added to the repository.
# TYPE resticprofile_backup_added_bytes gauge
resticprofile_backup_added_bytes{profile="prom"} 70690
# HELP resticprofile_backup_dir_changed Number of directories with changes.
# TYPE resticprofile_backup_dir_changed gauge
resticprofile_backup_dir_changed{profile="prom"} 15
# HELP resticprofile_backup_dir_new Number of new directories added to the backup.
# TYPE resticprofile_backup_dir_new gauge
resticprofile_backup_dir_new{profile="prom"} 0
# HELP resticprofile_backup_dir_unmodified Number of directories unmodified since last backup.
# TYPE resticprofile_backup_dir_unmodified gauge
resticprofile_backup_dir_unmodified{profile="prom"} 529
# HELP resticprofile_backup_duration_seconds The backup duration (in seconds).
# TYPE resticprofile_backup_duration_seconds gauge
resticprofile_backup_duration_seconds{profile="prom"} 0.879901212
# HELP resticprofile_backup_files_changed Number of files with changes.
# TYPE resticprofile_backup_files_changed gauge
resticprofile_backup_files_changed{profile="prom"} 3
# HELP resticprofile_backup_files_new Number of new files added to the backup.
# TYPE resticprofile_backup_files_new gauge
resticprofile_backup_files_new{profile="prom"} 1
# HELP resticprofile_backup_files_processed Total number of files scanned by the backup for changes.
# TYPE resticprofile_backup_files_processed gauge
resticprofile_backup_files_processed{profile="prom"} 3680
# HELP resticprofile_backup_files_unmodified Number of files unmodified since last backup.
# TYPE resticprofile_backup_files_unmodified gauge
resticprofile_backup_files_unmodified{profile="prom"} 3676
# HELP resticprofile_backup_processed_bytes Total number of bytes scanned for changes.
# TYPE resticprofile_backup_processed_bytes gauge
resticprofile_backup_processed_bytes{profile="prom"} 8.55433765e+08
# HELP resticprofile_backup_status Backup status: 0=fail, 1=warning, 2=success.
# TYPE resticprofile_backup_status gauge
resticprofile_backup_status{profile="prom"} 2
# HELP resticprofile_backup_time_seconds Last backup run (unixtime).
# TYPE resticprofile_backup_time_seconds gauge
resticprofile_backup_time_seconds{profile="prom"} 1.662310865e+09
# HELP resticprofile_build_info resticprofile build information.
# TYPE resticprofile_build_info gauge
resticprofile_build_info{goversion="go1.19",version="0.19.0"} 1
User defined labels
You can add your own prometheus labels. Please note they will be applied to all the metrics. Here’s an example:
[root]
inherit = "default"
prometheus-save-to-file = "root.prom"
prometheus-push = "http://localhost:9091/"
[[root.prometheus-labels]]
host = "{{ .Hostname }}"
[root.backup]
extended-status = true
no-error-on-warning = true
source = [ "/" ]
root:
inherit: default
prometheus-save-to-file: "root.prom"
prometheus-push: "http://localhost:9091/"
prometheus-labels:
- host: {{ .Hostname }}
backup:
extended-status: true
no-error-on-warning: true
source:
- /
"root" = {
"inherit" = "default"
"prometheus-save-to-file" = "root.prom"
"prometheus-push" = "http://localhost:9091/"
"prometheus-labels" = {
"host" = "{{ .Hostname }}"
}
"backup" = {
"extended-status" = true
"no-error-on-warning" = true
"source" = ["/"]
}
}
{
"root": {
"inherit": "default",
"prometheus-save-to-file": "root.prom",
"prometheus-push": "http://localhost:9091/",
"prometheus-labels": [
{
"host": "{{ .Hostname }}"
}
],
"backup": {
"extended-status": true,
"no-error-on-warning": true,
"source": [
"/"
]
}
}
}
which will add the host
label to all your metrics.