feat: add elasticsearch_node_shards_state metric #1098
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.
Hi there, my first contribution on this project! Let me know your thoughts.
Context
Inspired by cerebro, I want to create a dashboard in Grafana to visualize shard distribution, state and movements over time. This helps during scale up periods and diagnose imbalances. I tried to use
count(elasticsearch_indices_shards_docs) by (index, node)metric, but that didn't give me proper node name (e.g. 4n6k9UN4SZG-n3MjOAnszA) and a distinction of primary, replica and shard states.Changes
elasticsearch_node_shards_totalon metrics.md (missing)elasticsearch_node_shards_statemetric with the following encoding (chosen arbitrarily):This allows me to create a Matrix with nodes as rows, indices as columns, and color the cells based on the value. The metric is flexible, has more labels but still low in cardinality due to limited possible values.