Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there any possible that provide a new metrics which calculate index store size total by aliase? #412

Open
max-tian opened this issue Apr 28, 2021 · 3 comments

Comments

@max-tian
Copy link

Sometimes, there are many indices which grouped by versioning (naming convention). When I use metrics elasticsearch_indices_store_size_bytes_total for monitoring index store size, I only want to know the current using index(not old versions). In that case, the current using index has an alias. The old index doesn't have. If there is such label in this metrics. I could use it as following:
elasticsearch_indices_store_size_bytes_total{alias="my-alias"}
Since the index name will be changed automatically, I don't need to change the index name in this metrics. Thus, I don't need to change the query expression again and again.

@shani-e
Copy link

shani-e commented Aug 1, 2023

It's will be very helpful!!

@jorgelbg
Copy link
Contributor

jorgelbg commented Mar 4, 2024

This is not exactly per alias, but it could help to get the desired data (for anyone hitting this in the future). We can use the label_replace function to extract the interesting part from the index name and group by that.

For instance, with daily indices, we always have something like: my-index-2024.02.02. In this case, we want to aggregate the common part of all those indices (my-index).

sum by (pattern) (
    label_replace(
        sum by (index) (
            elasticsearch_indices_store_size_bytes_total
        ),
        "pattern",
        "$1",
        "index",
		"(.*)_[0-9]{4}\\.[0-9]{2}\\.[0-9]{2}$"
    )
)

You may need to tweak the regex to extract the pattern from the index label.

@sysadmind
Copy link
Contributor

You should be able to enable alias metrics --es.aliases and then use something like group_left() to get the label on the index query

https://prometheus.io/docs/prometheus/latest/querying/operators/#group-modifiers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants