From 314bdddd438a5491e4cac53d49af277ba2b4247f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20Oelm=C3=BCller?= Date: Mon, 30 Oct 2017 12:34:53 +0100 Subject: [PATCH 1/2] fix role labels for ES 2.x --- collector/nodes.go | 11 +++++++++-- collector/nodes_response.go | 1 + 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/collector/nodes.go b/collector/nodes.go index ae8f587b..5c87bdf8 100644 --- a/collector/nodes.go +++ b/collector/nodes.go @@ -12,7 +12,7 @@ import ( ) var ( - defaultNodeLabels = []string{"cluster", "host", "name", "es_master_node", "es_data_node", "es_ingest_node"} + defaultNodeLabels = []string{"cluster", "host", "name", "es_master_node", "es_data_node", "es_ingest_node", "es_client_node"} defaultThreadPoolLabels = append(defaultNodeLabels, "type") defaultBreakerLabels = append(defaultNodeLabels, "breaker") defaultFilesystemLabels = append(defaultNodeLabels, "mount", "path") @@ -24,6 +24,7 @@ var ( "data": true, "ingest": true, } + isClientNode := "true" // assumption: a 5.x node has at least one role, otherwise it's a 1.7 or 2.x node if len(node.Roles) > 0 { for _, role := range node.Roles { @@ -34,10 +35,15 @@ var ( } else { for role, setting := range node.Attributes { if _, ok := roles[role]; ok { - roles[role] = setting == "false" + if setting == "false" { + roles[role] = false + } } } } + if len(node.Http) == 0 { + isClientNode = "false" + } return []string{ cluster, node.Host, @@ -45,6 +51,7 @@ var ( fmt.Sprintf("%t", roles["master"]), fmt.Sprintf("%t", roles["data"]), fmt.Sprintf("%t", roles["ingest"]), + isClientNode, } } defaultThreadPoolLabelValues = func(cluster string, node NodeStatsNodeResponse, pool string) []string { diff --git a/collector/nodes_response.go b/collector/nodes_response.go index 37a99d29..1c0d56b4 100644 --- a/collector/nodes_response.go +++ b/collector/nodes_response.go @@ -23,6 +23,7 @@ type NodeStatsNodeResponse struct { ThreadPool map[string]NodeStatsThreadPoolPoolResponse `json:"thread_pool"` JVM NodeStatsJVMResponse `json:"jvm"` Breakers map[string]NodeStatsBreakersResponse `json:"breakers"` + Http map[string]int `json:"http"` Transport NodeStatsTransportResponse `json:"transport"` Process NodeStatsProcessResponse `json:"process"` } From 15f3973bf43734ac068b64433290911540c2ac35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20Oelm=C3=BCller?= Date: Mon, 30 Oct 2017 13:46:55 +0100 Subject: [PATCH 2/2] set ingest_node to false for 2.x clusters --- collector/nodes.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/collector/nodes.go b/collector/nodes.go index 5c87bdf8..dcff3671 100644 --- a/collector/nodes.go +++ b/collector/nodes.go @@ -19,17 +19,22 @@ var ( defaultCacheLabels = append(defaultNodeLabels, "cache") defaultNodeLabelValues = func(cluster string, node NodeStatsNodeResponse) []string { + // default settings (2.x) and map, which roles to consider roles := map[string]bool{ "master": true, "data": true, - "ingest": true, + "ingest": false, } isClientNode := "true" // assumption: a 5.x node has at least one role, otherwise it's a 1.7 or 2.x node if len(node.Roles) > 0 { for _, role := range node.Roles { + // set every absent role to false if _, ok := roles[role]; !ok { roles[role] = false + } else { + // if present in the roles field, set to true + roles[role] = true } } } else { @@ -37,6 +42,8 @@ var ( if _, ok := roles[role]; ok { if setting == "false" { roles[role] = false + } else { + roles[role] = true } } }