List all indexes on ElasticSearch server?
I would like to list all indexes present on an ElasticSearch server. I tried this:
curl -XGET localhost:9200/
but it just gives me this:
{
"ok" : true,
"status" : 200,
"name" : "El Aguila",
"version" : {
"number" : "0.19.3",
"snapshot_build" : false
},
"tagline" : "You Know, for Search"
}
I want a list of all indexes..
curl elasticsearch
add a comment |
I would like to list all indexes present on an ElasticSearch server. I tried this:
curl -XGET localhost:9200/
but it just gives me this:
{
"ok" : true,
"status" : 200,
"name" : "El Aguila",
"version" : {
"number" : "0.19.3",
"snapshot_build" : false
},
"tagline" : "You Know, for Search"
}
I want a list of all indexes..
curl elasticsearch
According to me Abhijit Mazumder's answer below should be accepted one.
– Animesh Pandey
Aug 6 '15 at 7:18
4
@AnimeshPandey then upvote that answer..
– Eva
Aug 6 '15 at 8:07
I already did that.
– Animesh Pandey
Aug 6 '15 at 8:36
6
great! in the future, you can simply upvote what answers you think should be accepted rather than comment about it ;)
– Eva
Aug 13 '15 at 16:27
add a comment |
I would like to list all indexes present on an ElasticSearch server. I tried this:
curl -XGET localhost:9200/
but it just gives me this:
{
"ok" : true,
"status" : 200,
"name" : "El Aguila",
"version" : {
"number" : "0.19.3",
"snapshot_build" : false
},
"tagline" : "You Know, for Search"
}
I want a list of all indexes..
curl elasticsearch
I would like to list all indexes present on an ElasticSearch server. I tried this:
curl -XGET localhost:9200/
but it just gives me this:
{
"ok" : true,
"status" : 200,
"name" : "El Aguila",
"version" : {
"number" : "0.19.3",
"snapshot_build" : false
},
"tagline" : "You Know, for Search"
}
I want a list of all indexes..
curl elasticsearch
curl elasticsearch
edited Oct 29 '18 at 8:16
Vadim Kotov
4,80063549
4,80063549
asked Jul 2 '13 at 13:09
EvaEva
1,61621423
1,61621423
According to me Abhijit Mazumder's answer below should be accepted one.
– Animesh Pandey
Aug 6 '15 at 7:18
4
@AnimeshPandey then upvote that answer..
– Eva
Aug 6 '15 at 8:07
I already did that.
– Animesh Pandey
Aug 6 '15 at 8:36
6
great! in the future, you can simply upvote what answers you think should be accepted rather than comment about it ;)
– Eva
Aug 13 '15 at 16:27
add a comment |
According to me Abhijit Mazumder's answer below should be accepted one.
– Animesh Pandey
Aug 6 '15 at 7:18
4
@AnimeshPandey then upvote that answer..
– Eva
Aug 6 '15 at 8:07
I already did that.
– Animesh Pandey
Aug 6 '15 at 8:36
6
great! in the future, you can simply upvote what answers you think should be accepted rather than comment about it ;)
– Eva
Aug 13 '15 at 16:27
According to me Abhijit Mazumder's answer below should be accepted one.
– Animesh Pandey
Aug 6 '15 at 7:18
According to me Abhijit Mazumder's answer below should be accepted one.
– Animesh Pandey
Aug 6 '15 at 7:18
4
4
@AnimeshPandey then upvote that answer..
– Eva
Aug 6 '15 at 8:07
@AnimeshPandey then upvote that answer..
– Eva
Aug 6 '15 at 8:07
I already did that.
– Animesh Pandey
Aug 6 '15 at 8:36
I already did that.
– Animesh Pandey
Aug 6 '15 at 8:36
6
6
great! in the future, you can simply upvote what answers you think should be accepted rather than comment about it ;)
– Eva
Aug 13 '15 at 16:27
great! in the future, you can simply upvote what answers you think should be accepted rather than comment about it ;)
– Eva
Aug 13 '15 at 16:27
add a comment |
22 Answers
22
active
oldest
votes
For a concise list of all indices in your cluster, call
curl http://localhost:9200/_aliases
this will give you a list of indices and their aliases.
If you want it pretty-printed, add pretty=1:
curl http://localhost:9200/_aliases?pretty=1
The result will look something like this, if your indices are called old_deuteronomy and mungojerrie:
{
"old_deuteronomy" : {
"aliases" : { }
},
"mungojerrie" : {
"aliases" : {
"rumpleteazer" : { },
"that_horrible_cat" : { }
}
}
}
5
@paweloque answer now looks like it's the correct solution; seems cleaner.curl http://localhost:9200/_stats/indexes?pretty=1
– not a patch
Mar 28 '14 at 12:09
1
My 2 cents for a plain (non-json) list:curl -s localhost:9200/_aliases?pretty=true | awk -F" '!/aliases/ && $2 != "" {print $2}'
– Yaron
Apr 21 '15 at 15:14
For Elasticsearch 6.5 either hit the/statsendpoint, or the health endpoint with param_cluster/health?level=indices
– Justin W.
Feb 23 at 1:22
add a comment |
Try
curl 'localhost:9200/_cat/indices?v'
I will give you following self explanatory output in a tabular manner
health index pri rep docs.count docs.deleted store.size pri.store.size
yellow customer 5 1 0 0 495b 495b
Adding a pipe to sort made this easy to see what was going green. Also the store.size changing indicated additional progress.
– kevpie
Sep 28 '15 at 8:24
you can also select and order columns adding e.g. &h=health,index as well as sort with &s=health:desc
– Georg Engel
Dec 18 '18 at 19:33
add a comment |
You can query localhost:9200/_status and that will give you a list of indices and information about each. The response will look something like this:
{
"ok" : true,
"_shards" : { ... },
"indices" : {
"my_index" : { ... },
"another_index" : { ... }
}
}
3
If you just want to know list of index names then this approach is too much and slower. Better use -GET /_stats/indexes
– asyncwait
Jul 12 '14 at 6:45
4
@asyncwait I'd recommend/_stats/indicessince it's the correct plural and also the key used in/_statusand in/_stats.
– Nicholas Shanks
Jan 15 '15 at 9:53
1
Doesn't seem to be a valid URL anymore on version 5.6.
– Kimberly W
Nov 3 '17 at 16:00
API endpoint has changed to_nodes/statsand_nodes/status@KimberlyW
– maxymoo
Apr 4 '18 at 2:23
Deprecated in 1.2.0.
– jarmod
Aug 7 '18 at 17:59
add a comment |
The _stats command provides ways to customize the results by specifying the metrics wished. To get the indices the query is as follows:
GET /_stats/indices
The general format of the _stats query is:
/_stats
/_stats/{metric}
/_stats/{metric}/{indexMetric}
/{index}/_stats
/{index}/_stats/{metric}
Where the metrics are:
indices, docs, store, indexing, search, get, merge,
refresh, flush, warmer, filter_cache, id_cache,
percolate, segments, fielddata, completion
As an exercice to myself, I've written a small elasticsearch plugin providing the functionality to list elasticsearch indices without any other information. You can find it at the following url:
http://blog.iterativ.ch/2014/04/11/listindices-writing-your-first-elasticsearch-java-plugin/
https://github.com/iterativ/elasticsearch-listindices
Doesn't work:"type": "illegal_argument_exception", "reason": "request [/_stats/indices] contains unrecognized metric: [indices]"
– Ivan Yurchenko
Jan 16 '18 at 9:42
@IvanYurchenko I've implemented my elasticsearch plugin long time ago. Very possible that the APIs have changed since and it doesn't work anymore.. Best is to use the '_aliases' command. It will also provide information about all indices in elasticsearch.
– paweloque
Jan 16 '18 at 17:36
add a comment |
I use this to get all indices:
$ curl --silent 'http://127.0.0.1:9200/_cat/indices' | cut -d -f3
With this list you can work on...
Example
$ curl -s 'http://localhost:9200/_cat/indices' | head -5
green open qa-abcdefq_1458925279526 1 6 0 0 1008b 144b
green open qa-test_learnq_1460483735129 1 6 0 0 1008b 144b
green open qa-testimportd_1458925361399 1 6 0 0 1008b 144b
green open qa-test123p_reports 1 6 3868280 25605 5.9gb 870.5mb
green open qa-dan050216p_1462220967543 1 6 0 0 1008b 144b
To get the 3rd column above (names of the indices):
$ curl -s 'http://localhost:9200/_cat/indices' | head -5 | cut -d -f3
qa-abcdefq_1458925279526
qa-test_learnq_1460483735129
qa-testimportd_1458925361399
qa-test123p_reports
qa-dan050216p_1462220967543
NOTE: You can also use awk '{print $3}' instead of cut -d -f3.
Column Headers
You can also suffix the query with a ?v to add a column header. Doing so will break the cut... method so I'd recommend using the awk.. selection at this point.
$ curl -s 'http://localhost:9200/_cat/indices?v' | head -5
health status index pri rep docs.count docs.deleted store.size pri.store.size
green open qa-abcdefq_1458925279526 1 6 0 0 1008b 144b
green open qa-test_learnq_1460483735129 1 6 0 0 1008b 144b
green open qa-testimportd_1458925361399 1 6 0 0 1008b 144b
green open qa-test123p_reports 1 6 3868280 25605 5.9gb 870.5mb
1
curl -s 'http://localhost:9200/_cat/indices?h=index'will print out just the index name. No need to use shell tricks to filter the column.
– hgf
Jan 2 '18 at 14:56
not only can you use awk, you should use awk (or else usetr -s ' 'beforecutto condense runs of spaces) or else you won't get the index name if the status isredbecause it will be padded with spaces andcuttreats each individual space as delimiting a new field even if that "field" ends up empty
– kbolino
Apr 12 '18 at 23:19
add a comment |
I would also recommend doing /_cat/indices which gives a nice human readable list of your indexes.
add a comment |
curl -XGET 'http://localhost:9200/_cluster/health?level=indices'
This will output like below
{
"cluster_name": "XXXXXX:name",
"status": "green",
"timed_out": false,
"number_of_nodes": 3,
"number_of_data_nodes": 3,
"active_primary_shards": 199,
"active_shards": 398,
"relocating_shards": 0,
"initializing_shards": 0,
"unassigned_shards": 0,
"delayed_unassigned_shards": 0,
"number_of_pending_tasks": 0,
"number_of_in_flight_fetch": 0,
"task_max_waiting_in_queue_millis": 0,
"active_shards_percent_as_number": 100,
"indices": {
"logstash-2017.06.19": {
"status": "green",
"number_of_shards": 3,
"number_of_replicas": 1,
"active_primary_shards": 3,
"active_shards": 6,
"relocating_shards": 0,
"initializing_shards": 0,
"unassigned_shards": 0
},
"logstash-2017.06.18": {
"status": "green",
"number_of_shards": 3,
"number_of_replicas": 1,
"active_primary_shards": 3,
"active_shards": 6,
"relocating_shards": 0,
"initializing_shards": 0,
"unassigned_shards": 0
}}
All the other endpoints did not work for me. Your answer worked! Thx. See stackoverflow.com/questions/49204526/…
– arun
Mar 10 '18 at 2:25
Me too, is this a newer version thing. The main answers seem to work on 2.x but not 6.x
– Andrew Jon Dodds
Jul 3 '18 at 14:50
add a comment |
I'll give you the query which you can run on kibana.
GET /_cat/indices?v
and the CURL version will be
CURL -XGET http://localhost:9200/_cat/indices?v
add a comment |
_stats/indices gives the result with indices.
$ curl -XGET "localhost:9200/_stats/indices?pretty=true"
{
"_shards" : {
"total" : 10,
"successful" : 5,
"failed" : 0
},
"_all" : {
"primaries" : { },
"total" : { }
},
"indices" : {
"visitors" : {
"primaries" : { },
"total" : { }
}
}
}
add a comment |
People here have answered how to do it in curl and sense, some people might need to do this in java.
Here it goes
client.admin().indices().stats(new IndicesStatsRequest()).actionGet().getIndices().keySet()
add a comment |
Try this cat API: it will give you the list of all the indices with health and other details.
CURL -XGET http://localhost:9200/_cat/indices
add a comment |
The simplest way to get a list of only indexes is to use the answer above, with the 'h=index' parameter:
curl -XGET "localhost:9200/_cat/indices?h=index"
add a comment |
I use the _stats/indexes endpoint to get a json blob of data and then filter with jq.
curl 'localhost:9200/_stats/indexes' | jq '.indices | keys | .'
"admin"
"blazeds"
"cgi-bin"
"contacts_v1"
"flex2gateway"
"formmail"
"formmail.pl"
"gw"
...
If you don't want quotes, add a -r flag to jq.
Yes, the endpoint is indexes and the data key is indices, so they couldn't make up their minds either :)
I needed this to clean up these garbage indices created by an internal security scan (nessus).
PS. I highly recommend getting familiar with jq if you're going to interact with ES from the command line.
add a comment |
<dependency>
<groupId>org.elasticsearch</groupId>
<artifactId>elasticsearch</artifactId>
<version>2.4.0</version>
</dependency>
Java API
Settings settings = Settings.settingsBuilder().put("cluster.name", Consts.ES_CLUSTER_NAME).build();
TransportClient client = TransportClient.builder().settings(settings).build().addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName("52.43.207.11"), 9300));
IndicesAdminClient indicesAdminClient = client.admin().indices();
GetIndexResponse getIndexResponse = indicesAdminClient.getIndex(new GetIndexRequest()).get();
for (String index : getIndexResponse.getIndices()) {
logger.info("[index:" + index + "]");
}
You could provide some explanation for the code, and make the answer a little bit more readable... How to Answer
– AgataB
Sep 10 '16 at 15:36
add a comment |
here's another way just to see the indices in the db:
curl -sG somehost-dev.example.com:9200/_status --user "credentials:password" | sed 's/,/n/g' | grep index | grep -v "size_in" | uniq
{ "index":"tmpdb"}
{ "index":"devapp"}
add a comment |
One of the best way to list indices + to display its status together with list : is by simply executing below query.
Note: preferably use Sense to get the proper output.
curl -XGET 'http://localhost:9200/_cat/shards'
The sample output is as below. The main advantage is, it basically shows index name and the shards it saved into, index size and shards ip etc
index1 0 p STARTED 173650 457.1mb 192.168.0.1 ip-192.168.0.1
index1 0 r UNASSIGNED
index2 1 p STARTED 173435 456.6mb 192.168.0.1 ip-192.168.0.1
index2 1 r UNASSIGNED
...
...
...
add a comment |
If you're working in scala, a way to do this and use Future's is to create a RequestExecutor, then use the IndicesStatsRequestBuilder and the administrative client to submit your request.
import org.elasticsearch.action.{ ActionRequestBuilder, ActionListener, ActionResponse }
import scala.concurrent.{ Future, Promise, blocking }
/** Convenice wrapper for creating RequestExecutors */
object RequestExecutor {
def apply[T <: ActionResponse](): RequestExecutor[T] = {
new RequestExecutor[T]
}
}
/** Wrapper to convert an ActionResponse into a scala Future
*
* @see http://chris-zen.github.io/software/2015/05/10/elasticsearch-with-scala-and-akka.html
*/
class RequestExecutor[T <: ActionResponse] extends ActionListener[T] {
private val promise = Promise[T]()
def onResponse(response: T) {
promise.success(response)
}
def onFailure(e: Throwable) {
promise.failure(e)
}
def execute[RB <: ActionRequestBuilder[_, T, _, _]](request: RB): Future[T] = {
blocking {
request.execute(this)
promise.future
}
}
}
The executor is lifted from this blog post which is definitely a good read if you're trying to query ES programmatically and not through curl. One you have this you can create a list of all indexes pretty easily like so:
def totalCountsByIndexName(): Future[List[(String, Long)]] = {
import scala.collection.JavaConverters._
val statsRequestBuider = new IndicesStatsRequestBuilder(client.admin().indices())
val futureStatResponse = RequestExecutor[IndicesStatsResponse].execute(statsRequestBuider)
futureStatResponse.map { indicesStatsResponse =>
indicesStatsResponse.getIndices().asScala.map {
case (k, indexStats) => {
val indexName = indexStats.getIndex()
val totalCount = indexStats.getTotal().getDocs().getCount()
(indexName, totalCount)
}
}.toList
}
}
client is an instance of Client which can be a node or a transport client, whichever suits your needs. You'll also need to have an implicit ExecutionContext in scope for this request. If you try to compile this code without it then you'll get a warning from the scala compiler on how to get that if you don't have one imported already.
I needed the document count, but if you really only need the names of the indices you can pull them from the keys of the map instead of from the IndexStats:
indicesStatsResponse.getIndices().keySet()
This question shows up when you're searching for how to do this even if you're trying to do this programmatically, so I hope this helps anyone looking to do this in scala/java. Otherwise, curl users can just do as the top answer says and use
curl http://localhost:9200/_aliases
add a comment |
You can also get specific index using
curl -X GET "localhost:9200/<INDEX_NAME>"
e.g. curl -X GET "localhost:9200/twitter"
You may get output like:
{
"twitter": {
"aliases": {
},
"mappings": {
},
"settings": {
"index": {
"creation_date": "1540797250479",
"number_of_shards": "3",
"number_of_replicas": "2",
"uuid": "CHYecky8Q-ijsoJbpXP95w",
"version": {
"created": "6040299"
},
"provided_name": "twitter"
}
}
}
}
For more info [https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-get-index.html][1]
add a comment |
you can try this command
curl -X GET http://localhost:9200/_cat/indices?v
1
Hello, just a quick note. This has been specified in the above answers close to 3 times. Please do not post repetitive answers which has already been given unless you intend to edit this and add some more information which hasn't been posted earlier in earlier answers. I hope I am not discouraging you but this is to ensure that all the questions and answers won't get duplicated and repetitive.
– Kamal
Oct 29 '18 at 8:29
add a comment |
I had Kibana and ES installed on a machine. But I did not know the details(at what path, or port) was the ES node on that machine.
So how can you do it from Kibana (version 5.6)?
- Go to Dev Tools
- See Console section, and run the following query:
GET _cat/indices
I was interested in finding the the size of a particular ES index
add a comment |
You may use this command line.
curl -X GET "localhost:9200/_cat/indices?v"
For more (Elasticsearch Official site)
add a comment |
For Elasticsearch 6.X, I found the following the most helpful. Each provide different data in the response.
# more verbose
curl -sS 'localhost:9200/_stats' | jq -C ".indices" | less
# less verbose, summary
curl -sS 'localhost:9200/_cluster/health?level=indices' | jq -C ".indices" | less
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f17426521%2flist-all-indexes-on-elasticsearch-server%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
22 Answers
22
active
oldest
votes
22 Answers
22
active
oldest
votes
active
oldest
votes
active
oldest
votes
For a concise list of all indices in your cluster, call
curl http://localhost:9200/_aliases
this will give you a list of indices and their aliases.
If you want it pretty-printed, add pretty=1:
curl http://localhost:9200/_aliases?pretty=1
The result will look something like this, if your indices are called old_deuteronomy and mungojerrie:
{
"old_deuteronomy" : {
"aliases" : { }
},
"mungojerrie" : {
"aliases" : {
"rumpleteazer" : { },
"that_horrible_cat" : { }
}
}
}
5
@paweloque answer now looks like it's the correct solution; seems cleaner.curl http://localhost:9200/_stats/indexes?pretty=1
– not a patch
Mar 28 '14 at 12:09
1
My 2 cents for a plain (non-json) list:curl -s localhost:9200/_aliases?pretty=true | awk -F" '!/aliases/ && $2 != "" {print $2}'
– Yaron
Apr 21 '15 at 15:14
For Elasticsearch 6.5 either hit the/statsendpoint, or the health endpoint with param_cluster/health?level=indices
– Justin W.
Feb 23 at 1:22
add a comment |
For a concise list of all indices in your cluster, call
curl http://localhost:9200/_aliases
this will give you a list of indices and their aliases.
If you want it pretty-printed, add pretty=1:
curl http://localhost:9200/_aliases?pretty=1
The result will look something like this, if your indices are called old_deuteronomy and mungojerrie:
{
"old_deuteronomy" : {
"aliases" : { }
},
"mungojerrie" : {
"aliases" : {
"rumpleteazer" : { },
"that_horrible_cat" : { }
}
}
}
5
@paweloque answer now looks like it's the correct solution; seems cleaner.curl http://localhost:9200/_stats/indexes?pretty=1
– not a patch
Mar 28 '14 at 12:09
1
My 2 cents for a plain (non-json) list:curl -s localhost:9200/_aliases?pretty=true | awk -F" '!/aliases/ && $2 != "" {print $2}'
– Yaron
Apr 21 '15 at 15:14
For Elasticsearch 6.5 either hit the/statsendpoint, or the health endpoint with param_cluster/health?level=indices
– Justin W.
Feb 23 at 1:22
add a comment |
For a concise list of all indices in your cluster, call
curl http://localhost:9200/_aliases
this will give you a list of indices and their aliases.
If you want it pretty-printed, add pretty=1:
curl http://localhost:9200/_aliases?pretty=1
The result will look something like this, if your indices are called old_deuteronomy and mungojerrie:
{
"old_deuteronomy" : {
"aliases" : { }
},
"mungojerrie" : {
"aliases" : {
"rumpleteazer" : { },
"that_horrible_cat" : { }
}
}
}
For a concise list of all indices in your cluster, call
curl http://localhost:9200/_aliases
this will give you a list of indices and their aliases.
If you want it pretty-printed, add pretty=1:
curl http://localhost:9200/_aliases?pretty=1
The result will look something like this, if your indices are called old_deuteronomy and mungojerrie:
{
"old_deuteronomy" : {
"aliases" : { }
},
"mungojerrie" : {
"aliases" : {
"rumpleteazer" : { },
"that_horrible_cat" : { }
}
}
}
edited Jan 16 '14 at 11:27
Esteis
1,53621831
1,53621831
answered Jul 2 '13 at 15:20
karmikarmi
10.6k22741
10.6k22741
5
@paweloque answer now looks like it's the correct solution; seems cleaner.curl http://localhost:9200/_stats/indexes?pretty=1
– not a patch
Mar 28 '14 at 12:09
1
My 2 cents for a plain (non-json) list:curl -s localhost:9200/_aliases?pretty=true | awk -F" '!/aliases/ && $2 != "" {print $2}'
– Yaron
Apr 21 '15 at 15:14
For Elasticsearch 6.5 either hit the/statsendpoint, or the health endpoint with param_cluster/health?level=indices
– Justin W.
Feb 23 at 1:22
add a comment |
5
@paweloque answer now looks like it's the correct solution; seems cleaner.curl http://localhost:9200/_stats/indexes?pretty=1
– not a patch
Mar 28 '14 at 12:09
1
My 2 cents for a plain (non-json) list:curl -s localhost:9200/_aliases?pretty=true | awk -F" '!/aliases/ && $2 != "" {print $2}'
– Yaron
Apr 21 '15 at 15:14
For Elasticsearch 6.5 either hit the/statsendpoint, or the health endpoint with param_cluster/health?level=indices
– Justin W.
Feb 23 at 1:22
5
5
@paweloque answer now looks like it's the correct solution; seems cleaner.
curl http://localhost:9200/_stats/indexes?pretty=1– not a patch
Mar 28 '14 at 12:09
@paweloque answer now looks like it's the correct solution; seems cleaner.
curl http://localhost:9200/_stats/indexes?pretty=1– not a patch
Mar 28 '14 at 12:09
1
1
My 2 cents for a plain (non-json) list:
curl -s localhost:9200/_aliases?pretty=true | awk -F" '!/aliases/ && $2 != "" {print $2}'– Yaron
Apr 21 '15 at 15:14
My 2 cents for a plain (non-json) list:
curl -s localhost:9200/_aliases?pretty=true | awk -F" '!/aliases/ && $2 != "" {print $2}'– Yaron
Apr 21 '15 at 15:14
For Elasticsearch 6.5 either hit the
/stats endpoint, or the health endpoint with param _cluster/health?level=indices– Justin W.
Feb 23 at 1:22
For Elasticsearch 6.5 either hit the
/stats endpoint, or the health endpoint with param _cluster/health?level=indices– Justin W.
Feb 23 at 1:22
add a comment |
Try
curl 'localhost:9200/_cat/indices?v'
I will give you following self explanatory output in a tabular manner
health index pri rep docs.count docs.deleted store.size pri.store.size
yellow customer 5 1 0 0 495b 495b
Adding a pipe to sort made this easy to see what was going green. Also the store.size changing indicated additional progress.
– kevpie
Sep 28 '15 at 8:24
you can also select and order columns adding e.g. &h=health,index as well as sort with &s=health:desc
– Georg Engel
Dec 18 '18 at 19:33
add a comment |
Try
curl 'localhost:9200/_cat/indices?v'
I will give you following self explanatory output in a tabular manner
health index pri rep docs.count docs.deleted store.size pri.store.size
yellow customer 5 1 0 0 495b 495b
Adding a pipe to sort made this easy to see what was going green. Also the store.size changing indicated additional progress.
– kevpie
Sep 28 '15 at 8:24
you can also select and order columns adding e.g. &h=health,index as well as sort with &s=health:desc
– Georg Engel
Dec 18 '18 at 19:33
add a comment |
Try
curl 'localhost:9200/_cat/indices?v'
I will give you following self explanatory output in a tabular manner
health index pri rep docs.count docs.deleted store.size pri.store.size
yellow customer 5 1 0 0 495b 495b
Try
curl 'localhost:9200/_cat/indices?v'
I will give you following self explanatory output in a tabular manner
health index pri rep docs.count docs.deleted store.size pri.store.size
yellow customer 5 1 0 0 495b 495b
answered May 13 '15 at 19:59
Abhijit MazumderAbhijit Mazumder
2,46322335
2,46322335
Adding a pipe to sort made this easy to see what was going green. Also the store.size changing indicated additional progress.
– kevpie
Sep 28 '15 at 8:24
you can also select and order columns adding e.g. &h=health,index as well as sort with &s=health:desc
– Georg Engel
Dec 18 '18 at 19:33
add a comment |
Adding a pipe to sort made this easy to see what was going green. Also the store.size changing indicated additional progress.
– kevpie
Sep 28 '15 at 8:24
you can also select and order columns adding e.g. &h=health,index as well as sort with &s=health:desc
– Georg Engel
Dec 18 '18 at 19:33
Adding a pipe to sort made this easy to see what was going green. Also the store.size changing indicated additional progress.
– kevpie
Sep 28 '15 at 8:24
Adding a pipe to sort made this easy to see what was going green. Also the store.size changing indicated additional progress.
– kevpie
Sep 28 '15 at 8:24
you can also select and order columns adding e.g. &h=health,index as well as sort with &s=health:desc
– Georg Engel
Dec 18 '18 at 19:33
you can also select and order columns adding e.g. &h=health,index as well as sort with &s=health:desc
– Georg Engel
Dec 18 '18 at 19:33
add a comment |
You can query localhost:9200/_status and that will give you a list of indices and information about each. The response will look something like this:
{
"ok" : true,
"_shards" : { ... },
"indices" : {
"my_index" : { ... },
"another_index" : { ... }
}
}
3
If you just want to know list of index names then this approach is too much and slower. Better use -GET /_stats/indexes
– asyncwait
Jul 12 '14 at 6:45
4
@asyncwait I'd recommend/_stats/indicessince it's the correct plural and also the key used in/_statusand in/_stats.
– Nicholas Shanks
Jan 15 '15 at 9:53
1
Doesn't seem to be a valid URL anymore on version 5.6.
– Kimberly W
Nov 3 '17 at 16:00
API endpoint has changed to_nodes/statsand_nodes/status@KimberlyW
– maxymoo
Apr 4 '18 at 2:23
Deprecated in 1.2.0.
– jarmod
Aug 7 '18 at 17:59
add a comment |
You can query localhost:9200/_status and that will give you a list of indices and information about each. The response will look something like this:
{
"ok" : true,
"_shards" : { ... },
"indices" : {
"my_index" : { ... },
"another_index" : { ... }
}
}
3
If you just want to know list of index names then this approach is too much and slower. Better use -GET /_stats/indexes
– asyncwait
Jul 12 '14 at 6:45
4
@asyncwait I'd recommend/_stats/indicessince it's the correct plural and also the key used in/_statusand in/_stats.
– Nicholas Shanks
Jan 15 '15 at 9:53
1
Doesn't seem to be a valid URL anymore on version 5.6.
– Kimberly W
Nov 3 '17 at 16:00
API endpoint has changed to_nodes/statsand_nodes/status@KimberlyW
– maxymoo
Apr 4 '18 at 2:23
Deprecated in 1.2.0.
– jarmod
Aug 7 '18 at 17:59
add a comment |
You can query localhost:9200/_status and that will give you a list of indices and information about each. The response will look something like this:
{
"ok" : true,
"_shards" : { ... },
"indices" : {
"my_index" : { ... },
"another_index" : { ... }
}
}
You can query localhost:9200/_status and that will give you a list of indices and information about each. The response will look something like this:
{
"ok" : true,
"_shards" : { ... },
"indices" : {
"my_index" : { ... },
"another_index" : { ... }
}
}
answered Jul 2 '13 at 14:07
Matthew BoynesMatthew Boynes
96989
96989
3
If you just want to know list of index names then this approach is too much and slower. Better use -GET /_stats/indexes
– asyncwait
Jul 12 '14 at 6:45
4
@asyncwait I'd recommend/_stats/indicessince it's the correct plural and also the key used in/_statusand in/_stats.
– Nicholas Shanks
Jan 15 '15 at 9:53
1
Doesn't seem to be a valid URL anymore on version 5.6.
– Kimberly W
Nov 3 '17 at 16:00
API endpoint has changed to_nodes/statsand_nodes/status@KimberlyW
– maxymoo
Apr 4 '18 at 2:23
Deprecated in 1.2.0.
– jarmod
Aug 7 '18 at 17:59
add a comment |
3
If you just want to know list of index names then this approach is too much and slower. Better use -GET /_stats/indexes
– asyncwait
Jul 12 '14 at 6:45
4
@asyncwait I'd recommend/_stats/indicessince it's the correct plural and also the key used in/_statusand in/_stats.
– Nicholas Shanks
Jan 15 '15 at 9:53
1
Doesn't seem to be a valid URL anymore on version 5.6.
– Kimberly W
Nov 3 '17 at 16:00
API endpoint has changed to_nodes/statsand_nodes/status@KimberlyW
– maxymoo
Apr 4 '18 at 2:23
Deprecated in 1.2.0.
– jarmod
Aug 7 '18 at 17:59
3
3
If you just want to know list of index names then this approach is too much and slower. Better use -
GET /_stats/indexes– asyncwait
Jul 12 '14 at 6:45
If you just want to know list of index names then this approach is too much and slower. Better use -
GET /_stats/indexes– asyncwait
Jul 12 '14 at 6:45
4
4
@asyncwait I'd recommend
/_stats/indices since it's the correct plural and also the key used in /_status and in /_stats.– Nicholas Shanks
Jan 15 '15 at 9:53
@asyncwait I'd recommend
/_stats/indices since it's the correct plural and also the key used in /_status and in /_stats.– Nicholas Shanks
Jan 15 '15 at 9:53
1
1
Doesn't seem to be a valid URL anymore on version 5.6.
– Kimberly W
Nov 3 '17 at 16:00
Doesn't seem to be a valid URL anymore on version 5.6.
– Kimberly W
Nov 3 '17 at 16:00
API endpoint has changed to
_nodes/stats and _nodes/status @KimberlyW– maxymoo
Apr 4 '18 at 2:23
API endpoint has changed to
_nodes/stats and _nodes/status @KimberlyW– maxymoo
Apr 4 '18 at 2:23
Deprecated in 1.2.0.
– jarmod
Aug 7 '18 at 17:59
Deprecated in 1.2.0.
– jarmod
Aug 7 '18 at 17:59
add a comment |
The _stats command provides ways to customize the results by specifying the metrics wished. To get the indices the query is as follows:
GET /_stats/indices
The general format of the _stats query is:
/_stats
/_stats/{metric}
/_stats/{metric}/{indexMetric}
/{index}/_stats
/{index}/_stats/{metric}
Where the metrics are:
indices, docs, store, indexing, search, get, merge,
refresh, flush, warmer, filter_cache, id_cache,
percolate, segments, fielddata, completion
As an exercice to myself, I've written a small elasticsearch plugin providing the functionality to list elasticsearch indices without any other information. You can find it at the following url:
http://blog.iterativ.ch/2014/04/11/listindices-writing-your-first-elasticsearch-java-plugin/
https://github.com/iterativ/elasticsearch-listindices
Doesn't work:"type": "illegal_argument_exception", "reason": "request [/_stats/indices] contains unrecognized metric: [indices]"
– Ivan Yurchenko
Jan 16 '18 at 9:42
@IvanYurchenko I've implemented my elasticsearch plugin long time ago. Very possible that the APIs have changed since and it doesn't work anymore.. Best is to use the '_aliases' command. It will also provide information about all indices in elasticsearch.
– paweloque
Jan 16 '18 at 17:36
add a comment |
The _stats command provides ways to customize the results by specifying the metrics wished. To get the indices the query is as follows:
GET /_stats/indices
The general format of the _stats query is:
/_stats
/_stats/{metric}
/_stats/{metric}/{indexMetric}
/{index}/_stats
/{index}/_stats/{metric}
Where the metrics are:
indices, docs, store, indexing, search, get, merge,
refresh, flush, warmer, filter_cache, id_cache,
percolate, segments, fielddata, completion
As an exercice to myself, I've written a small elasticsearch plugin providing the functionality to list elasticsearch indices without any other information. You can find it at the following url:
http://blog.iterativ.ch/2014/04/11/listindices-writing-your-first-elasticsearch-java-plugin/
https://github.com/iterativ/elasticsearch-listindices
Doesn't work:"type": "illegal_argument_exception", "reason": "request [/_stats/indices] contains unrecognized metric: [indices]"
– Ivan Yurchenko
Jan 16 '18 at 9:42
@IvanYurchenko I've implemented my elasticsearch plugin long time ago. Very possible that the APIs have changed since and it doesn't work anymore.. Best is to use the '_aliases' command. It will also provide information about all indices in elasticsearch.
– paweloque
Jan 16 '18 at 17:36
add a comment |
The _stats command provides ways to customize the results by specifying the metrics wished. To get the indices the query is as follows:
GET /_stats/indices
The general format of the _stats query is:
/_stats
/_stats/{metric}
/_stats/{metric}/{indexMetric}
/{index}/_stats
/{index}/_stats/{metric}
Where the metrics are:
indices, docs, store, indexing, search, get, merge,
refresh, flush, warmer, filter_cache, id_cache,
percolate, segments, fielddata, completion
As an exercice to myself, I've written a small elasticsearch plugin providing the functionality to list elasticsearch indices without any other information. You can find it at the following url:
http://blog.iterativ.ch/2014/04/11/listindices-writing-your-first-elasticsearch-java-plugin/
https://github.com/iterativ/elasticsearch-listindices
The _stats command provides ways to customize the results by specifying the metrics wished. To get the indices the query is as follows:
GET /_stats/indices
The general format of the _stats query is:
/_stats
/_stats/{metric}
/_stats/{metric}/{indexMetric}
/{index}/_stats
/{index}/_stats/{metric}
Where the metrics are:
indices, docs, store, indexing, search, get, merge,
refresh, flush, warmer, filter_cache, id_cache,
percolate, segments, fielddata, completion
As an exercice to myself, I've written a small elasticsearch plugin providing the functionality to list elasticsearch indices without any other information. You can find it at the following url:
http://blog.iterativ.ch/2014/04/11/listindices-writing-your-first-elasticsearch-java-plugin/
https://github.com/iterativ/elasticsearch-listindices
edited Jul 29 '15 at 5:02
Reto Aebersold
13.6k34465
13.6k34465
answered Mar 2 '14 at 0:21
paweloquepaweloque
9,1642070117
9,1642070117
Doesn't work:"type": "illegal_argument_exception", "reason": "request [/_stats/indices] contains unrecognized metric: [indices]"
– Ivan Yurchenko
Jan 16 '18 at 9:42
@IvanYurchenko I've implemented my elasticsearch plugin long time ago. Very possible that the APIs have changed since and it doesn't work anymore.. Best is to use the '_aliases' command. It will also provide information about all indices in elasticsearch.
– paweloque
Jan 16 '18 at 17:36
add a comment |
Doesn't work:"type": "illegal_argument_exception", "reason": "request [/_stats/indices] contains unrecognized metric: [indices]"
– Ivan Yurchenko
Jan 16 '18 at 9:42
@IvanYurchenko I've implemented my elasticsearch plugin long time ago. Very possible that the APIs have changed since and it doesn't work anymore.. Best is to use the '_aliases' command. It will also provide information about all indices in elasticsearch.
– paweloque
Jan 16 '18 at 17:36
Doesn't work:
"type": "illegal_argument_exception", "reason": "request [/_stats/indices] contains unrecognized metric: [indices]"– Ivan Yurchenko
Jan 16 '18 at 9:42
Doesn't work:
"type": "illegal_argument_exception", "reason": "request [/_stats/indices] contains unrecognized metric: [indices]"– Ivan Yurchenko
Jan 16 '18 at 9:42
@IvanYurchenko I've implemented my elasticsearch plugin long time ago. Very possible that the APIs have changed since and it doesn't work anymore.. Best is to use the '_aliases' command. It will also provide information about all indices in elasticsearch.
– paweloque
Jan 16 '18 at 17:36
@IvanYurchenko I've implemented my elasticsearch plugin long time ago. Very possible that the APIs have changed since and it doesn't work anymore.. Best is to use the '_aliases' command. It will also provide information about all indices in elasticsearch.
– paweloque
Jan 16 '18 at 17:36
add a comment |
I use this to get all indices:
$ curl --silent 'http://127.0.0.1:9200/_cat/indices' | cut -d -f3
With this list you can work on...
Example
$ curl -s 'http://localhost:9200/_cat/indices' | head -5
green open qa-abcdefq_1458925279526 1 6 0 0 1008b 144b
green open qa-test_learnq_1460483735129 1 6 0 0 1008b 144b
green open qa-testimportd_1458925361399 1 6 0 0 1008b 144b
green open qa-test123p_reports 1 6 3868280 25605 5.9gb 870.5mb
green open qa-dan050216p_1462220967543 1 6 0 0 1008b 144b
To get the 3rd column above (names of the indices):
$ curl -s 'http://localhost:9200/_cat/indices' | head -5 | cut -d -f3
qa-abcdefq_1458925279526
qa-test_learnq_1460483735129
qa-testimportd_1458925361399
qa-test123p_reports
qa-dan050216p_1462220967543
NOTE: You can also use awk '{print $3}' instead of cut -d -f3.
Column Headers
You can also suffix the query with a ?v to add a column header. Doing so will break the cut... method so I'd recommend using the awk.. selection at this point.
$ curl -s 'http://localhost:9200/_cat/indices?v' | head -5
health status index pri rep docs.count docs.deleted store.size pri.store.size
green open qa-abcdefq_1458925279526 1 6 0 0 1008b 144b
green open qa-test_learnq_1460483735129 1 6 0 0 1008b 144b
green open qa-testimportd_1458925361399 1 6 0 0 1008b 144b
green open qa-test123p_reports 1 6 3868280 25605 5.9gb 870.5mb
1
curl -s 'http://localhost:9200/_cat/indices?h=index'will print out just the index name. No need to use shell tricks to filter the column.
– hgf
Jan 2 '18 at 14:56
not only can you use awk, you should use awk (or else usetr -s ' 'beforecutto condense runs of spaces) or else you won't get the index name if the status isredbecause it will be padded with spaces andcuttreats each individual space as delimiting a new field even if that "field" ends up empty
– kbolino
Apr 12 '18 at 23:19
add a comment |
I use this to get all indices:
$ curl --silent 'http://127.0.0.1:9200/_cat/indices' | cut -d -f3
With this list you can work on...
Example
$ curl -s 'http://localhost:9200/_cat/indices' | head -5
green open qa-abcdefq_1458925279526 1 6 0 0 1008b 144b
green open qa-test_learnq_1460483735129 1 6 0 0 1008b 144b
green open qa-testimportd_1458925361399 1 6 0 0 1008b 144b
green open qa-test123p_reports 1 6 3868280 25605 5.9gb 870.5mb
green open qa-dan050216p_1462220967543 1 6 0 0 1008b 144b
To get the 3rd column above (names of the indices):
$ curl -s 'http://localhost:9200/_cat/indices' | head -5 | cut -d -f3
qa-abcdefq_1458925279526
qa-test_learnq_1460483735129
qa-testimportd_1458925361399
qa-test123p_reports
qa-dan050216p_1462220967543
NOTE: You can also use awk '{print $3}' instead of cut -d -f3.
Column Headers
You can also suffix the query with a ?v to add a column header. Doing so will break the cut... method so I'd recommend using the awk.. selection at this point.
$ curl -s 'http://localhost:9200/_cat/indices?v' | head -5
health status index pri rep docs.count docs.deleted store.size pri.store.size
green open qa-abcdefq_1458925279526 1 6 0 0 1008b 144b
green open qa-test_learnq_1460483735129 1 6 0 0 1008b 144b
green open qa-testimportd_1458925361399 1 6 0 0 1008b 144b
green open qa-test123p_reports 1 6 3868280 25605 5.9gb 870.5mb
1
curl -s 'http://localhost:9200/_cat/indices?h=index'will print out just the index name. No need to use shell tricks to filter the column.
– hgf
Jan 2 '18 at 14:56
not only can you use awk, you should use awk (or else usetr -s ' 'beforecutto condense runs of spaces) or else you won't get the index name if the status isredbecause it will be padded with spaces andcuttreats each individual space as delimiting a new field even if that "field" ends up empty
– kbolino
Apr 12 '18 at 23:19
add a comment |
I use this to get all indices:
$ curl --silent 'http://127.0.0.1:9200/_cat/indices' | cut -d -f3
With this list you can work on...
Example
$ curl -s 'http://localhost:9200/_cat/indices' | head -5
green open qa-abcdefq_1458925279526 1 6 0 0 1008b 144b
green open qa-test_learnq_1460483735129 1 6 0 0 1008b 144b
green open qa-testimportd_1458925361399 1 6 0 0 1008b 144b
green open qa-test123p_reports 1 6 3868280 25605 5.9gb 870.5mb
green open qa-dan050216p_1462220967543 1 6 0 0 1008b 144b
To get the 3rd column above (names of the indices):
$ curl -s 'http://localhost:9200/_cat/indices' | head -5 | cut -d -f3
qa-abcdefq_1458925279526
qa-test_learnq_1460483735129
qa-testimportd_1458925361399
qa-test123p_reports
qa-dan050216p_1462220967543
NOTE: You can also use awk '{print $3}' instead of cut -d -f3.
Column Headers
You can also suffix the query with a ?v to add a column header. Doing so will break the cut... method so I'd recommend using the awk.. selection at this point.
$ curl -s 'http://localhost:9200/_cat/indices?v' | head -5
health status index pri rep docs.count docs.deleted store.size pri.store.size
green open qa-abcdefq_1458925279526 1 6 0 0 1008b 144b
green open qa-test_learnq_1460483735129 1 6 0 0 1008b 144b
green open qa-testimportd_1458925361399 1 6 0 0 1008b 144b
green open qa-test123p_reports 1 6 3868280 25605 5.9gb 870.5mb
I use this to get all indices:
$ curl --silent 'http://127.0.0.1:9200/_cat/indices' | cut -d -f3
With this list you can work on...
Example
$ curl -s 'http://localhost:9200/_cat/indices' | head -5
green open qa-abcdefq_1458925279526 1 6 0 0 1008b 144b
green open qa-test_learnq_1460483735129 1 6 0 0 1008b 144b
green open qa-testimportd_1458925361399 1 6 0 0 1008b 144b
green open qa-test123p_reports 1 6 3868280 25605 5.9gb 870.5mb
green open qa-dan050216p_1462220967543 1 6 0 0 1008b 144b
To get the 3rd column above (names of the indices):
$ curl -s 'http://localhost:9200/_cat/indices' | head -5 | cut -d -f3
qa-abcdefq_1458925279526
qa-test_learnq_1460483735129
qa-testimportd_1458925361399
qa-test123p_reports
qa-dan050216p_1462220967543
NOTE: You can also use awk '{print $3}' instead of cut -d -f3.
Column Headers
You can also suffix the query with a ?v to add a column header. Doing so will break the cut... method so I'd recommend using the awk.. selection at this point.
$ curl -s 'http://localhost:9200/_cat/indices?v' | head -5
health status index pri rep docs.count docs.deleted store.size pri.store.size
green open qa-abcdefq_1458925279526 1 6 0 0 1008b 144b
green open qa-test_learnq_1460483735129 1 6 0 0 1008b 144b
green open qa-testimportd_1458925361399 1 6 0 0 1008b 144b
green open qa-test123p_reports 1 6 3868280 25605 5.9gb 870.5mb
edited May 13 '16 at 13:10
slm
8,781106280
8,781106280
answered Aug 14 '14 at 10:26
themisterunknownthemisterunknown
396311
396311
1
curl -s 'http://localhost:9200/_cat/indices?h=index'will print out just the index name. No need to use shell tricks to filter the column.
– hgf
Jan 2 '18 at 14:56
not only can you use awk, you should use awk (or else usetr -s ' 'beforecutto condense runs of spaces) or else you won't get the index name if the status isredbecause it will be padded with spaces andcuttreats each individual space as delimiting a new field even if that "field" ends up empty
– kbolino
Apr 12 '18 at 23:19
add a comment |
1
curl -s 'http://localhost:9200/_cat/indices?h=index'will print out just the index name. No need to use shell tricks to filter the column.
– hgf
Jan 2 '18 at 14:56
not only can you use awk, you should use awk (or else usetr -s ' 'beforecutto condense runs of spaces) or else you won't get the index name if the status isredbecause it will be padded with spaces andcuttreats each individual space as delimiting a new field even if that "field" ends up empty
– kbolino
Apr 12 '18 at 23:19
1
1
curl -s 'http://localhost:9200/_cat/indices?h=index' will print out just the index name. No need to use shell tricks to filter the column.– hgf
Jan 2 '18 at 14:56
curl -s 'http://localhost:9200/_cat/indices?h=index' will print out just the index name. No need to use shell tricks to filter the column.– hgf
Jan 2 '18 at 14:56
not only can you use awk, you should use awk (or else use
tr -s ' ' before cut to condense runs of spaces) or else you won't get the index name if the status is red because it will be padded with spaces and cut treats each individual space as delimiting a new field even if that "field" ends up empty– kbolino
Apr 12 '18 at 23:19
not only can you use awk, you should use awk (or else use
tr -s ' ' before cut to condense runs of spaces) or else you won't get the index name if the status is red because it will be padded with spaces and cut treats each individual space as delimiting a new field even if that "field" ends up empty– kbolino
Apr 12 '18 at 23:19
add a comment |
I would also recommend doing /_cat/indices which gives a nice human readable list of your indexes.
add a comment |
I would also recommend doing /_cat/indices which gives a nice human readable list of your indexes.
add a comment |
I would also recommend doing /_cat/indices which gives a nice human readable list of your indexes.
I would also recommend doing /_cat/indices which gives a nice human readable list of your indexes.
answered Aug 7 '14 at 18:53
Matt WatsonMatt Watson
82778
82778
add a comment |
add a comment |
curl -XGET 'http://localhost:9200/_cluster/health?level=indices'
This will output like below
{
"cluster_name": "XXXXXX:name",
"status": "green",
"timed_out": false,
"number_of_nodes": 3,
"number_of_data_nodes": 3,
"active_primary_shards": 199,
"active_shards": 398,
"relocating_shards": 0,
"initializing_shards": 0,
"unassigned_shards": 0,
"delayed_unassigned_shards": 0,
"number_of_pending_tasks": 0,
"number_of_in_flight_fetch": 0,
"task_max_waiting_in_queue_millis": 0,
"active_shards_percent_as_number": 100,
"indices": {
"logstash-2017.06.19": {
"status": "green",
"number_of_shards": 3,
"number_of_replicas": 1,
"active_primary_shards": 3,
"active_shards": 6,
"relocating_shards": 0,
"initializing_shards": 0,
"unassigned_shards": 0
},
"logstash-2017.06.18": {
"status": "green",
"number_of_shards": 3,
"number_of_replicas": 1,
"active_primary_shards": 3,
"active_shards": 6,
"relocating_shards": 0,
"initializing_shards": 0,
"unassigned_shards": 0
}}
All the other endpoints did not work for me. Your answer worked! Thx. See stackoverflow.com/questions/49204526/…
– arun
Mar 10 '18 at 2:25
Me too, is this a newer version thing. The main answers seem to work on 2.x but not 6.x
– Andrew Jon Dodds
Jul 3 '18 at 14:50
add a comment |
curl -XGET 'http://localhost:9200/_cluster/health?level=indices'
This will output like below
{
"cluster_name": "XXXXXX:name",
"status": "green",
"timed_out": false,
"number_of_nodes": 3,
"number_of_data_nodes": 3,
"active_primary_shards": 199,
"active_shards": 398,
"relocating_shards": 0,
"initializing_shards": 0,
"unassigned_shards": 0,
"delayed_unassigned_shards": 0,
"number_of_pending_tasks": 0,
"number_of_in_flight_fetch": 0,
"task_max_waiting_in_queue_millis": 0,
"active_shards_percent_as_number": 100,
"indices": {
"logstash-2017.06.19": {
"status": "green",
"number_of_shards": 3,
"number_of_replicas": 1,
"active_primary_shards": 3,
"active_shards": 6,
"relocating_shards": 0,
"initializing_shards": 0,
"unassigned_shards": 0
},
"logstash-2017.06.18": {
"status": "green",
"number_of_shards": 3,
"number_of_replicas": 1,
"active_primary_shards": 3,
"active_shards": 6,
"relocating_shards": 0,
"initializing_shards": 0,
"unassigned_shards": 0
}}
All the other endpoints did not work for me. Your answer worked! Thx. See stackoverflow.com/questions/49204526/…
– arun
Mar 10 '18 at 2:25
Me too, is this a newer version thing. The main answers seem to work on 2.x but not 6.x
– Andrew Jon Dodds
Jul 3 '18 at 14:50
add a comment |
curl -XGET 'http://localhost:9200/_cluster/health?level=indices'
This will output like below
{
"cluster_name": "XXXXXX:name",
"status": "green",
"timed_out": false,
"number_of_nodes": 3,
"number_of_data_nodes": 3,
"active_primary_shards": 199,
"active_shards": 398,
"relocating_shards": 0,
"initializing_shards": 0,
"unassigned_shards": 0,
"delayed_unassigned_shards": 0,
"number_of_pending_tasks": 0,
"number_of_in_flight_fetch": 0,
"task_max_waiting_in_queue_millis": 0,
"active_shards_percent_as_number": 100,
"indices": {
"logstash-2017.06.19": {
"status": "green",
"number_of_shards": 3,
"number_of_replicas": 1,
"active_primary_shards": 3,
"active_shards": 6,
"relocating_shards": 0,
"initializing_shards": 0,
"unassigned_shards": 0
},
"logstash-2017.06.18": {
"status": "green",
"number_of_shards": 3,
"number_of_replicas": 1,
"active_primary_shards": 3,
"active_shards": 6,
"relocating_shards": 0,
"initializing_shards": 0,
"unassigned_shards": 0
}}
curl -XGET 'http://localhost:9200/_cluster/health?level=indices'
This will output like below
{
"cluster_name": "XXXXXX:name",
"status": "green",
"timed_out": false,
"number_of_nodes": 3,
"number_of_data_nodes": 3,
"active_primary_shards": 199,
"active_shards": 398,
"relocating_shards": 0,
"initializing_shards": 0,
"unassigned_shards": 0,
"delayed_unassigned_shards": 0,
"number_of_pending_tasks": 0,
"number_of_in_flight_fetch": 0,
"task_max_waiting_in_queue_millis": 0,
"active_shards_percent_as_number": 100,
"indices": {
"logstash-2017.06.19": {
"status": "green",
"number_of_shards": 3,
"number_of_replicas": 1,
"active_primary_shards": 3,
"active_shards": 6,
"relocating_shards": 0,
"initializing_shards": 0,
"unassigned_shards": 0
},
"logstash-2017.06.18": {
"status": "green",
"number_of_shards": 3,
"number_of_replicas": 1,
"active_primary_shards": 3,
"active_shards": 6,
"relocating_shards": 0,
"initializing_shards": 0,
"unassigned_shards": 0
}}
edited Jan 16 '18 at 9:44
Ivan Yurchenko
3,0561226
3,0561226
answered Aug 2 '17 at 15:01
PShettyPShetty
33549
33549
All the other endpoints did not work for me. Your answer worked! Thx. See stackoverflow.com/questions/49204526/…
– arun
Mar 10 '18 at 2:25
Me too, is this a newer version thing. The main answers seem to work on 2.x but not 6.x
– Andrew Jon Dodds
Jul 3 '18 at 14:50
add a comment |
All the other endpoints did not work for me. Your answer worked! Thx. See stackoverflow.com/questions/49204526/…
– arun
Mar 10 '18 at 2:25
Me too, is this a newer version thing. The main answers seem to work on 2.x but not 6.x
– Andrew Jon Dodds
Jul 3 '18 at 14:50
All the other endpoints did not work for me. Your answer worked! Thx. See stackoverflow.com/questions/49204526/…
– arun
Mar 10 '18 at 2:25
All the other endpoints did not work for me. Your answer worked! Thx. See stackoverflow.com/questions/49204526/…
– arun
Mar 10 '18 at 2:25
Me too, is this a newer version thing. The main answers seem to work on 2.x but not 6.x
– Andrew Jon Dodds
Jul 3 '18 at 14:50
Me too, is this a newer version thing. The main answers seem to work on 2.x but not 6.x
– Andrew Jon Dodds
Jul 3 '18 at 14:50
add a comment |
I'll give you the query which you can run on kibana.
GET /_cat/indices?v
and the CURL version will be
CURL -XGET http://localhost:9200/_cat/indices?v
add a comment |
I'll give you the query which you can run on kibana.
GET /_cat/indices?v
and the CURL version will be
CURL -XGET http://localhost:9200/_cat/indices?v
add a comment |
I'll give you the query which you can run on kibana.
GET /_cat/indices?v
and the CURL version will be
CURL -XGET http://localhost:9200/_cat/indices?v
I'll give you the query which you can run on kibana.
GET /_cat/indices?v
and the CURL version will be
CURL -XGET http://localhost:9200/_cat/indices?v
edited Jul 25 '17 at 19:59
answered Jul 10 '17 at 5:03
Pinkesh SharmaPinkesh Sharma
1,8121212
1,8121212
add a comment |
add a comment |
_stats/indices gives the result with indices.
$ curl -XGET "localhost:9200/_stats/indices?pretty=true"
{
"_shards" : {
"total" : 10,
"successful" : 5,
"failed" : 0
},
"_all" : {
"primaries" : { },
"total" : { }
},
"indices" : {
"visitors" : {
"primaries" : { },
"total" : { }
}
}
}
add a comment |
_stats/indices gives the result with indices.
$ curl -XGET "localhost:9200/_stats/indices?pretty=true"
{
"_shards" : {
"total" : 10,
"successful" : 5,
"failed" : 0
},
"_all" : {
"primaries" : { },
"total" : { }
},
"indices" : {
"visitors" : {
"primaries" : { },
"total" : { }
}
}
}
add a comment |
_stats/indices gives the result with indices.
$ curl -XGET "localhost:9200/_stats/indices?pretty=true"
{
"_shards" : {
"total" : 10,
"successful" : 5,
"failed" : 0
},
"_all" : {
"primaries" : { },
"total" : { }
},
"indices" : {
"visitors" : {
"primaries" : { },
"total" : { }
}
}
}
_stats/indices gives the result with indices.
$ curl -XGET "localhost:9200/_stats/indices?pretty=true"
{
"_shards" : {
"total" : 10,
"successful" : 5,
"failed" : 0
},
"_all" : {
"primaries" : { },
"total" : { }
},
"indices" : {
"visitors" : {
"primaries" : { },
"total" : { }
}
}
}
answered Jan 9 '15 at 8:25
prayagupdprayagupd
20.2k893142
20.2k893142
add a comment |
add a comment |
People here have answered how to do it in curl and sense, some people might need to do this in java.
Here it goes
client.admin().indices().stats(new IndicesStatsRequest()).actionGet().getIndices().keySet()
add a comment |
People here have answered how to do it in curl and sense, some people might need to do this in java.
Here it goes
client.admin().indices().stats(new IndicesStatsRequest()).actionGet().getIndices().keySet()
add a comment |
People here have answered how to do it in curl and sense, some people might need to do this in java.
Here it goes
client.admin().indices().stats(new IndicesStatsRequest()).actionGet().getIndices().keySet()
People here have answered how to do it in curl and sense, some people might need to do this in java.
Here it goes
client.admin().indices().stats(new IndicesStatsRequest()).actionGet().getIndices().keySet()
answered Aug 28 '15 at 8:21
Avinash Kumar PandeyAvinash Kumar Pandey
42339
42339
add a comment |
add a comment |
Try this cat API: it will give you the list of all the indices with health and other details.
CURL -XGET http://localhost:9200/_cat/indices
add a comment |
Try this cat API: it will give you the list of all the indices with health and other details.
CURL -XGET http://localhost:9200/_cat/indices
add a comment |
Try this cat API: it will give you the list of all the indices with health and other details.
CURL -XGET http://localhost:9200/_cat/indices
Try this cat API: it will give you the list of all the indices with health and other details.
CURL -XGET http://localhost:9200/_cat/indices
answered Sep 18 '17 at 11:05
GauravGaurav
1349
1349
add a comment |
add a comment |
The simplest way to get a list of only indexes is to use the answer above, with the 'h=index' parameter:
curl -XGET "localhost:9200/_cat/indices?h=index"
add a comment |
The simplest way to get a list of only indexes is to use the answer above, with the 'h=index' parameter:
curl -XGET "localhost:9200/_cat/indices?h=index"
add a comment |
The simplest way to get a list of only indexes is to use the answer above, with the 'h=index' parameter:
curl -XGET "localhost:9200/_cat/indices?h=index"
The simplest way to get a list of only indexes is to use the answer above, with the 'h=index' parameter:
curl -XGET "localhost:9200/_cat/indices?h=index"
edited Nov 30 '18 at 14:03
planetmaker
4,71221730
4,71221730
answered Nov 30 '18 at 13:59
J. LewisJ. Lewis
211
211
add a comment |
add a comment |
I use the _stats/indexes endpoint to get a json blob of data and then filter with jq.
curl 'localhost:9200/_stats/indexes' | jq '.indices | keys | .'
"admin"
"blazeds"
"cgi-bin"
"contacts_v1"
"flex2gateway"
"formmail"
"formmail.pl"
"gw"
...
If you don't want quotes, add a -r flag to jq.
Yes, the endpoint is indexes and the data key is indices, so they couldn't make up their minds either :)
I needed this to clean up these garbage indices created by an internal security scan (nessus).
PS. I highly recommend getting familiar with jq if you're going to interact with ES from the command line.
add a comment |
I use the _stats/indexes endpoint to get a json blob of data and then filter with jq.
curl 'localhost:9200/_stats/indexes' | jq '.indices | keys | .'
"admin"
"blazeds"
"cgi-bin"
"contacts_v1"
"flex2gateway"
"formmail"
"formmail.pl"
"gw"
...
If you don't want quotes, add a -r flag to jq.
Yes, the endpoint is indexes and the data key is indices, so they couldn't make up their minds either :)
I needed this to clean up these garbage indices created by an internal security scan (nessus).
PS. I highly recommend getting familiar with jq if you're going to interact with ES from the command line.
add a comment |
I use the _stats/indexes endpoint to get a json blob of data and then filter with jq.
curl 'localhost:9200/_stats/indexes' | jq '.indices | keys | .'
"admin"
"blazeds"
"cgi-bin"
"contacts_v1"
"flex2gateway"
"formmail"
"formmail.pl"
"gw"
...
If you don't want quotes, add a -r flag to jq.
Yes, the endpoint is indexes and the data key is indices, so they couldn't make up their minds either :)
I needed this to clean up these garbage indices created by an internal security scan (nessus).
PS. I highly recommend getting familiar with jq if you're going to interact with ES from the command line.
I use the _stats/indexes endpoint to get a json blob of data and then filter with jq.
curl 'localhost:9200/_stats/indexes' | jq '.indices | keys | .'
"admin"
"blazeds"
"cgi-bin"
"contacts_v1"
"flex2gateway"
"formmail"
"formmail.pl"
"gw"
...
If you don't want quotes, add a -r flag to jq.
Yes, the endpoint is indexes and the data key is indices, so they couldn't make up their minds either :)
I needed this to clean up these garbage indices created by an internal security scan (nessus).
PS. I highly recommend getting familiar with jq if you're going to interact with ES from the command line.
edited Jun 15 '16 at 18:00
answered Jun 15 '16 at 17:55
spazmspazm
2,7882023
2,7882023
add a comment |
add a comment |
<dependency>
<groupId>org.elasticsearch</groupId>
<artifactId>elasticsearch</artifactId>
<version>2.4.0</version>
</dependency>
Java API
Settings settings = Settings.settingsBuilder().put("cluster.name", Consts.ES_CLUSTER_NAME).build();
TransportClient client = TransportClient.builder().settings(settings).build().addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName("52.43.207.11"), 9300));
IndicesAdminClient indicesAdminClient = client.admin().indices();
GetIndexResponse getIndexResponse = indicesAdminClient.getIndex(new GetIndexRequest()).get();
for (String index : getIndexResponse.getIndices()) {
logger.info("[index:" + index + "]");
}
You could provide some explanation for the code, and make the answer a little bit more readable... How to Answer
– AgataB
Sep 10 '16 at 15:36
add a comment |
<dependency>
<groupId>org.elasticsearch</groupId>
<artifactId>elasticsearch</artifactId>
<version>2.4.0</version>
</dependency>
Java API
Settings settings = Settings.settingsBuilder().put("cluster.name", Consts.ES_CLUSTER_NAME).build();
TransportClient client = TransportClient.builder().settings(settings).build().addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName("52.43.207.11"), 9300));
IndicesAdminClient indicesAdminClient = client.admin().indices();
GetIndexResponse getIndexResponse = indicesAdminClient.getIndex(new GetIndexRequest()).get();
for (String index : getIndexResponse.getIndices()) {
logger.info("[index:" + index + "]");
}
You could provide some explanation for the code, and make the answer a little bit more readable... How to Answer
– AgataB
Sep 10 '16 at 15:36
add a comment |
<dependency>
<groupId>org.elasticsearch</groupId>
<artifactId>elasticsearch</artifactId>
<version>2.4.0</version>
</dependency>
Java API
Settings settings = Settings.settingsBuilder().put("cluster.name", Consts.ES_CLUSTER_NAME).build();
TransportClient client = TransportClient.builder().settings(settings).build().addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName("52.43.207.11"), 9300));
IndicesAdminClient indicesAdminClient = client.admin().indices();
GetIndexResponse getIndexResponse = indicesAdminClient.getIndex(new GetIndexRequest()).get();
for (String index : getIndexResponse.getIndices()) {
logger.info("[index:" + index + "]");
}
<dependency>
<groupId>org.elasticsearch</groupId>
<artifactId>elasticsearch</artifactId>
<version>2.4.0</version>
</dependency>
Java API
Settings settings = Settings.settingsBuilder().put("cluster.name", Consts.ES_CLUSTER_NAME).build();
TransportClient client = TransportClient.builder().settings(settings).build().addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName("52.43.207.11"), 9300));
IndicesAdminClient indicesAdminClient = client.admin().indices();
GetIndexResponse getIndexResponse = indicesAdminClient.getIndex(new GetIndexRequest()).get();
for (String index : getIndexResponse.getIndices()) {
logger.info("[index:" + index + "]");
}
answered Sep 10 '16 at 15:14
StanislavKoStanislavKo
5913
5913
You could provide some explanation for the code, and make the answer a little bit more readable... How to Answer
– AgataB
Sep 10 '16 at 15:36
add a comment |
You could provide some explanation for the code, and make the answer a little bit more readable... How to Answer
– AgataB
Sep 10 '16 at 15:36
You could provide some explanation for the code, and make the answer a little bit more readable... How to Answer
– AgataB
Sep 10 '16 at 15:36
You could provide some explanation for the code, and make the answer a little bit more readable... How to Answer
– AgataB
Sep 10 '16 at 15:36
add a comment |
here's another way just to see the indices in the db:
curl -sG somehost-dev.example.com:9200/_status --user "credentials:password" | sed 's/,/n/g' | grep index | grep -v "size_in" | uniq
{ "index":"tmpdb"}
{ "index":"devapp"}
add a comment |
here's another way just to see the indices in the db:
curl -sG somehost-dev.example.com:9200/_status --user "credentials:password" | sed 's/,/n/g' | grep index | grep -v "size_in" | uniq
{ "index":"tmpdb"}
{ "index":"devapp"}
add a comment |
here's another way just to see the indices in the db:
curl -sG somehost-dev.example.com:9200/_status --user "credentials:password" | sed 's/,/n/g' | grep index | grep -v "size_in" | uniq
{ "index":"tmpdb"}
{ "index":"devapp"}
here's another way just to see the indices in the db:
curl -sG somehost-dev.example.com:9200/_status --user "credentials:password" | sed 's/,/n/g' | grep index | grep -v "size_in" | uniq
{ "index":"tmpdb"}
{ "index":"devapp"}
edited Apr 16 '15 at 11:55
om-nom-nom
54.8k11161213
54.8k11161213
answered May 20 '14 at 18:03
TheodoreCTheodoreC
1
1
add a comment |
add a comment |
One of the best way to list indices + to display its status together with list : is by simply executing below query.
Note: preferably use Sense to get the proper output.
curl -XGET 'http://localhost:9200/_cat/shards'
The sample output is as below. The main advantage is, it basically shows index name and the shards it saved into, index size and shards ip etc
index1 0 p STARTED 173650 457.1mb 192.168.0.1 ip-192.168.0.1
index1 0 r UNASSIGNED
index2 1 p STARTED 173435 456.6mb 192.168.0.1 ip-192.168.0.1
index2 1 r UNASSIGNED
...
...
...
add a comment |
One of the best way to list indices + to display its status together with list : is by simply executing below query.
Note: preferably use Sense to get the proper output.
curl -XGET 'http://localhost:9200/_cat/shards'
The sample output is as below. The main advantage is, it basically shows index name and the shards it saved into, index size and shards ip etc
index1 0 p STARTED 173650 457.1mb 192.168.0.1 ip-192.168.0.1
index1 0 r UNASSIGNED
index2 1 p STARTED 173435 456.6mb 192.168.0.1 ip-192.168.0.1
index2 1 r UNASSIGNED
...
...
...
add a comment |
One of the best way to list indices + to display its status together with list : is by simply executing below query.
Note: preferably use Sense to get the proper output.
curl -XGET 'http://localhost:9200/_cat/shards'
The sample output is as below. The main advantage is, it basically shows index name and the shards it saved into, index size and shards ip etc
index1 0 p STARTED 173650 457.1mb 192.168.0.1 ip-192.168.0.1
index1 0 r UNASSIGNED
index2 1 p STARTED 173435 456.6mb 192.168.0.1 ip-192.168.0.1
index2 1 r UNASSIGNED
...
...
...
One of the best way to list indices + to display its status together with list : is by simply executing below query.
Note: preferably use Sense to get the proper output.
curl -XGET 'http://localhost:9200/_cat/shards'
The sample output is as below. The main advantage is, it basically shows index name and the shards it saved into, index size and shards ip etc
index1 0 p STARTED 173650 457.1mb 192.168.0.1 ip-192.168.0.1
index1 0 r UNASSIGNED
index2 1 p STARTED 173435 456.6mb 192.168.0.1 ip-192.168.0.1
index2 1 r UNASSIGNED
...
...
...
answered Jun 1 '16 at 16:33
Ritesh AryalRitesh Aryal
337313
337313
add a comment |
add a comment |
If you're working in scala, a way to do this and use Future's is to create a RequestExecutor, then use the IndicesStatsRequestBuilder and the administrative client to submit your request.
import org.elasticsearch.action.{ ActionRequestBuilder, ActionListener, ActionResponse }
import scala.concurrent.{ Future, Promise, blocking }
/** Convenice wrapper for creating RequestExecutors */
object RequestExecutor {
def apply[T <: ActionResponse](): RequestExecutor[T] = {
new RequestExecutor[T]
}
}
/** Wrapper to convert an ActionResponse into a scala Future
*
* @see http://chris-zen.github.io/software/2015/05/10/elasticsearch-with-scala-and-akka.html
*/
class RequestExecutor[T <: ActionResponse] extends ActionListener[T] {
private val promise = Promise[T]()
def onResponse(response: T) {
promise.success(response)
}
def onFailure(e: Throwable) {
promise.failure(e)
}
def execute[RB <: ActionRequestBuilder[_, T, _, _]](request: RB): Future[T] = {
blocking {
request.execute(this)
promise.future
}
}
}
The executor is lifted from this blog post which is definitely a good read if you're trying to query ES programmatically and not through curl. One you have this you can create a list of all indexes pretty easily like so:
def totalCountsByIndexName(): Future[List[(String, Long)]] = {
import scala.collection.JavaConverters._
val statsRequestBuider = new IndicesStatsRequestBuilder(client.admin().indices())
val futureStatResponse = RequestExecutor[IndicesStatsResponse].execute(statsRequestBuider)
futureStatResponse.map { indicesStatsResponse =>
indicesStatsResponse.getIndices().asScala.map {
case (k, indexStats) => {
val indexName = indexStats.getIndex()
val totalCount = indexStats.getTotal().getDocs().getCount()
(indexName, totalCount)
}
}.toList
}
}
client is an instance of Client which can be a node or a transport client, whichever suits your needs. You'll also need to have an implicit ExecutionContext in scope for this request. If you try to compile this code without it then you'll get a warning from the scala compiler on how to get that if you don't have one imported already.
I needed the document count, but if you really only need the names of the indices you can pull them from the keys of the map instead of from the IndexStats:
indicesStatsResponse.getIndices().keySet()
This question shows up when you're searching for how to do this even if you're trying to do this programmatically, so I hope this helps anyone looking to do this in scala/java. Otherwise, curl users can just do as the top answer says and use
curl http://localhost:9200/_aliases
add a comment |
If you're working in scala, a way to do this and use Future's is to create a RequestExecutor, then use the IndicesStatsRequestBuilder and the administrative client to submit your request.
import org.elasticsearch.action.{ ActionRequestBuilder, ActionListener, ActionResponse }
import scala.concurrent.{ Future, Promise, blocking }
/** Convenice wrapper for creating RequestExecutors */
object RequestExecutor {
def apply[T <: ActionResponse](): RequestExecutor[T] = {
new RequestExecutor[T]
}
}
/** Wrapper to convert an ActionResponse into a scala Future
*
* @see http://chris-zen.github.io/software/2015/05/10/elasticsearch-with-scala-and-akka.html
*/
class RequestExecutor[T <: ActionResponse] extends ActionListener[T] {
private val promise = Promise[T]()
def onResponse(response: T) {
promise.success(response)
}
def onFailure(e: Throwable) {
promise.failure(e)
}
def execute[RB <: ActionRequestBuilder[_, T, _, _]](request: RB): Future[T] = {
blocking {
request.execute(this)
promise.future
}
}
}
The executor is lifted from this blog post which is definitely a good read if you're trying to query ES programmatically and not through curl. One you have this you can create a list of all indexes pretty easily like so:
def totalCountsByIndexName(): Future[List[(String, Long)]] = {
import scala.collection.JavaConverters._
val statsRequestBuider = new IndicesStatsRequestBuilder(client.admin().indices())
val futureStatResponse = RequestExecutor[IndicesStatsResponse].execute(statsRequestBuider)
futureStatResponse.map { indicesStatsResponse =>
indicesStatsResponse.getIndices().asScala.map {
case (k, indexStats) => {
val indexName = indexStats.getIndex()
val totalCount = indexStats.getTotal().getDocs().getCount()
(indexName, totalCount)
}
}.toList
}
}
client is an instance of Client which can be a node or a transport client, whichever suits your needs. You'll also need to have an implicit ExecutionContext in scope for this request. If you try to compile this code without it then you'll get a warning from the scala compiler on how to get that if you don't have one imported already.
I needed the document count, but if you really only need the names of the indices you can pull them from the keys of the map instead of from the IndexStats:
indicesStatsResponse.getIndices().keySet()
This question shows up when you're searching for how to do this even if you're trying to do this programmatically, so I hope this helps anyone looking to do this in scala/java. Otherwise, curl users can just do as the top answer says and use
curl http://localhost:9200/_aliases
add a comment |
If you're working in scala, a way to do this and use Future's is to create a RequestExecutor, then use the IndicesStatsRequestBuilder and the administrative client to submit your request.
import org.elasticsearch.action.{ ActionRequestBuilder, ActionListener, ActionResponse }
import scala.concurrent.{ Future, Promise, blocking }
/** Convenice wrapper for creating RequestExecutors */
object RequestExecutor {
def apply[T <: ActionResponse](): RequestExecutor[T] = {
new RequestExecutor[T]
}
}
/** Wrapper to convert an ActionResponse into a scala Future
*
* @see http://chris-zen.github.io/software/2015/05/10/elasticsearch-with-scala-and-akka.html
*/
class RequestExecutor[T <: ActionResponse] extends ActionListener[T] {
private val promise = Promise[T]()
def onResponse(response: T) {
promise.success(response)
}
def onFailure(e: Throwable) {
promise.failure(e)
}
def execute[RB <: ActionRequestBuilder[_, T, _, _]](request: RB): Future[T] = {
blocking {
request.execute(this)
promise.future
}
}
}
The executor is lifted from this blog post which is definitely a good read if you're trying to query ES programmatically and not through curl. One you have this you can create a list of all indexes pretty easily like so:
def totalCountsByIndexName(): Future[List[(String, Long)]] = {
import scala.collection.JavaConverters._
val statsRequestBuider = new IndicesStatsRequestBuilder(client.admin().indices())
val futureStatResponse = RequestExecutor[IndicesStatsResponse].execute(statsRequestBuider)
futureStatResponse.map { indicesStatsResponse =>
indicesStatsResponse.getIndices().asScala.map {
case (k, indexStats) => {
val indexName = indexStats.getIndex()
val totalCount = indexStats.getTotal().getDocs().getCount()
(indexName, totalCount)
}
}.toList
}
}
client is an instance of Client which can be a node or a transport client, whichever suits your needs. You'll also need to have an implicit ExecutionContext in scope for this request. If you try to compile this code without it then you'll get a warning from the scala compiler on how to get that if you don't have one imported already.
I needed the document count, but if you really only need the names of the indices you can pull them from the keys of the map instead of from the IndexStats:
indicesStatsResponse.getIndices().keySet()
This question shows up when you're searching for how to do this even if you're trying to do this programmatically, so I hope this helps anyone looking to do this in scala/java. Otherwise, curl users can just do as the top answer says and use
curl http://localhost:9200/_aliases
If you're working in scala, a way to do this and use Future's is to create a RequestExecutor, then use the IndicesStatsRequestBuilder and the administrative client to submit your request.
import org.elasticsearch.action.{ ActionRequestBuilder, ActionListener, ActionResponse }
import scala.concurrent.{ Future, Promise, blocking }
/** Convenice wrapper for creating RequestExecutors */
object RequestExecutor {
def apply[T <: ActionResponse](): RequestExecutor[T] = {
new RequestExecutor[T]
}
}
/** Wrapper to convert an ActionResponse into a scala Future
*
* @see http://chris-zen.github.io/software/2015/05/10/elasticsearch-with-scala-and-akka.html
*/
class RequestExecutor[T <: ActionResponse] extends ActionListener[T] {
private val promise = Promise[T]()
def onResponse(response: T) {
promise.success(response)
}
def onFailure(e: Throwable) {
promise.failure(e)
}
def execute[RB <: ActionRequestBuilder[_, T, _, _]](request: RB): Future[T] = {
blocking {
request.execute(this)
promise.future
}
}
}
The executor is lifted from this blog post which is definitely a good read if you're trying to query ES programmatically and not through curl. One you have this you can create a list of all indexes pretty easily like so:
def totalCountsByIndexName(): Future[List[(String, Long)]] = {
import scala.collection.JavaConverters._
val statsRequestBuider = new IndicesStatsRequestBuilder(client.admin().indices())
val futureStatResponse = RequestExecutor[IndicesStatsResponse].execute(statsRequestBuider)
futureStatResponse.map { indicesStatsResponse =>
indicesStatsResponse.getIndices().asScala.map {
case (k, indexStats) => {
val indexName = indexStats.getIndex()
val totalCount = indexStats.getTotal().getDocs().getCount()
(indexName, totalCount)
}
}.toList
}
}
client is an instance of Client which can be a node or a transport client, whichever suits your needs. You'll also need to have an implicit ExecutionContext in scope for this request. If you try to compile this code without it then you'll get a warning from the scala compiler on how to get that if you don't have one imported already.
I needed the document count, but if you really only need the names of the indices you can pull them from the keys of the map instead of from the IndexStats:
indicesStatsResponse.getIndices().keySet()
This question shows up when you're searching for how to do this even if you're trying to do this programmatically, so I hope this helps anyone looking to do this in scala/java. Otherwise, curl users can just do as the top answer says and use
curl http://localhost:9200/_aliases
answered Nov 15 '16 at 14:12
EdgeCaseBergEdgeCaseBerg
1,53111331
1,53111331
add a comment |
add a comment |
You can also get specific index using
curl -X GET "localhost:9200/<INDEX_NAME>"
e.g. curl -X GET "localhost:9200/twitter"
You may get output like:
{
"twitter": {
"aliases": {
},
"mappings": {
},
"settings": {
"index": {
"creation_date": "1540797250479",
"number_of_shards": "3",
"number_of_replicas": "2",
"uuid": "CHYecky8Q-ijsoJbpXP95w",
"version": {
"created": "6040299"
},
"provided_name": "twitter"
}
}
}
}
For more info [https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-get-index.html][1]
add a comment |
You can also get specific index using
curl -X GET "localhost:9200/<INDEX_NAME>"
e.g. curl -X GET "localhost:9200/twitter"
You may get output like:
{
"twitter": {
"aliases": {
},
"mappings": {
},
"settings": {
"index": {
"creation_date": "1540797250479",
"number_of_shards": "3",
"number_of_replicas": "2",
"uuid": "CHYecky8Q-ijsoJbpXP95w",
"version": {
"created": "6040299"
},
"provided_name": "twitter"
}
}
}
}
For more info [https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-get-index.html][1]
add a comment |
You can also get specific index using
curl -X GET "localhost:9200/<INDEX_NAME>"
e.g. curl -X GET "localhost:9200/twitter"
You may get output like:
{
"twitter": {
"aliases": {
},
"mappings": {
},
"settings": {
"index": {
"creation_date": "1540797250479",
"number_of_shards": "3",
"number_of_replicas": "2",
"uuid": "CHYecky8Q-ijsoJbpXP95w",
"version": {
"created": "6040299"
},
"provided_name": "twitter"
}
}
}
}
For more info [https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-get-index.html][1]
You can also get specific index using
curl -X GET "localhost:9200/<INDEX_NAME>"
e.g. curl -X GET "localhost:9200/twitter"
You may get output like:
{
"twitter": {
"aliases": {
},
"mappings": {
},
"settings": {
"index": {
"creation_date": "1540797250479",
"number_of_shards": "3",
"number_of_replicas": "2",
"uuid": "CHYecky8Q-ijsoJbpXP95w",
"version": {
"created": "6040299"
},
"provided_name": "twitter"
}
}
}
}
For more info [https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-get-index.html][1]
edited Oct 29 '18 at 7:40
answered Oct 29 '18 at 7:25
Yagnesh bhalalaYagnesh bhalala
450613
450613
add a comment |
add a comment |
you can try this command
curl -X GET http://localhost:9200/_cat/indices?v
1
Hello, just a quick note. This has been specified in the above answers close to 3 times. Please do not post repetitive answers which has already been given unless you intend to edit this and add some more information which hasn't been posted earlier in earlier answers. I hope I am not discouraging you but this is to ensure that all the questions and answers won't get duplicated and repetitive.
– Kamal
Oct 29 '18 at 8:29
add a comment |
you can try this command
curl -X GET http://localhost:9200/_cat/indices?v
1
Hello, just a quick note. This has been specified in the above answers close to 3 times. Please do not post repetitive answers which has already been given unless you intend to edit this and add some more information which hasn't been posted earlier in earlier answers. I hope I am not discouraging you but this is to ensure that all the questions and answers won't get duplicated and repetitive.
– Kamal
Oct 29 '18 at 8:29
add a comment |
you can try this command
curl -X GET http://localhost:9200/_cat/indices?v
you can try this command
curl -X GET http://localhost:9200/_cat/indices?v
answered Oct 29 '18 at 8:03
dat nguyendat nguyen
13
13
1
Hello, just a quick note. This has been specified in the above answers close to 3 times. Please do not post repetitive answers which has already been given unless you intend to edit this and add some more information which hasn't been posted earlier in earlier answers. I hope I am not discouraging you but this is to ensure that all the questions and answers won't get duplicated and repetitive.
– Kamal
Oct 29 '18 at 8:29
add a comment |
1
Hello, just a quick note. This has been specified in the above answers close to 3 times. Please do not post repetitive answers which has already been given unless you intend to edit this and add some more information which hasn't been posted earlier in earlier answers. I hope I am not discouraging you but this is to ensure that all the questions and answers won't get duplicated and repetitive.
– Kamal
Oct 29 '18 at 8:29
1
1
Hello, just a quick note. This has been specified in the above answers close to 3 times. Please do not post repetitive answers which has already been given unless you intend to edit this and add some more information which hasn't been posted earlier in earlier answers. I hope I am not discouraging you but this is to ensure that all the questions and answers won't get duplicated and repetitive.
– Kamal
Oct 29 '18 at 8:29
Hello, just a quick note. This has been specified in the above answers close to 3 times. Please do not post repetitive answers which has already been given unless you intend to edit this and add some more information which hasn't been posted earlier in earlier answers. I hope I am not discouraging you but this is to ensure that all the questions and answers won't get duplicated and repetitive.
– Kamal
Oct 29 '18 at 8:29
add a comment |
I had Kibana and ES installed on a machine. But I did not know the details(at what path, or port) was the ES node on that machine.
So how can you do it from Kibana (version 5.6)?
- Go to Dev Tools
- See Console section, and run the following query:
GET _cat/indices
I was interested in finding the the size of a particular ES index
add a comment |
I had Kibana and ES installed on a machine. But I did not know the details(at what path, or port) was the ES node on that machine.
So how can you do it from Kibana (version 5.6)?
- Go to Dev Tools
- See Console section, and run the following query:
GET _cat/indices
I was interested in finding the the size of a particular ES index
add a comment |
I had Kibana and ES installed on a machine. But I did not know the details(at what path, or port) was the ES node on that machine.
So how can you do it from Kibana (version 5.6)?
- Go to Dev Tools
- See Console section, and run the following query:
GET _cat/indices
I was interested in finding the the size of a particular ES index
I had Kibana and ES installed on a machine. But I did not know the details(at what path, or port) was the ES node on that machine.
So how can you do it from Kibana (version 5.6)?
- Go to Dev Tools
- See Console section, and run the following query:
GET _cat/indices
I was interested in finding the the size of a particular ES index
edited Nov 7 '18 at 13:03
answered Nov 7 '18 at 12:57
razvangrazvang
49358
49358
add a comment |
add a comment |
You may use this command line.
curl -X GET "localhost:9200/_cat/indices?v"
For more (Elasticsearch Official site)
add a comment |
You may use this command line.
curl -X GET "localhost:9200/_cat/indices?v"
For more (Elasticsearch Official site)
add a comment |
You may use this command line.
curl -X GET "localhost:9200/_cat/indices?v"
For more (Elasticsearch Official site)
You may use this command line.
curl -X GET "localhost:9200/_cat/indices?v"
For more (Elasticsearch Official site)
edited Nov 23 '18 at 6:29
answered Nov 23 '18 at 6:10
Yagnesh bhalalaYagnesh bhalala
450613
450613
add a comment |
add a comment |
For Elasticsearch 6.X, I found the following the most helpful. Each provide different data in the response.
# more verbose
curl -sS 'localhost:9200/_stats' | jq -C ".indices" | less
# less verbose, summary
curl -sS 'localhost:9200/_cluster/health?level=indices' | jq -C ".indices" | less
add a comment |
For Elasticsearch 6.X, I found the following the most helpful. Each provide different data in the response.
# more verbose
curl -sS 'localhost:9200/_stats' | jq -C ".indices" | less
# less verbose, summary
curl -sS 'localhost:9200/_cluster/health?level=indices' | jq -C ".indices" | less
add a comment |
For Elasticsearch 6.X, I found the following the most helpful. Each provide different data in the response.
# more verbose
curl -sS 'localhost:9200/_stats' | jq -C ".indices" | less
# less verbose, summary
curl -sS 'localhost:9200/_cluster/health?level=indices' | jq -C ".indices" | less
For Elasticsearch 6.X, I found the following the most helpful. Each provide different data in the response.
# more verbose
curl -sS 'localhost:9200/_stats' | jq -C ".indices" | less
# less verbose, summary
curl -sS 'localhost:9200/_cluster/health?level=indices' | jq -C ".indices" | less
answered Feb 23 at 1:26
Justin W.Justin W.
188136
188136
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f17426521%2flist-all-indexes-on-elasticsearch-server%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
According to me Abhijit Mazumder's answer below should be accepted one.
– Animesh Pandey
Aug 6 '15 at 7:18
4
@AnimeshPandey then upvote that answer..
– Eva
Aug 6 '15 at 8:07
I already did that.
– Animesh Pandey
Aug 6 '15 at 8:36
6
great! in the future, you can simply upvote what answers you think should be accepted rather than comment about it ;)
– Eva
Aug 13 '15 at 16:27