Skip to content
This repository was archived by the owner on Nov 28, 2022. It is now read-only.

Commit 8943501

Browse files
committed
Remove check for superuser
1 parent 306c5be commit 8943501

File tree

1 file changed

+8
-14
lines changed

1 file changed

+8
-14
lines changed

gauges/deadtuples.go

+8-14
Original file line numberDiff line numberDiff line change
@@ -7,36 +7,30 @@ import (
77
"github.com/prometheus/client_golang/prometheus"
88
)
99

10-
type Relation struct {
10+
type relation struct {
1111
Name string `db:"relname"`
1212
}
1313

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
2115
func (g *Gauges) DeadTuples() *prometheus.GaugeVec {
2216
var gauge = prometheus.NewGaugeVec(prometheus.GaugeOpts{
2317
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",
2519
ConstLabels: g.labels,
2620
}, []string{"table"})
2721

28-
if !g.isSuperuser {
29-
log.Warn("postgresql_dead_tuples_pct disabled because pgstattuple requires a superuser")
30-
return gauge
31-
}
3222
if !g.hasExtension("pgstattuple") {
3323
log.Warn("postgresql_dead_tuples_pct disabled because pgstattuple extension is not installed")
3424
return gauge
3525
}
3626

27+
const relationsQuery = `
28+
SELECT relname FROM pg_stat_user_tables ORDER BY n_tup_ins + n_tup_upd desc LIMIT 20
29+
`
30+
3731
go func() {
3832
for {
39-
var tables []Relation
33+
var tables []relation
4034
g.query(relationsQuery, &tables, emptyParams)
4135
for _, table := range tables {
4236
var pct []float64

0 commit comments

Comments
 (0)