Skip to content

Commit 2a320bf

Browse files
committed
number_of_replicas
Signed-off-by: Alexandr Marchenko <[email protected]>
1 parent 3d86731 commit 2a320bf

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ Further Information
162162
| elasticsearch_indices_segments_memory_bytes | gauge | 1 | Current memory size of segments in bytes
163163
| elasticsearch_indices_settings_stats_read_only_indices | gauge | 1 | Count of indices that have read_only_allow_delete=true
164164
| elasticsearch_indices_settings_total_fields | gauge | | Index setting value for index.mapping.total_fields.limit (total allowable mapped fields in a index)
165+
| elasticsearch_indices_settings_number_of_replicas | gauge | | Index setting value for index.number_of_replicas
165166
| elasticsearch_indices_shards_docs | gauge | 3 | Count of documents on this shard
166167
| elasticsearch_indices_shards_docs_deleted | gauge | 3 | Count of deleted documents on each shard
167168
| elasticsearch_indices_store_size_bytes | gauge | 1 | Current size of stored index data in bytes

collector/indices_settings.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,21 @@ func NewIndicesSettings(logger log.Logger, client *http.Client, url *url.URL) *I
9090
return val
9191
},
9292
},
93+
{
94+
Type: prometheus.GaugeValue,
95+
Desc: prometheus.NewDesc(
96+
prometheus.BuildFQName(namespace, "indices_settings", "number_of_replicas"),
97+
"index setting number_of_replicas",
98+
defaultIndicesTotalFieldsLabels, nil,
99+
),
100+
Value: func(indexSettings Settings) float64 {
101+
val, err := strconv.ParseFloat(indexSettings.IndexInfo.NumberOfReplicas, 64)
102+
if err != nil {
103+
return float64(defaultTotalFieldsValue)
104+
}
105+
return val
106+
},
107+
},
93108
},
94109
}
95110
}

collector/indices_settings_response.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,9 @@ type Settings struct {
2828

2929
// IndexInfo defines the blocks of the current index
3030
type IndexInfo struct {
31-
Blocks Blocks `json:"blocks"`
32-
Mapping Mapping `json:"mapping"`
31+
Blocks Blocks `json:"blocks"`
32+
Mapping Mapping `json:"mapping"`
33+
NumberOfReplicas string `json:"number_of_replicas"`
3334
}
3435

3536
// Blocks defines whether current index has read_only_allow_delete enabled

0 commit comments

Comments
 (0)