Skip to content

Commit

Permalink
number_of_replicas (#483)
Browse files Browse the repository at this point in the history
* number_of_replicas

Signed-off-by: Alexandr Marchenko <[email protected]>

* simplify metric name by removing redundant number_of_ prefix

Co-authored-by: Ben Kochie <[email protected]>
Signed-off-by: Alexandr Marchenko <[email protected]>

* Update README.md

Thanks indeed

Co-authored-by: Joe Adams <[email protected]>
Signed-off-by: Alexandr Marchenko <[email protected]>

Signed-off-by: Alexandr Marchenko <[email protected]>
Co-authored-by: Ben Kochie <[email protected]>
Co-authored-by: Joe Adams <[email protected]>
  • Loading branch information
3 people authored Nov 1, 2022
1 parent 70152fe commit 416fa22
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ Further Information
| elasticsearch_indices_segments_memory_bytes | gauge | 1 | Current memory size of segments in bytes
| elasticsearch_indices_settings_stats_read_only_indices | gauge | 1 | Count of indices that have read_only_allow_delete=true
| elasticsearch_indices_settings_total_fields | gauge | | Index setting value for index.mapping.total_fields.limit (total allowable mapped fields in a index)
| elasticsearch_indices_settings_replicas | gauge | | Index setting value for index.replicas
| elasticsearch_indices_shards_docs | gauge | 3 | Count of documents on this shard
| elasticsearch_indices_shards_docs_deleted | gauge | 3 | Count of deleted documents on each shard
| elasticsearch_indices_store_size_bytes | gauge | 1 | Current size of stored index data in bytes
Expand Down
15 changes: 15 additions & 0 deletions collector/indices_settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,21 @@ func NewIndicesSettings(logger log.Logger, client *http.Client, url *url.URL) *I
return val
},
},
{
Type: prometheus.GaugeValue,
Desc: prometheus.NewDesc(
prometheus.BuildFQName(namespace, "indices_settings", "replicas"),
"index setting number_of_replicas",
defaultIndicesTotalFieldsLabels, nil,
),
Value: func(indexSettings Settings) float64 {
val, err := strconv.ParseFloat(indexSettings.IndexInfo.NumberOfReplicas, 64)
if err != nil {
return float64(defaultTotalFieldsValue)
}
return val
},
},
},
}
}
Expand Down
5 changes: 3 additions & 2 deletions collector/indices_settings_response.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@ type Settings struct {

// IndexInfo defines the blocks of the current index
type IndexInfo struct {
Blocks Blocks `json:"blocks"`
Mapping Mapping `json:"mapping"`
Blocks Blocks `json:"blocks"`
Mapping Mapping `json:"mapping"`
NumberOfReplicas string `json:"number_of_replicas"`
}

// Blocks defines whether current index has read_only_allow_delete enabled
Expand Down

0 comments on commit 416fa22

Please sign in to comment.