feat: add optional node label to elasticsearch_indices_aliases metric - #1157
Open
pincher95 wants to merge 2 commits into
Open
feat: add optional node label to elasticsearch_indices_aliases metric#1157pincher95 wants to merge 2 commits into
pincher95 wants to merge 2 commits into
Conversation
Add an opt-in --es.aliases.node-labels flag that appends a node label
to the elasticsearch_indices_aliases metric, showing which nodes host
shards for each aliased index.
When disabled (default): metric keeps the original 3 labels
{index, alias, cluster} — fully backward compatible.
When enabled: emits one series per (index, alias, node) with 4 labels.
When --es.shards is disabled, an extra lightweight call to
/_all/_stats?level=shards&metric=docs fetches shard-to-node placement.
Signed-off-by: pincher95 <yuri.tsuprun@logz.io>
sysadmind
reviewed
May 13, 2026
| } | ||
|
|
||
| func (i *Indices) populateShardRouting(ctx context.Context, isr *indexStatsResponse) error { | ||
| u := i.url.ResolveReference(&url.URL{Path: "/_all/_stats"}) |
Contributor
There was a problem hiding this comment.
This won't work for clusters that have a path prefix because the reference has a leading slash.
Contributor
|
Isn't this already possible by joining labels in Prometheus? There is already an |
Signed-off-by: Yuri Tsuprun <51751791+pincher95@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds an opt-in
--es.aliases.node-labelsflag that appends anodelabel to theelasticsearch_indices_aliasesmetric, showing which nodes host shards for eachaliased index.
{index, alias, cluster}— fully backward compatible(index, alias, node)with 4 labels{index, alias, node, cluster}Resolves #1156
Changes
collector/indices.goindicesAliasesWithNodedescriptor with 4 labels alongside the original 3-labelindicesAliasesaliasNodeLabelsandaliasesDescfields toIndicesstruct; constructor selects descriptor based on flagpopulateShardRouting()to fetch shard placement when--es.shardsis offcollectAliasNodes()helper to extract sorted unique node IDs from shard dataCollect()branches onaliasNodeLabels: legacy path emits 3 labels, node-aware path emits per-node seriescollector/indices_test.goTestIndicesAliasNodeLabelsvalidating node labels are populated from shard routing fixturesmain.go--es.aliases.node-labelsflag (defaultfalse)NewIndices()in both single-target and/probepathsREADME.md