@@ -259,6 +259,9 @@ func TestGetRepoMetricsErrorsAndDebugs(t *testing.T) {
259
259
// All metrics exist and all labels are corrected.
260
260
// pgBackrest version = latest.
261
261
// With '--backrest.database-count' flag.
262
+ // The case when the backup is performed with block incremental feature flags.
263
+ // Absent metrics:
264
+ // - pgbackrest_backup_repo_size_bytes
262
265
//
263
266
//nolint:dupl
264
267
func TestGetBackupMetrics (t * testing.T ) {
@@ -287,16 +290,13 @@ pgbackrest_backup_duration_seconds{backup_name="20210607-092423F",backup_type="f
287
290
pgbackrest_backup_error_status{backup_name="20210607-092423F",backup_type="full",database_id="1",repo_key="1",stanza="demo"} 1
288
291
# HELP pgbackrest_backup_info Backup info.
289
292
# TYPE pgbackrest_backup_info gauge
290
- pgbackrest_backup_info{backrest_ver="2.44 ",backup_name="20210607-092423F",backup_type="full",block_incr="y",database_id="1",lsn_start="0/2000028",lsn_stop="0/2000100",pg_version="13",prior="",repo_key="1",stanza="demo",wal_start="000000010000000000000002",wal_stop="000000010000000000000002"} 1
293
+ pgbackrest_backup_info{backrest_ver="2.45 ",backup_name="20210607-092423F",backup_type="full",block_incr="y",database_id="1",lsn_start="0/2000028",lsn_stop="0/2000100",pg_version="13",prior="",repo_key="1",stanza="demo",wal_start="000000010000000000000002",wal_stop="000000010000000000000002"} 1
291
294
# HELP pgbackrest_backup_repo_delta_bytes Compressed files size in backup.
292
295
# TYPE pgbackrest_backup_repo_delta_bytes gauge
293
296
pgbackrest_backup_repo_delta_bytes{backup_name="20210607-092423F",backup_type="full",database_id="1",repo_key="1",stanza="demo"} 2.969514e+06
294
297
# HELP pgbackrest_backup_repo_delta_map_bytes Size of block incremental delta map.
295
298
# TYPE pgbackrest_backup_repo_delta_map_bytes gauge
296
299
pgbackrest_backup_repo_delta_map_bytes{backup_name="20210607-092423F",backup_type="full",database_id="1",repo_key="1",stanza="demo"} 12
297
- # HELP pgbackrest_backup_repo_size_bytes Full compressed files size to restore the database from backup.
298
- # TYPE pgbackrest_backup_repo_size_bytes gauge
299
- pgbackrest_backup_repo_size_bytes{backup_name="20210607-092423F",backup_type="full",database_id="1",repo_key="1",stanza="demo"} 2.969514e+06
300
300
# HELP pgbackrest_backup_repo_size_map_bytes Size of block incremental map.
301
301
# TYPE pgbackrest_backup_repo_size_map_bytes gauge
302
302
pgbackrest_backup_repo_size_map_bytes{backup_name="20210607-092423F",backup_type="full",database_id="1",repo_key="1",stanza="demo"} 100
@@ -344,9 +344,9 @@ pgbackrest_backup_size_bytes{backup_name="20210607-092423F",backup_type="full",d
344
344
`[{"archive":[{"database":{"id":1,"repo-key":1},"id":"13-1",` +
345
345
`"max":"000000010000000000000002","min":"000000010000000000000001"}],` +
346
346
`"backup":[{"archive":{"start":"000000010000000000000002","stop":"000000010000000000000002"},` +
347
- `"backrest":{"format":5,"version":"2.44 "},"database":{"id":1,"repo-key":1},` +
347
+ `"backrest":{"format":5,"version":"2.45 "},"database":{"id":1,"repo-key":1},` +
348
348
`"database-ref":[{"name":"postgres","oid":13412}],"error":true,"error-list":["base/1/3351"],` +
349
- `"info":{"delta":24316343,"repository":{"delta":2969512, "delta-map":12,"size":2969512,"size -map":100},"size":24316343},` +
349
+ `"info":{"delta":24316343,"repository":{"delta":2969512, "delta-map":12,"size-map":100},"size":24316343},` +
350
350
`"label":"20210614-213200F","lsn":{"start":"0/2000028","stop":"0/2000100"},"prior":null,"reference":null,"timestamp":{"start":1623706320,` +
351
351
`"stop":1623706322},"type":"full"}],"cipher":"none","db":[{"id":1,"repo-key":1,` +
352
352
`"system-id":6970977677138971135,"version":"13"}],"name":"demo","repo":[{"cipher":"none",` +
@@ -454,17 +454,17 @@ pgbackrest_backup_size_bytes{backup_name="20210607-092423F",backup_type="full",d
454
454
"000000010000000000000004" ,
455
455
"000000010000000000000001" ,
456
456
[]databaseRef {{"postgres" , 13425 }},
457
- true ).Name ,
457
+ true , 2969514 ).Name ,
458
458
templateStanzaRepoMapSizesAbsent (
459
459
"000000010000000000000004" ,
460
460
"000000010000000000000001" ,
461
461
[]databaseRef {{"postgres" , 13425 }},
462
- true ).Backup ,
462
+ true , 2969514 ).Backup ,
463
463
templateStanzaRepoMapSizesAbsent (
464
464
"000000010000000000000004" ,
465
465
"000000010000000000000001" ,
466
466
[]databaseRef {{"postgres" , 13425 }},
467
- true ).DB ,
467
+ true , 2969514 ).DB ,
468
468
true ,
469
469
setUpMetricValue ,
470
470
templateMetrics ,
@@ -572,17 +572,20 @@ pgbackrest_backup_size_bytes{backup_name="20210607-092423F",backup_type="full",d
572
572
"000000010000000000000004" ,
573
573
"000000010000000000000001" ,
574
574
[]databaseRef {{"postgres" , 13425 }},
575
- true ).Name ,
575
+ true ,
576
+ 2969514 ).Name ,
576
577
templateStanzaRepoMapSizesAbsent (
577
578
"000000010000000000000004" ,
578
579
"000000010000000000000001" ,
579
580
[]databaseRef {{"postgres" , 13425 }},
580
- true ).Backup ,
581
+ true ,
582
+ 2969514 ).Backup ,
581
583
templateStanzaRepoMapSizesAbsent (
582
584
"000000010000000000000004" ,
583
585
"000000010000000000000001" ,
584
586
[]databaseRef {{"postgres" , 13425 }},
585
- true ).DB ,
587
+ true ,
588
+ 2969514 ).DB ,
586
589
true ,
587
590
setUpMetricValue ,
588
591
templateMetrics ,
@@ -689,13 +692,16 @@ pgbackrest_backup_size_bytes{backup_name="20210607-092423F",backup_type="full",d
689
692
"" ,
690
693
templateStanzaErrorAbsent (
691
694
"000000010000000000000004" ,
692
- "000000010000000000000001" ).Name ,
695
+ "000000010000000000000001" ,
696
+ 2969514 ).Name ,
693
697
templateStanzaErrorAbsent (
694
698
"000000010000000000000004" ,
695
- "000000010000000000000001" ).Backup ,
699
+ "000000010000000000000001" ,
700
+ 2969514 ).Backup ,
696
701
templateStanzaErrorAbsent (
697
702
"000000010000000000000004" ,
698
- "000000010000000000000001" ).DB ,
703
+ "000000010000000000000001" ,
704
+ 2969514 ).DB ,
699
705
true ,
700
706
setUpMetricValue ,
701
707
templateMetrics ,
@@ -802,13 +808,16 @@ pgbackrest_backup_size_bytes{backup_name="20210607-092423F",backup_type="full",d
802
808
"" ,
803
809
templateStanzaRepoAbsent (
804
810
"000000010000000000000004" ,
805
- "000000010000000000000001" ).Name ,
811
+ "000000010000000000000001" ,
812
+ 2969514 ).Name ,
806
813
templateStanzaRepoAbsent (
807
814
"000000010000000000000004" ,
808
- "000000010000000000000001" ).Backup ,
815
+ "000000010000000000000001" ,
816
+ 2969514 ).Backup ,
809
817
templateStanzaRepoAbsent (
810
818
"000000010000000000000004" ,
811
- "000000010000000000000001" ).DB ,
819
+ "000000010000000000000001" ,
820
+ 2969514 ).DB ,
812
821
false ,
813
822
setUpMetricValue ,
814
823
templateMetrics ,
@@ -875,6 +884,8 @@ func TestGetBackupMetricsErrorsAndDebugs(t *testing.T) {
875
884
args args
876
885
mockTestData mockStruct
877
886
}{
887
+ // pgBackRest >= 2.45
888
+ // Without backup set size.
878
889
{
879
890
"getBackupMetricsLogError" ,
880
891
args {
@@ -903,8 +914,55 @@ func TestGetBackupMetricsErrorsAndDebugs(t *testing.T) {
903
914
100 ).DB ,
904
915
true ,
905
916
fakeSetUpMetricValue ,
906
- 10 ,
907
- 10 ,
917
+ 9 ,
918
+ 9 ,
919
+ },
920
+ mockStruct {
921
+ `[{"archive":[{"database":{"id":1,"repo-key":1},"id":"13-1",` +
922
+ `"max":"000000010000000000000002","min":"000000010000000000000001"}],` +
923
+ `"backup":[{"archive":{"start":"000000010000000000000002","stop":"000000010000000000000002"},` +
924
+ `"backrest":{"format":5,"version":"2.41"},"database":{"id":1,"repo-key":1},` +
925
+ `"database-ref":[{"name":"postgres","oid":13412}],"error":true,"error-list":["base/1/3351"],` +
926
+ `"info":{"delta":24316343,"repository":{"delta":2969512, "delta-map":12,"size-map":100},"size":24316343},` +
927
+ `"label":"20210614-213200F","lsn":{"start":"0/2000028","stop":"0/2000100"},"prior":null,"reference":null,"timestamp":{"start":1623706320,` +
928
+ `"stop":1623706322},"type":"full"}],"cipher":"none","db":[{"id":1,"repo-key":1,` +
929
+ `"system-id":6970977677138971135,"version":"13"}],"name":"demo","repo":[{"cipher":"none",` +
930
+ `"key":1,"status":{"code":0,"message":"ok"}}],"status":{"code":0,"lock":{"backup":` +
931
+ `{"held":false}},"message":"ok"}}]` ,
932
+ "" ,
933
+ 0 ,
934
+ },
935
+ },
936
+ // pgBackrest older than v2.45.
937
+ // Here the version is not important.
938
+ // Getting an error is being tested for backup set size.
939
+ {
940
+ "getBackupMetricsLogErrorWithRepo" ,
941
+ args {
942
+ "" ,
943
+ "" ,
944
+ templateStanzaRepoMapSizesAbsent (
945
+ "000000010000000000000004" ,
946
+ "000000010000000000000001" ,
947
+ []databaseRef {{"postgres" , 13425 }},
948
+ true ,
949
+ 2969514 ).Name ,
950
+ templateStanzaRepoMapSizesAbsent (
951
+ "000000010000000000000004" ,
952
+ "000000010000000000000001" ,
953
+ []databaseRef {{"postgres" , 13425 }},
954
+ true ,
955
+ 2969514 ).Backup ,
956
+ templateStanzaRepoMapSizesAbsent (
957
+ "000000010000000000000004" ,
958
+ "000000010000000000000001" ,
959
+ []databaseRef {{"postgres" , 13425 }},
960
+ true ,
961
+ 2969514 ).DB ,
962
+ true ,
963
+ fakeSetUpMetricValue ,
964
+ 8 ,
965
+ 8 ,
908
966
},
909
967
mockStruct {
910
968
`[{"archive":[{"database":{"id":1,"repo-key":1},"id":"13-1",` +
@@ -1831,6 +1889,7 @@ func fakeSetUpMetricValue(metric *prometheus.GaugeVec, value float64, labels ...
1831
1889
//nolint:unparam
1832
1890
func templateStanza (walMax , walMin string , dbRef []databaseRef , errorStatus bool , deltaMap , sizeMap int64 ) stanza {
1833
1891
var (
1892
+ size * int64
1834
1893
link * []struct {
1835
1894
Destination string "json:\" destination\" "
1836
1895
Name string "json:\" name\" "
@@ -1854,7 +1913,7 @@ func templateStanza(walMax, walMin string, dbRef []databaseRef, errorStatus bool
1854
1913
struct {
1855
1914
Format int "json:\" format\" "
1856
1915
Version string "json:\" version\" "
1857
- }{5 , "2.44 " },
1916
+ }{5 , "2.45 " },
1858
1917
databaseID {1 , 1 },
1859
1918
& dbRef ,
1860
1919
& errorStatus ,
@@ -1863,9 +1922,9 @@ func templateStanza(walMax, walMin string, dbRef []databaseRef, errorStatus bool
1863
1922
struct {
1864
1923
Delta int64 "json:\" delta\" "
1865
1924
DeltaMap * int64 "json:\" delta-map\" "
1866
- Size int64 "json:\" size\" "
1925
+ Size * int64 "json:\" size\" "
1867
1926
SizeMap * int64 "json:\" size-map\" "
1868
- }{2969514 , & deltaMap , 2969514 , & sizeMap },
1927
+ }{2969514 , & deltaMap , size , & sizeMap },
1869
1928
24316343 ,
1870
1929
},
1871
1930
"20210607-092423F" ,
@@ -1915,7 +1974,7 @@ func templateStanza(walMax, walMin string, dbRef []databaseRef, errorStatus bool
1915
1974
}
1916
1975
1917
1976
//nolint:unparam
1918
- func templateStanzaRepoMapSizesAbsent (walMax , walMin string , dbRef []databaseRef , errorStatus bool ) stanza {
1977
+ func templateStanzaRepoMapSizesAbsent (walMax , walMin string , dbRef []databaseRef , errorStatus bool , size int64 ) stanza {
1919
1978
var (
1920
1979
deltaMap , sizeMap * int64
1921
1980
link * []struct {
@@ -1950,9 +2009,9 @@ func templateStanzaRepoMapSizesAbsent(walMax, walMin string, dbRef []databaseRef
1950
2009
struct {
1951
2010
Delta int64 "json:\" delta\" "
1952
2011
DeltaMap * int64 "json:\" delta-map\" "
1953
- Size int64 "json:\" size\" "
2012
+ Size * int64 "json:\" size\" "
1954
2013
SizeMap * int64 "json:\" size-map\" "
1955
- }{2969514 , deltaMap , 2969514 , sizeMap },
2014
+ }{2969514 , deltaMap , & size , sizeMap },
1956
2015
24316343 ,
1957
2016
},
1958
2017
"20210607-092423F" ,
@@ -2002,7 +2061,7 @@ func templateStanzaRepoMapSizesAbsent(walMax, walMin string, dbRef []databaseRef
2002
2061
}
2003
2062
2004
2063
//nolint:unparam
2005
- func templateStanzaErrorAbsent (walMax , walMin string ) stanza {
2064
+ func templateStanzaErrorAbsent (walMax , walMin string , size int64 ) stanza {
2006
2065
var (
2007
2066
errorStatus * bool
2008
2067
deltaMap , sizeMap * int64
@@ -2039,9 +2098,9 @@ func templateStanzaErrorAbsent(walMax, walMin string) stanza {
2039
2098
struct {
2040
2099
Delta int64 "json:\" delta\" "
2041
2100
DeltaMap * int64 "json:\" delta-map\" "
2042
- Size int64 "json:\" size\" "
2101
+ Size * int64 "json:\" size\" "
2043
2102
SizeMap * int64 "json:\" size-map\" "
2044
- }{2969514 , deltaMap , 2969514 , sizeMap },
2103
+ }{2969514 , deltaMap , & size , sizeMap },
2045
2104
24316343 ,
2046
2105
},
2047
2106
"20210607-092423F" ,
@@ -2091,7 +2150,7 @@ func templateStanzaErrorAbsent(walMax, walMin string) stanza {
2091
2150
}
2092
2151
2093
2152
//nolint:unparam
2094
- func templateStanzaRepoAbsent (walMax , walMin string ) stanza {
2153
+ func templateStanzaRepoAbsent (walMax , walMin string , size int64 ) stanza {
2095
2154
var (
2096
2155
errorStatus * bool
2097
2156
deltaMap , sizeMap * int64
@@ -2127,9 +2186,9 @@ func templateStanzaRepoAbsent(walMax, walMin string) stanza {
2127
2186
struct {
2128
2187
Delta int64 "json:\" delta\" "
2129
2188
DeltaMap * int64 "json:\" delta-map\" "
2130
- Size int64 "json:\" size\" "
2189
+ Size * int64 "json:\" size\" "
2131
2190
SizeMap * int64 "json:\" size-map\" "
2132
- }{2969514 , deltaMap , 2969514 , sizeMap },
2191
+ }{2969514 , deltaMap , & size , sizeMap },
2133
2192
24316343 ,
2134
2193
},
2135
2194
"20210607-092423F" ,
0 commit comments