Skip to content

Commit e8588be

Browse files
Zach Burnhamzwopir
Zach Burnham
authored andcommitted
added shard store size as well as "primary" label to shard metrics
1 parent 9498803 commit e8588be

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

collector/indices.go

+15-2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"net/http"
77
"net/url"
88
"path"
9+
"strconv"
910

1011
"github.com/go-kit/kit/log"
1112
"github.com/go-kit/kit/log/level"
@@ -68,7 +69,7 @@ func NewIndices(logger log.Logger, client *http.Client, url *url.URL, shards boo
6869

6970
shardLabels := labels{
7071
keys: func(...string) []string {
71-
return []string{"index", "shard", "node", "cluster"}
72+
return []string{"index", "shard", "node", "primary", "cluster"}
7273
},
7374
values: func(lastClusterinfo *clusterinfo.Response, s ...string) []string {
7475
if lastClusterinfo != nil {
@@ -970,6 +971,18 @@ func NewIndices(logger log.Logger, client *http.Client, url *url.URL, shards boo
970971
},
971972
Labels: shardLabels,
972973
},
974+
{
975+
Type: prometheus.GaugeValue,
976+
Desc: prometheus.NewDesc(
977+
prometheus.BuildFQName(namespace, "indices", "shards_store_size_in_bytes"),
978+
"Store size of this shard",
979+
shardLabels.keys(), nil,
980+
),
981+
Value: func(data IndexStatsIndexShardsDetailResponse) float64 {
982+
return float64(data.Store.SizeInBytes)
983+
},
984+
Labels: shardLabels,
985+
},
973986
},
974987
}
975988

@@ -1087,7 +1100,7 @@ func (i *Indices) Collect(ch chan<- prometheus.Metric) {
10871100
metric.Desc,
10881101
metric.Type,
10891102
metric.Value(shard),
1090-
metric.Labels.values(i.lastClusterInfo, indexName, shardNumber, shard.Routing.Node)...,
1103+
metric.Labels.values(i.lastClusterInfo, indexName, shardNumber, shard.Routing.Node, strconv.FormatBool(shard.Routing.Primary))...,
10911104
)
10921105
}
10931106
}

0 commit comments

Comments
 (0)