This repository was archived by the owner on Nov 28, 2022. It is now read-only.
File tree 1 file changed +8
-14
lines changed
1 file changed +8
-14
lines changed Original file line number Diff line number Diff line change @@ -7,36 +7,30 @@ import (
7
7
"github.com/prometheus/client_golang/prometheus"
8
8
)
9
9
10
- type Relation struct {
10
+ type relation struct {
11
11
Name string `db:"relname"`
12
12
}
13
13
14
- var relationsQuery = `
15
- SELECT relname
16
- FROM pg_stat_user_tables
17
- ORDER BY n_tup_ins + n_tup_upd desc
18
- LIMIT 20
19
- `
20
-
14
+ // DeadTuples returns the percentage of dead tuples on the top 20 biggest tables
21
15
func (g * Gauges ) DeadTuples () * prometheus.GaugeVec {
22
16
var gauge = prometheus .NewGaugeVec (prometheus.GaugeOpts {
23
17
Name : "postgresql_dead_tuples_pct" ,
24
- Help : "dead tuples percentage on the top 20 biggest tables" ,
18
+ Help : "percentage of dead tuples on the top 20 biggest tables" ,
25
19
ConstLabels : g .labels ,
26
20
}, []string {"table" })
27
21
28
- if ! g .isSuperuser {
29
- log .Warn ("postgresql_dead_tuples_pct disabled because pgstattuple requires a superuser" )
30
- return gauge
31
- }
32
22
if ! g .hasExtension ("pgstattuple" ) {
33
23
log .Warn ("postgresql_dead_tuples_pct disabled because pgstattuple extension is not installed" )
34
24
return gauge
35
25
}
36
26
27
+ const relationsQuery = `
28
+ SELECT relname FROM pg_stat_user_tables ORDER BY n_tup_ins + n_tup_upd desc LIMIT 20
29
+ `
30
+
37
31
go func () {
38
32
for {
39
- var tables []Relation
33
+ var tables []relation
40
34
g .query (relationsQuery , & tables , emptyParams )
41
35
for _ , table := range tables {
42
36
var pct []float64
You can’t perform that action at this time.
0 commit comments