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

Commit 343b1fc

Browse files
committed
Improve indexes metrics help
1 parent 178cbd4 commit 343b1fc

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

gauges/indexes.go

+10-5
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"github.com/prometheus/client_golang/prometheus"
77
)
88

9+
// UnusedIndexes returns the count of unused indexes in the database
910
func (g *Gauges) UnusedIndexes() prometheus.Gauge {
1011
return g.new(
1112
prometheus.GaugeOpts{
@@ -23,31 +24,33 @@ func (g *Gauges) UnusedIndexes() prometheus.Gauge {
2324
)
2425
}
2526

27+
// IndexBlocksRead returns the sum of the number of disk blocks read from all public indexes
2628
func (g *Gauges) IndexBlocksRead() prometheus.Gauge {
2729
return g.new(
2830
prometheus.GaugeOpts{
2931
Name: "postgresql_index_blks_read_sum",
30-
Help: "Sum of the number of disk blocks read from all public indexes",
32+
Help: "Sum of the number of disk blocks read from all user indexes",
3133
ConstLabels: g.labels,
3234
},
3335
`
3436
SELECT coalesce(sum(idx_blks_read), 0)
35-
FROM pg_statio_all_indexes
37+
FROM pg_statio_user_indexes
3638
WHERE schemaname = 'public'
3739
`,
3840
)
3941
}
4042

43+
// IndexBlocksHit returns the sum of the number of buffer hits on all user indexes
4144
func (g *Gauges) IndexBlocksHit() prometheus.Gauge {
4245
return g.new(
4346
prometheus.GaugeOpts{
4447
Name: "postgresql_index_blks_hit_sum",
45-
Help: "Sum of the number of buffer hits on all public indexes",
48+
Help: "Sum of the number of buffer hits on all user indexes",
4649
ConstLabels: g.labels,
4750
},
4851
`
4952
SELECT coalesce(sum(idx_blks_hit), 0)
50-
FROM pg_statio_all_indexes
53+
FROM pg_statio_user_indexes
5154
WHERE schemaname = 'public'
5255
`,
5356
)
@@ -160,11 +163,13 @@ type indexBloat struct {
160163
Pct float64 `db:"bloat_pct"`
161164
}
162165

166+
// IndexBloat returns bloat percentage of an index reporting only for indexes
167+
// with size greater than 10mb and bloat lower than 50%
163168
func (g *Gauges) IndexBloat() *prometheus.GaugeVec {
164169
var gauge = prometheus.NewGaugeVec(
165170
prometheus.GaugeOpts{
166171
Name: "postgresql_index_bloat_pct",
167-
Help: "bloat percentage of an index. reports only for indexes > 10mb and > 50% bloat",
172+
Help: "Bloat percentage of an index. This metric reports only indexes > 10mb and > 50% bloat",
168173
ConstLabels: g.labels,
169174
},
170175
[]string{"index", "table"},

0 commit comments

Comments
 (0)