@@ -23,6 +23,13 @@ import (
2323 "github.com/prometheus/client_golang/prometheus"
2424)
2525
26+ var (
27+ settingUnits = []string {
28+ "ms" , "s" , "min" , "h" , "d" ,
29+ "B" , "kB" , "MB" , "GB" , "TB" ,
30+ }
31+ )
32+
2633// Query the pg_settings view containing runtime variables
2734func querySettings (ch chan <- prometheus.Metric , server * Server ) error {
2835 level .Debug (logger ).Log ("msg" , "Querying pg_setting view" , "server" , server )
@@ -93,9 +100,24 @@ func (s *pgSetting) metric(labels prometheus.Labels) prometheus.Metric {
93100 return prometheus .MustNewConstMetric (desc , prometheus .GaugeValue , val )
94101}
95102
103+ // Removes units from any of the setting values.
104+ // This is mostly because of a irregularity regarding AWS RDS Aurora
105+ // https://github.com/prometheus-community/postgres_exporter/issues/619
106+ func (s * pgSetting ) sanitizeValue () {
107+ for _ , unit := range settingUnits {
108+ if strings .HasSuffix (s .setting , unit ) {
109+ endPos := len (s .setting ) - len (unit ) - 1
110+ s .setting = s .setting [:endPos ]
111+ return
112+ }
113+ }
114+ }
115+
96116// TODO: fix linter override
97117// nolint: nakedret
98118func (s * pgSetting ) normaliseUnit () (val float64 , unit string , err error ) {
119+ s .sanitizeValue ()
120+
99121 val , err = strconv .ParseFloat (s .setting , 64 )
100122 if err != nil {
101123 return val , unit , fmt .Errorf ("Error converting setting %q value %q to float: %s" , s .name , s .setting , err )
0 commit comments