Fix shard indices reporting in elasticsearch input (#7332)
This commit is contained in:
parent
f89381851e
commit
d915f7c7d6
|
@ -545,11 +545,12 @@ func (e *Elasticsearch) gatherIndicesStats(url string, acc telegraf.Accumulator)
|
|||
}
|
||||
|
||||
if e.IndicesLevel == "shards" {
|
||||
for shardNumber, shard := range index.Shards {
|
||||
if len(shard) > 0 {
|
||||
for shardNumber, shards := range index.Shards {
|
||||
for _, shard := range shards {
|
||||
|
||||
// Get Shard Stats
|
||||
flattened := jsonparser.JSONFlattener{}
|
||||
err := flattened.FullFlattenJSON("", shard[0], true, true)
|
||||
err := flattened.FullFlattenJSON("", shard, true, true)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -327,17 +327,26 @@ func TestGatherClusterIndiceShardsStats(t *testing.T) {
|
|||
clusterIndicesExpected,
|
||||
map[string]string{"index_name": "twitter"})
|
||||
|
||||
tags := map[string]string{
|
||||
primaryTags := map[string]string{
|
||||
"index_name": "twitter",
|
||||
"node_id": "oqvR8I1dTpONvwRM30etww",
|
||||
"shard_name": "0",
|
||||
"type": "primary",
|
||||
}
|
||||
|
||||
acc.AssertContainsTaggedFields(t, "elasticsearch_indices_stats_shards",
|
||||
clusterIndicesPrimaryShardsExpected,
|
||||
primaryTags)
|
||||
|
||||
replicaTags := map[string]string{
|
||||
"index_name": "twitter",
|
||||
"node_id": "oqvR8I1dTpONvwRM30etww",
|
||||
"shard_name": "1",
|
||||
"type": "replica",
|
||||
}
|
||||
|
||||
acc.AssertContainsTaggedFields(t, "elasticsearch_indices_stats_shards",
|
||||
clusterIndicesShardsExpected,
|
||||
tags)
|
||||
|
||||
clusterIndicesReplicaShardsExpected,
|
||||
replicaTags)
|
||||
}
|
||||
|
||||
func newElasticsearchWithClient() *Elasticsearch {
|
||||
|
|
|
@ -3650,7 +3650,105 @@ const clusterIndicesShardsResponse = `
|
|||
}
|
||||
}`
|
||||
|
||||
var clusterIndicesShardsExpected = map[string]interface{}{
|
||||
var clusterIndicesPrimaryShardsExpected = map[string]interface{}{
|
||||
"commit_generation": float64(4),
|
||||
"commit_num_docs": float64(340),
|
||||
"completion_size_in_bytes": float64(0),
|
||||
"docs_count": float64(340),
|
||||
"docs_deleted": float64(0),
|
||||
"fielddata_evictions": float64(0),
|
||||
"fielddata_memory_size_in_bytes": float64(0),
|
||||
"flush_periodic": float64(0),
|
||||
"flush_total": float64(1),
|
||||
"flush_total_time_in_millis": float64(32),
|
||||
"get_current": float64(0),
|
||||
"get_exists_time_in_millis": float64(0),
|
||||
"get_exists_total": float64(0),
|
||||
"get_missing_time_in_millis": float64(0),
|
||||
"get_missing_total": float64(0),
|
||||
"get_time_in_millis": float64(0),
|
||||
"get_total": float64(0),
|
||||
"indexing_delete_current": float64(0),
|
||||
"indexing_delete_time_in_millis": float64(0),
|
||||
"indexing_delete_total": float64(0),
|
||||
"indexing_index_current": float64(0),
|
||||
"indexing_index_failed": float64(0),
|
||||
"indexing_index_time_in_millis": float64(176),
|
||||
"indexing_index_total": float64(340),
|
||||
"indexing_noop_update_total": float64(0),
|
||||
"indexing_throttle_time_in_millis": float64(0),
|
||||
"merges_current": float64(0),
|
||||
"merges_current_docs": float64(0),
|
||||
"merges_current_size_in_bytes": float64(0),
|
||||
"merges_total": float64(0),
|
||||
"merges_total_auto_throttle_in_bytes": float64(2.097152e+07),
|
||||
"merges_total_docs": float64(0),
|
||||
"merges_total_size_in_bytes": float64(0),
|
||||
"merges_total_stopped_time_in_millis": float64(0),
|
||||
"merges_total_throttled_time_in_millis": float64(0),
|
||||
"merges_total_time_in_millis": float64(0),
|
||||
"query_cache_cache_count": float64(0),
|
||||
"query_cache_cache_size": float64(0),
|
||||
"query_cache_evictions": float64(0),
|
||||
"query_cache_hit_count": float64(0),
|
||||
"query_cache_memory_size_in_bytes": float64(0),
|
||||
"query_cache_miss_count": float64(0),
|
||||
"query_cache_total_count": float64(0),
|
||||
"recovery_current_as_source": float64(0),
|
||||
"recovery_current_as_target": float64(0),
|
||||
"recovery_throttle_time_in_millis": float64(0),
|
||||
"refresh_external_total": float64(4),
|
||||
"refresh_external_total_time_in_millis": float64(105),
|
||||
"refresh_listeners": float64(0),
|
||||
"refresh_total": float64(6),
|
||||
"refresh_total_time_in_millis": float64(103),
|
||||
"request_cache_evictions": float64(0),
|
||||
"request_cache_hit_count": float64(0),
|
||||
"request_cache_memory_size_in_bytes": float64(0),
|
||||
"request_cache_miss_count": float64(0),
|
||||
"retention_leases_primary_term": float64(1),
|
||||
"retention_leases_version": float64(0),
|
||||
"routing_state": int(3),
|
||||
"search_fetch_current": float64(0),
|
||||
"search_fetch_time_in_millis": float64(0),
|
||||
"search_fetch_total": float64(0),
|
||||
"search_open_contexts": float64(0),
|
||||
"search_query_current": float64(0),
|
||||
"search_query_time_in_millis": float64(0),
|
||||
"search_query_total": float64(0),
|
||||
"search_scroll_current": float64(0),
|
||||
"search_scroll_time_in_millis": float64(0),
|
||||
"search_scroll_total": float64(0),
|
||||
"search_suggest_current": float64(0),
|
||||
"search_suggest_time_in_millis": float64(0),
|
||||
"search_suggest_total": float64(0),
|
||||
"segments_count": float64(1),
|
||||
"segments_doc_values_memory_in_bytes": float64(68),
|
||||
"segments_fixed_bit_set_memory_in_bytes": float64(0),
|
||||
"segments_index_writer_memory_in_bytes": float64(0),
|
||||
"segments_max_unsafe_auto_id_timestamp": float64(-1),
|
||||
"segments_memory_in_bytes": float64(4301),
|
||||
"segments_norms_memory_in_bytes": float64(384),
|
||||
"segments_points_memory_in_bytes": float64(3),
|
||||
"segments_stored_fields_memory_in_bytes": float64(312),
|
||||
"segments_term_vectors_memory_in_bytes": float64(0),
|
||||
"segments_terms_memory_in_bytes": float64(3534),
|
||||
"segments_version_map_memory_in_bytes": float64(0),
|
||||
"seq_no_global_checkpoint": float64(339),
|
||||
"seq_no_local_checkpoint": float64(339),
|
||||
"seq_no_max_seq_no": float64(339),
|
||||
"store_size_in_bytes": float64(90564),
|
||||
"translog_earliest_last_modified_age": float64(936870),
|
||||
"translog_operations": float64(340),
|
||||
"translog_size_in_bytes": float64(77158),
|
||||
"translog_uncommitted_operations": float64(0),
|
||||
"translog_uncommitted_size_in_bytes": float64(55),
|
||||
"warmer_current": float64(0),
|
||||
"warmer_total": float64(3),
|
||||
"warmer_total_time_in_millis": float64(0),
|
||||
}
|
||||
|
||||
var clusterIndicesReplicaShardsExpected = map[string]interface{}{
|
||||
"commit_generation": float64(5),
|
||||
"commit_num_docs": float64(352),
|
||||
"completion_size_in_bytes": float64(0),
|
||||
|
|
Loading…
Reference in New Issue