Skip to content

Commit

Permalink
feat: additional elasticcloud roles
Browse files Browse the repository at this point in the history
Signed-off-by: Christophe MORIO <cmorio@talend.com>
  • Loading branch information
christophemorio committed Nov 17, 2022
1 parent 416fa22 commit c8a1083
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions collector/nodes.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,14 @@ import (
func getRoles(node NodeStatsNodeResponse) map[string]bool {
// default settings (2.x) and map, which roles to consider
roles := map[string]bool{
"master": false,
"data": false,
"ingest": false,
"client": true,
"master": false,
"data": false,
"data_hot": false,
"data_warm": false,
"data_cold": false,
"data_frozen": false,
"ingest": false,
"client": 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 {
Expand Down Expand Up @@ -84,7 +88,9 @@ func createRoleMetric(role string) *nodeMetric {
}

var (
defaultNodeLabels = []string{"cluster", "host", "name", "es_master_node", "es_data_node", "es_ingest_node", "es_client_node"}
defaultNodeLabels = []string{"cluster", "host", "name", "es_master_node", "es_data_node",
"es_data_hot_node", "es_data_warm_node", "es_data_cold_node", "es_data_frozen_node",
"es_ingest_node", "es_client_node"}
defaultRoleLabels = []string{"cluster", "host", "name"}
defaultThreadPoolLabels = append(defaultNodeLabels, "type")
defaultBreakerLabels = append(defaultNodeLabels, "breaker")
Expand All @@ -100,6 +106,10 @@ var (
node.Name,
fmt.Sprintf("%t", roles["master"]),
fmt.Sprintf("%t", roles["data"]),
fmt.Sprintf("%t", roles["data_hot"]),
fmt.Sprintf("%t", roles["data_warm"]),
fmt.Sprintf("%t", roles["data_cold"]),
fmt.Sprintf("%t", roles["data_frozen"]),
fmt.Sprintf("%t", roles["ingest"]),
fmt.Sprintf("%t", roles["client"]),
}
Expand Down Expand Up @@ -1866,7 +1876,8 @@ func (c *Nodes) Collect(ch chan<- prometheus.Metric) {
// Handle the node labels metric
roles := getRoles(node)

for _, role := range []string{"master", "data", "client", "ingest"} {
for _, role := range []string{"master", "data", "data_hot", "data_cold",
"data_warm", "data_frozen", "client", "ingest"} {
if roles[role] {
metric := createRoleMetric(role)
ch <- prometheus.MustNewConstMetric(
Expand Down

0 comments on commit c8a1083

Please sign in to comment.