Skip to content

Commit 4aa955d

Browse files
committed
feat(indices_settings): add creation_date metrics
Signed-off-by: Arthur Le Roux <[email protected]>
1 parent 5a51b7f commit 4aa955d

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ Further Information
187187
| elasticsearch_indices_search_query_total | counter | 1 | Total number of queries |
188188
| elasticsearch_indices_segments_count | gauge | 1 | Count of index segments on this node |
189189
| elasticsearch_indices_segments_memory_bytes | gauge | 1 | Current memory size of segments in bytes |
190+
| elasticsearch_indices_settings_creation_date | gauge | 1 | Index setting value for index.creation_date |
190191
| elasticsearch_indices_settings_stats_read_only_indices | gauge | 1 | Count of indices that have read_only_allow_delete=true |
191192
| elasticsearch_indices_settings_total_fields | gauge | | Index setting value for index.mapping.total_fields.limit (total allowable mapped fields in a index) |
192193
| elasticsearch_indices_settings_replicas | gauge | | Index setting value for index.replicas |

collector/indices_settings.go

+16
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ type IndicesSettings struct {
4343
var (
4444
defaultIndicesTotalFieldsLabels = []string{"index"}
4545
defaultTotalFieldsValue = 1000 //es default configuration for total fields
46+
defaultDateCreation = 0 //es index default creation date
4647
)
4748

4849
type indicesSettingsMetric struct {
@@ -105,6 +106,21 @@ func NewIndicesSettings(logger log.Logger, client *http.Client, url *url.URL) *I
105106
return val
106107
},
107108
},
109+
{
110+
Type: prometheus.GaugeValue,
111+
Desc: prometheus.NewDesc(
112+
prometheus.BuildFQName(namespace, "indices_settings", "creation_date"),
113+
"index setting creation_date",
114+
defaultIndicesTotalFieldsLabels, nil,
115+
),
116+
Value: func(indexSettings Settings) float64 {
117+
val, err := strconv.ParseFloat(indexSettings.IndexInfo.CreationDate, 64)
118+
if err != nil {
119+
return float64(defaultDateCreation)
120+
}
121+
return val
122+
},
123+
},
108124
},
109125
}
110126
}

collector/indices_settings_response.go

+1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ type IndexInfo struct {
3131
Blocks Blocks `json:"blocks"`
3232
Mapping Mapping `json:"mapping"`
3333
NumberOfReplicas string `json:"number_of_replicas"`
34+
CreationDate string `json:"creation_date"`
3435
}
3536

3637
// Blocks defines whether current index has read_only_allow_delete enabled

0 commit comments

Comments
 (0)