Skip to content

Add creation_date metrics #816

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Dec 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ Further Information
| elasticsearch_indices_search_query_total | counter | 1 | Total number of queries |
| elasticsearch_indices_segments_count | gauge | 1 | Count of index segments on this node |
| elasticsearch_indices_segments_memory_bytes | gauge | 1 | Current memory size of segments in bytes |
| elasticsearch_indices_settings_creation_timestamp_seconds | gauge | 1 | Timestamp of the index creation in seconds |
| 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 |
Expand Down
16 changes: 16 additions & 0 deletions collector/indices_settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ type IndicesSettings struct {
var (
defaultIndicesTotalFieldsLabels = []string{"index"}
defaultTotalFieldsValue = 1000 //es default configuration for total fields
defaultDateCreation = 0 //es index default creation date
)

type indicesSettingsMetric struct {
Expand Down Expand Up @@ -105,6 +106,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", "creation_timestamp_seconds"),
"index setting creation_date",
defaultIndicesTotalFieldsLabels, nil,
),
Value: func(indexSettings Settings) float64 {
val, err := strconv.ParseFloat(indexSettings.IndexInfo.CreationDate, 64)
if err != nil {
return float64(defaultDateCreation)
}
return val / 1000.0
},
},
},
}
}
Expand Down
1 change: 1 addition & 0 deletions collector/indices_settings_response.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ type IndexInfo struct {
Blocks Blocks `json:"blocks"`
Mapping Mapping `json:"mapping"`
NumberOfReplicas string `json:"number_of_replicas"`
CreationDate string `json:"creation_date"`
}

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