Added 3 important elasticsearch cluster health metrics (#4167)

This commit is contained in:
Feliksas The Lion 2018-05-19 04:49:23 +03:00 committed by Daniel Nelson
parent 3cd21c8359
commit ca6d5a6202
2 changed files with 47 additions and 32 deletions

View File

@ -50,6 +50,9 @@ type clusterHealth struct {
RelocatingShards int `json:"relocating_shards"` RelocatingShards int `json:"relocating_shards"`
InitializingShards int `json:"initializing_shards"` InitializingShards int `json:"initializing_shards"`
UnassignedShards int `json:"unassigned_shards"` UnassignedShards int `json:"unassigned_shards"`
NumberOfPendingTasks int `json:"number_of_pending_tasks"`
TaskMaxWaitingInQueueMillis int `json:"task_max_waiting_in_queue_millis"`
ActiveShardsPercentAsNumber float64 `json:"active_shards_percent_as_number"`
Indices map[string]indexHealth `json:"indices"` Indices map[string]indexHealth `json:"indices"`
} }
@ -333,6 +336,9 @@ func (e *Elasticsearch) gatherClusterHealth(url string, acc telegraf.Accumulator
"relocating_shards": healthStats.RelocatingShards, "relocating_shards": healthStats.RelocatingShards,
"initializing_shards": healthStats.InitializingShards, "initializing_shards": healthStats.InitializingShards,
"unassigned_shards": healthStats.UnassignedShards, "unassigned_shards": healthStats.UnassignedShards,
"number_of_pending_tasks": healthStats.NumberOfPendingTasks,
"task_max_waiting_in_queue_millis": healthStats.TaskMaxWaitingInQueueMillis,
"active_shards_percent_as_number": healthStats.ActiveShardsPercentAsNumber,
} }
acc.AddFields( acc.AddFields(
"elasticsearch_cluster_health", "elasticsearch_cluster_health",

View File

@ -11,7 +11,10 @@ const clusterHealthResponse = `
"active_shards": 15, "active_shards": 15,
"relocating_shards": 0, "relocating_shards": 0,
"initializing_shards": 0, "initializing_shards": 0,
"unassigned_shards": 0 "unassigned_shards": 0,
"number_of_pending_tasks": 0,
"task_max_waiting_in_queue_millis": 0,
"active_shards_percent_as_number": 100.0
} }
` `
@ -27,6 +30,9 @@ const clusterHealthResponseWithIndices = `
"relocating_shards": 0, "relocating_shards": 0,
"initializing_shards": 0, "initializing_shards": 0,
"unassigned_shards": 0, "unassigned_shards": 0,
"number_of_pending_tasks": 0,
"task_max_waiting_in_queue_millis": 0,
"active_shards_percent_as_number": 100.0,
"indices": { "indices": {
"v1": { "v1": {
"status": "green", "status": "green",
@ -63,6 +69,9 @@ var clusterHealthExpected = map[string]interface{}{
"relocating_shards": 0, "relocating_shards": 0,
"initializing_shards": 0, "initializing_shards": 0,
"unassigned_shards": 0, "unassigned_shards": 0,
"number_of_pending_tasks": 0,
"task_max_waiting_in_queue_millis": 0,
"active_shards_percent_as_number": 100.0,
} }
var v1IndexExpected = map[string]interface{}{ var v1IndexExpected = map[string]interface{}{