Skip to content
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

[Metricbeat] Remove elasticsearch.index.created from the SM code #25113

Merged
merged 4 commits into from
Apr 20, 2021
Merged
Show file tree
Hide file tree
Changes from 3 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 CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ https://github.com/elastic/beats/compare/v7.0.0-alpha2...master[Check the HEAD d
- Add support for Consul 1.9. {pull}24123[24123]
- Add support for the MemoryPressure, DiskPressure, OutOfDisk and PIDPressure status conditions in state_node. {pull}23905[23905]
- Store `cloudfoundry.container.cpu.pct` in decimal form and as `scaled_float`. {pull}24219[24219]
- Remove `index_stats.created` field from Elasticsearch/index Metricset {pull}25113[25113]

*Packetbeat*

Expand Down
29 changes: 1 addition & 28 deletions metricbeat/module/elasticsearch/index/data_xpack.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ package index
import (
"encoding/json"
"fmt"
"strconv"
"time"

"github.com/joeshaw/multierror"
Expand All @@ -47,7 +46,6 @@ type Index struct {
Total indexStats `json:"total"`

Index string `json:"index"`
Created int64 `json:"created"`
Status string `json:"status"`
Hidden bool `json:"hidden"`
Shards shardStats `json:"shards"`
Expand Down Expand Up @@ -131,7 +129,7 @@ type bulkStats struct {
}

func eventsMappingXPack(r mb.ReporterV2, m *MetricSet, info elasticsearch.Info, content []byte) error {
clusterStateMetrics := []string{"metadata", "routing_table"}
clusterStateMetrics := []string{"routing_table"}
clusterState, err := elasticsearch.GetClusterState(m.HTTP, m.HTTP.GetURI(), clusterStateMetrics)
if err != nil {
return errors.Wrap(err, "failure retrieving cluster state from Elasticsearch")
Expand Down Expand Up @@ -185,11 +183,6 @@ func parseAPIResponse(content []byte, indicesStats *stats) error {
// Fields added here are based on same fields being added by internal collection in
// https://github.com/elastic/elasticsearch/blob/master/x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/collector/indices/IndexStatsMonitoringDoc.java#L62-L124
func addClusterStateFields(idx *Index, clusterState common.MapStr) error {
indexMetadata, err := getClusterStateMetricForIndex(clusterState, idx.Index, "metadata")
if err != nil {
return errors.Wrap(err, "failed to get index metadata from cluster state")
}

indexRoutingTable, err := getClusterStateMetricForIndex(clusterState, idx.Index, "routing_table")
if err != nil {
return errors.Wrap(err, "failed to get index routing table from cluster state")
Expand All @@ -200,12 +193,6 @@ func addClusterStateFields(idx *Index, clusterState common.MapStr) error {
return errors.Wrap(err, "failed to get shards from routing table")
}

created, err := getIndexCreated(indexMetadata)
if err != nil {
return errors.Wrap(err, "failed to get index creation time")
}
idx.Created = created
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can remove the Created field from the struct as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point


// "index_stats.version.created", <--- don't think this is being used in the UI, so can we skip it?
// "index_stats.version.upgraded", <--- don't think this is being used in the UI, so can we skip it?

Expand Down Expand Up @@ -354,20 +341,6 @@ func getIndexShardStats(shards common.MapStr) (*shardStats, error) {
}, nil
}

func getIndexCreated(indexMetadata common.MapStr) (int64, error) {
v, err := indexMetadata.GetValue("settings.index.creation_date")
if err != nil {
return 0, err
}

c, ok := v.(string)
if !ok {
return 0, elastic.MakeErrorForMissingField("settings.index.creation_date", elastic.Elasticsearch)
}

return strconv.ParseInt(c, 10, 64)
}

func getShardsFromRoutingTable(indexRoutingTable common.MapStr) (map[string]interface{}, error) {
s, err := indexRoutingTable.GetValue("shards")
if err != nil {
Expand Down