From 0ab69c99035b2a948c798369d32fa25a185d8265 Mon Sep 17 00:00:00 2001 From: Zach Burnham Date: Thu, 3 Oct 2019 17:19:15 -0700 Subject: [PATCH] added shard store size as well as "primary" label to shard metrics --- collector/indices.go | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/collector/indices.go b/collector/indices.go index d71b07b1..81bff8ef 100644 --- a/collector/indices.go +++ b/collector/indices.go @@ -6,6 +6,7 @@ import ( "net/http" "net/url" "path" + "strconv" "github.com/go-kit/kit/log" "github.com/go-kit/kit/log/level" @@ -68,7 +69,7 @@ func NewIndices(logger log.Logger, client *http.Client, url *url.URL, shards boo shardLabels := labels{ keys: func(...string) []string { - return []string{"index", "shard", "node", "cluster"} + return []string{"index", "shard", "node", "primary", "cluster"} }, values: func(lastClusterinfo *clusterinfo.Response, s ...string) []string { if lastClusterinfo != nil { @@ -970,6 +971,18 @@ func NewIndices(logger log.Logger, client *http.Client, url *url.URL, shards boo }, Labels: shardLabels, }, + { + Type: prometheus.GaugeValue, + Desc: prometheus.NewDesc( + prometheus.BuildFQName(namespace, "indices", "shards_store_size_in_bytes"), + "Store size of this shard", + shardLabels.keys(), nil, + ), + Value: func(data IndexStatsIndexShardsDetailResponse) float64 { + return float64(data.Store.SizeInBytes) + }, + Labels: shardLabels, + }, }, } @@ -1087,7 +1100,7 @@ func (i *Indices) Collect(ch chan<- prometheus.Metric) { metric.Desc, metric.Type, metric.Value(shard), - metric.Labels.values(i.lastClusterInfo, indexName, shardNumber, shard.Routing.Node)..., + metric.Labels.values(i.lastClusterInfo, indexName, shardNumber, shard.Routing.Node, strconv.FormatBool(shard.Routing.Primary))..., ) } }