Skip to content

Commit

Permalink
Merge pull request #2 from woblerr/rename_backup_metrics
Browse files Browse the repository at this point in the history
Rename backup metrics.
  • Loading branch information
woblerr authored Jul 1, 2021
2 parents 80fefce + 2742a37 commit ae585bf
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 41 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ The metrics provided by the client.
- 1 - info about backup is exist.

* `pgbackrest_exporter_backup_duration` - backup duration in seconds.
* `pgbackrest_exporter_backup_size` - amount of data in the database to actually backup.
* `pgbackrest_exporter_backup_database_size` - full uncompressed size of the database.
* `pgbackrest_exporter_backup_database_backup_size` - amount of data in the database to actually backup.
* `pgbackrest_exporter_backup_repo_backup_set_size` - full compressed files size to restore the database from backup.
* `pgbackrest_exporter_backup_repo_backup_size` - compressed files size in backup.
* `pgbackrest_exporter_wal_archive_status` - current WAL archive status.
Expand Down
52 changes: 26 additions & 26 deletions backrest/backrest_parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,22 +56,22 @@ var (
"stanza",
"start_time",
"stop_time"})
// The 'database backup size' is the amount of data in the database
// to actually backup (these will be the same for full backups).
pgbrStanzaBackupSizeMetric = promauto.NewGaugeVec(prometheus.GaugeOpts{
Name: "pgbackrest_exporter_backup_size",
Help: "Amount of data in the database to actually backup.",
// The 'database size' is the full uncompressed size of the database.
pgbrStanzaBackupDatabaseSizeMetric = promauto.NewGaugeVec(prometheus.GaugeOpts{
Name: "pgbackrest_exporter_backup_database_size",
Help: "Full uncompressed size of the database.",
},
[]string{
"backup_name",
"backup_type",
"database_id",
"repo_key",
"stanza"})
// The 'database size' is the full uncompressed size of the database.
pgbrStanzaBackupDatabaseSizeMetric = promauto.NewGaugeVec(prometheus.GaugeOpts{
Name: "pgbackrest_exporter_backup_database_size",
Help: "Full uncompressed size of the database.",
// The 'database backup size' is the amount of data in the database
// to actually backup (these will be the same for full backups).
pgbrStanzaBackupDatabaseBackupSizeMetric = promauto.NewGaugeVec(prometheus.GaugeOpts{
Name: "pgbackrest_exporter_backup_database_backup_size",
Help: "Amount of data in the database to actually backup.",
},
[]string{
"backup_name",
Expand All @@ -84,7 +84,7 @@ var (
// to restore the database from this backup.
// Repository 'backup set size' reflect compressed file sizes
// if compression is enabled in pgBackRest or the filesystem.
pgbrStanzaRepoBackupSetSizeMetric = promauto.NewGaugeVec(prometheus.GaugeOpts{
pgbrStanzaBackupRepoBackupSetSizeMetric = promauto.NewGaugeVec(prometheus.GaugeOpts{
Name: "pgbackrest_exporter_backup_repo_backup_set_size",
Help: "Full compressed files size to restore the database from backup.",
},
Expand All @@ -98,7 +98,7 @@ var (
// (these will also be the same for full backups).
// Repository 'backup size' reflect compressed file sizes
// if compression is enabled in pgBackRest or the filesystem.
pgbrStanzaRepoBackupSizeMetric = promauto.NewGaugeVec(prometheus.GaugeOpts{
pgbrStanzaBackupRepoBackupSizeMetric = promauto.NewGaugeVec(prometheus.GaugeOpts{
Name: "pgbackrest_exporter_backup_repo_backup_size",
Help: "Compressed files size in backup.",
},
Expand Down Expand Up @@ -140,10 +140,10 @@ func resetMetrics() {
pgbrRepoStatusMetric.Reset()
pgbrStanzaBackupInfoMetric.Reset()
pgbrStanzaBackupDurationMetric.Reset()
pgbrStanzaBackupSizeMetric.Reset()
pgbrStanzaBackupDatabaseSizeMetric.Reset()
pgbrStanzaRepoBackupSetSizeMetric.Reset()
pgbrStanzaRepoBackupSizeMetric.Reset()
pgbrStanzaBackupDatabaseBackupSizeMetric.Reset()
pgbrStanzaBackupRepoBackupSetSizeMetric.Reset()
pgbrStanzaBackupRepoBackupSizeMetric.Reset()
pgbrWALArchivingMetric.Reset()
}

Expand Down Expand Up @@ -243,10 +243,10 @@ func getMetrics(data stanza, verbose bool, setUpMetricValueFun setUpMetricValueF
time.Unix(backup.Timestamp.Stop, 0).Format(layout), ".",
)
}
// Database backup size.
// Database size.
err = setUpMetricValueFun(
pgbrStanzaBackupSizeMetric,
float64(backup.Info.Delta),
pgbrStanzaBackupDatabaseSizeMetric,
float64(backup.Info.Size),
backup.Label,
backup.Type,
strconv.Itoa(backup.Database.ID),
Expand All @@ -255,8 +255,8 @@ func getMetrics(data stanza, verbose bool, setUpMetricValueFun setUpMetricValueF
)
if err != nil {
log.Println(
"[ERROR] Metric pgbackrest_exporter_backup_size set up failed;",
"value:", float64(backup.Info.Delta), ";",
"[ERROR] Metric pgbackrest_exporter_backup_database_size set up failed;",
"value:", float64(backup.Info.Size), ";",
"labels:",
backup.Label, ",",
backup.Type, ",",
Expand All @@ -265,10 +265,10 @@ func getMetrics(data stanza, verbose bool, setUpMetricValueFun setUpMetricValueF
data.Name, ".",
)
}
// Database size.
// Database backup size.
err = setUpMetricValueFun(
pgbrStanzaBackupDatabaseSizeMetric,
float64(backup.Info.Size),
pgbrStanzaBackupDatabaseBackupSizeMetric,
float64(backup.Info.Delta),
backup.Label,
backup.Type,
strconv.Itoa(backup.Database.ID),
Expand All @@ -277,8 +277,8 @@ func getMetrics(data stanza, verbose bool, setUpMetricValueFun setUpMetricValueF
)
if err != nil {
log.Println(
"[ERROR] Metric pgbackrest_exporter_backup_database_size set up failed;",
"value:", float64(backup.Info.Size), ";",
"[ERROR] Metric pgbackrest_exporter_backup_database_backup_size set up failed;",
"value:", float64(backup.Info.Delta), ";",
"labels:",
backup.Label, ",",
backup.Type, ",",
Expand All @@ -289,7 +289,7 @@ func getMetrics(data stanza, verbose bool, setUpMetricValueFun setUpMetricValueF
}
// Repo backup set size.
err = setUpMetricValueFun(
pgbrStanzaRepoBackupSetSizeMetric,
pgbrStanzaBackupRepoBackupSetSizeMetric,
float64(backup.Info.Repository.Size),
backup.Label,
backup.Type,
Expand All @@ -311,7 +311,7 @@ func getMetrics(data stanza, verbose bool, setUpMetricValueFun setUpMetricValueF
}
// Repo backup size.
err = setUpMetricValueFun(
pgbrStanzaRepoBackupSizeMetric,
pgbrStanzaBackupRepoBackupSizeMetric,
float64(backup.Info.Repository.Delta),
backup.Label,
backup.Type,
Expand Down
28 changes: 14 additions & 14 deletions backrest/backrest_parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ func TestGetMetrics(t *testing.T) {
testText string
setUpMetricValueFun setUpMetricValueFunType
}
templateMetrics := `# HELP pgbackrest_exporter_backup_database_size Full uncompressed size of the database.
templateMetrics := `# HELP pgbackrest_exporter_backup_database_backup_size Amount of data in the database to actually backup.
# TYPE pgbackrest_exporter_backup_database_backup_size gauge
pgbackrest_exporter_backup_database_backup_size{backup_name="20210607-092423F",backup_type="full",database_id="1",repo_key="1",stanza="demo"} 2.4316343e+07
# HELP pgbackrest_exporter_backup_database_size Full uncompressed size of the database.
# TYPE pgbackrest_exporter_backup_database_size gauge
pgbackrest_exporter_backup_database_size{backup_name="20210607-092423F",backup_type="full",database_id="1",repo_key="1",stanza="demo"} 2.4316343e+07
# HELP pgbackrest_exporter_backup_duration Backup duration in seconds.
Expand All @@ -34,9 +37,6 @@ pgbackrest_exporter_backup_repo_backup_set_size{backup_name="20210607-092423F",b
# HELP pgbackrest_exporter_backup_repo_backup_size Compressed files size in backup.
# TYPE pgbackrest_exporter_backup_repo_backup_size gauge
pgbackrest_exporter_backup_repo_backup_size{backup_name="20210607-092423F",backup_type="full",database_id="1",repo_key="1",stanza="demo"} 2.969514e+06
# HELP pgbackrest_exporter_backup_size Amount of data in the database to actually backup.
# TYPE pgbackrest_exporter_backup_size gauge
pgbackrest_exporter_backup_size{backup_name="20210607-092423F",backup_type="full",database_id="1",repo_key="1",stanza="demo"} 2.4316343e+07
# HELP pgbackrest_exporter_repo_status Current repository status.
# TYPE pgbackrest_exporter_repo_status gauge
pgbackrest_exporter_repo_status{cipher="none",repo_key="1",stanza="demo"} 0
Expand Down Expand Up @@ -90,10 +90,10 @@ pgbackrest_exporter_stanza_status{stanza="demo"} 0
pgbrRepoStatusMetric,
pgbrStanzaBackupInfoMetric,
pgbrStanzaBackupDurationMetric,
pgbrStanzaBackupSizeMetric,
pgbrStanzaBackupDatabaseSizeMetric,
pgbrStanzaRepoBackupSetSizeMetric,
pgbrStanzaRepoBackupSizeMetric,
pgbrStanzaBackupDatabaseBackupSizeMetric,
pgbrStanzaBackupRepoBackupSetSizeMetric,
pgbrStanzaBackupRepoBackupSizeMetric,
pgbrWALArchivingMetric,
)
metricFamily, err := reg.Gather()
Expand Down Expand Up @@ -121,7 +121,10 @@ func TestGetMetricsRepoAbsent(t *testing.T) {
testText string
setUpMetricValueFun setUpMetricValueFunType
}
templateMetrics := `# HELP pgbackrest_exporter_backup_database_size Full uncompressed size of the database.
templateMetrics := `# HELP pgbackrest_exporter_backup_database_backup_size Amount of data in the database to actually backup.
# TYPE pgbackrest_exporter_backup_database_backup_size gauge
pgbackrest_exporter_backup_database_backup_size{backup_name="20210607-092423F",backup_type="full",database_id="1",repo_key="0",stanza="demo"} 2.4316343e+07
# HELP pgbackrest_exporter_backup_database_size Full uncompressed size of the database.
# TYPE pgbackrest_exporter_backup_database_size gauge
pgbackrest_exporter_backup_database_size{backup_name="20210607-092423F",backup_type="full",database_id="1",repo_key="0",stanza="demo"} 2.4316343e+07
# HELP pgbackrest_exporter_backup_duration Backup duration in seconds.
Expand All @@ -136,9 +139,6 @@ pgbackrest_exporter_backup_repo_backup_set_size{backup_name="20210607-092423F",b
# HELP pgbackrest_exporter_backup_repo_backup_size Compressed files size in backup.
# TYPE pgbackrest_exporter_backup_repo_backup_size gauge
pgbackrest_exporter_backup_repo_backup_size{backup_name="20210607-092423F",backup_type="full",database_id="1",repo_key="0",stanza="demo"} 2.969514e+06
# HELP pgbackrest_exporter_backup_size Amount of data in the database to actually backup.
# TYPE pgbackrest_exporter_backup_size gauge
pgbackrest_exporter_backup_size{backup_name="20210607-092423F",backup_type="full",database_id="1",repo_key="0",stanza="demo"} 2.4316343e+07
# HELP pgbackrest_exporter_stanza_status Current stanza status.
# TYPE pgbackrest_exporter_stanza_status gauge
pgbackrest_exporter_stanza_status{stanza="demo"} 0
Expand Down Expand Up @@ -169,10 +169,10 @@ pgbackrest_exporter_stanza_status{stanza="demo"} 0
pgbrRepoStatusMetric,
pgbrStanzaBackupInfoMetric,
pgbrStanzaBackupDurationMetric,
pgbrStanzaBackupSizeMetric,
pgbrStanzaBackupDatabaseSizeMetric,
pgbrStanzaRepoBackupSetSizeMetric,
pgbrStanzaRepoBackupSizeMetric,
pgbrStanzaBackupDatabaseBackupSizeMetric,
pgbrStanzaBackupRepoBackupSetSizeMetric,
pgbrStanzaBackupRepoBackupSizeMetric,
pgbrWALArchivingMetric,
)
metricFamily, err := reg.Gather()
Expand Down

0 comments on commit ae585bf

Please sign in to comment.