Skip to content

[FEATURE] Add node label to elasticsearch_nodes_roles metric #1105

@pincher95

Description

@pincher95

Title: Add node label to elasticsearch_nodes_roles for better correlation

Background

The elasticsearch_nodes_roles metric currently exposes these labels:

  • cluster
  • host
  • name
  • role

Proposal

Extend elasticsearch_nodes_roles with a node label that contains the Elasticsearch node ID:
ql

Current

elasticsearch_nodes_roles{cluster="prod",host="172.17.0.2",name="es-node-1",role="master"} 1

Proposed

elasticsearch_nodes_roles{cluster="prod",host="172.17.0.2",name="es-node-1",node="49nZYKtiQdGg7Nl_sVsI1A",role="master"} 1Implementation notes:

  • The node ID is already available as the key in the nodes map returned by /_nodes/_all/stats, so no extra API calls are needed.

  • In code this is essentially changing:

    for nodeID, node := range nodeStatsResp.Nodes {
    // ...
    labels := []string{
    nodeStatsResp.ClusterName,
    node.Host,
    node.Name,
    nodeID, // new label
    role,
    }
    }

    Why this helps

  • Makes it possible to reliably join elasticsearch_nodes_roles with node-ID–keyed metrics (e.g. shard-level indices metrics once they expose node too).

  • Enables queries such as “shards per role” or “docs per role” by joining on node (e.g. shard-level indices metrics once they expose node too).

  • No behavioral or performance impact beyond adding one label; all data comes from existing responses.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions