Skip to content
Merged
Changes from 1 commit
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
26 changes: 0 additions & 26 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 Down Expand Up @@ -185,11 +184,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 +194,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
Copy Markdown
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
Copy Markdown
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 +342,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