66 "github.com/prometheus/client_golang/prometheus"
77)
88
9+ // UnusedIndexes returns the count of unused indexes in the database
910func (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
2628func (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
4144func (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%
163168func (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