Added 3 important elasticsearch cluster health metrics (#4167)
This commit is contained in:
parent
3cd21c8359
commit
ca6d5a6202
|
@ -40,17 +40,20 @@ type nodeStat struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type clusterHealth struct {
|
type clusterHealth struct {
|
||||||
ClusterName string `json:"cluster_name"`
|
ClusterName string `json:"cluster_name"`
|
||||||
Status string `json:"status"`
|
Status string `json:"status"`
|
||||||
TimedOut bool `json:"timed_out"`
|
TimedOut bool `json:"timed_out"`
|
||||||
NumberOfNodes int `json:"number_of_nodes"`
|
NumberOfNodes int `json:"number_of_nodes"`
|
||||||
NumberOfDataNodes int `json:"number_of_data_nodes"`
|
NumberOfDataNodes int `json:"number_of_data_nodes"`
|
||||||
ActivePrimaryShards int `json:"active_primary_shards"`
|
ActivePrimaryShards int `json:"active_primary_shards"`
|
||||||
ActiveShards int `json:"active_shards"`
|
ActiveShards int `json:"active_shards"`
|
||||||
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"`
|
||||||
Indices map[string]indexHealth `json:"indices"`
|
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"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type indexHealth struct {
|
type indexHealth struct {
|
||||||
|
@ -323,16 +326,19 @@ func (e *Elasticsearch) gatherClusterHealth(url string, acc telegraf.Accumulator
|
||||||
}
|
}
|
||||||
measurementTime := time.Now()
|
measurementTime := time.Now()
|
||||||
clusterFields := map[string]interface{}{
|
clusterFields := map[string]interface{}{
|
||||||
"status": healthStats.Status,
|
"status": healthStats.Status,
|
||||||
"status_code": mapHealthStatusToCode(healthStats.Status),
|
"status_code": mapHealthStatusToCode(healthStats.Status),
|
||||||
"timed_out": healthStats.TimedOut,
|
"timed_out": healthStats.TimedOut,
|
||||||
"number_of_nodes": healthStats.NumberOfNodes,
|
"number_of_nodes": healthStats.NumberOfNodes,
|
||||||
"number_of_data_nodes": healthStats.NumberOfDataNodes,
|
"number_of_data_nodes": healthStats.NumberOfDataNodes,
|
||||||
"active_primary_shards": healthStats.ActivePrimaryShards,
|
"active_primary_shards": healthStats.ActivePrimaryShards,
|
||||||
"active_shards": healthStats.ActiveShards,
|
"active_shards": healthStats.ActiveShards,
|
||||||
"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",
|
||||||
|
|
|
@ -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",
|
||||||
|
@ -53,16 +59,19 @@ const clusterHealthResponseWithIndices = `
|
||||||
`
|
`
|
||||||
|
|
||||||
var clusterHealthExpected = map[string]interface{}{
|
var clusterHealthExpected = map[string]interface{}{
|
||||||
"status": "green",
|
"status": "green",
|
||||||
"status_code": 1,
|
"status_code": 1,
|
||||||
"timed_out": false,
|
"timed_out": false,
|
||||||
"number_of_nodes": 3,
|
"number_of_nodes": 3,
|
||||||
"number_of_data_nodes": 3,
|
"number_of_data_nodes": 3,
|
||||||
"active_primary_shards": 5,
|
"active_primary_shards": 5,
|
||||||
"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,
|
||||||
}
|
}
|
||||||
|
|
||||||
var v1IndexExpected = map[string]interface{}{
|
var v1IndexExpected = map[string]interface{}{
|
||||||
|
|
Loading…
Reference in New Issue