我可以通过这样的代码获取列表中的所有ES索引:
from elasticsearch import Elasticsearch
es = Elasticsearch()
indices=es.indices.get_aliases().keys()
sorted(indices)
但是有没有可能得到像 {'index1': '100gb', 'index2': '10gb', 'index3': '15gb'} 这样的字典。所以我的意思是带有索引名称和大小的 dic。
请您参考如下方法:
Curator 4 在 IndexList 初始化时提取大部分索引元数据。如果重要的话,它以字节为单位,而不是以人类可读的大小。
它在IndexList.index_info[index_name]['size_in_bytes']
在 http://curator.readthedocs.io/en/latest/objectclasses.html#indexlist 阅读有关 IndexList 方法的更多信息
import elasticsearch
import curator
client = elasticsearch.Elasticsearch(host='127.0.0.1')
il = curator.IndexList(client)
print('{0}'.format(il.indices))
[u'topbeat-2016.09.01', ...]
print('{0}'.format(il.index_info['topbeat-2016.09.01'])
{'number_of_replicas': u'1', 'size_in_bytes': 706503044, 'number_of_shards': u'5', 'docs': 1629986, 'age': {'creation_date': 1472688002}, 'state': u'open', 'segments': 0}
