Loading...

List and check alias in elasticsearch

This post gives an example how to check an alias or aliases in elasticsearch with the REST-API.

As example we create an alias

curl -XPOST 'localhost:9200/_aliases' -d '
{
    "actions" : [
        { "add" : { "index" : "metrics*", "alias" : "stats" } }
    ]
}'

This checks for the index metrics which alias are available.

curl -XGET 'localhost:9200/metrics/_alias/*'

elasticsearch allwos you to use asterisks. If you want to check for all indices.

dev@cinhtau:~> curl -XGET 'localhost:9200/*/_alias/*?pretty'
{
    "metrics-2015.10.01": {
        "aliases": {
            "stats": {}
        }
    },
    "metrics-2015.10.12": {
        "aliases": {
            "stats": {}
        }
    },
    "metrics-2015.10.02": {
        "aliases": {
            "stats": {}
        }
    },
    "metrics-2015.10.13": {
        "aliases": {
            "stats": {}
        }
    },
    "metrics-2015.10.09": {
        "aliases": {
            "stats": {}
        }
    },
    "metrics-2015.10.05": {
        "aliases": {
            "stats": {}
        }
    },
    "metrics-2015.10.11": {
        "aliases": {
            "stats": {}
        }
    },
    "metrics-2015.10.15": {
        "aliases": {
            "stats": {}
        }
    },
    "metrics-2015.10.04": {
        "aliases": {
            "stats": {}
        }
    },
    "metrics-2015.10.10": {
        "aliases": {
            "stats": {}
        }
    },
    "metrics-2015.10.14": {
        "aliases": {
            "stats": {}
        }
    },
    "metrics-2015.10.06": {
        "aliases": {
            "stats": {}
        }
    },
    "metrics-2025.10.02": {
        "aliases": {
            "stats": {}
        }
    },
    "metrics-2015.10.08": {
        "aliases": {
            "stats": {}
        }
    },
    "metrics-2015.10.16": {
        "aliases": {
            "stats": {}
        }
    },
    "metrics-2015.10.07": {
        "aliases": {
            "stats": {}
        }
    }
}