i tried to write one Python code for get ES index and size but it gave me a huge json output and I was not able to find an exact result.
how we can do this.
es.indices.stats(index=index)
i tried to write one Python code for get ES index and size but it gave me a huge json output and I was not able to find an exact result.
how we can do this.
es.indices.stats(index=index)
Try this:
indice = 'indexname'
params = {"filter_path": "indices.{0}.total.store.size_in_bytes".format(indice)}
response = get_client().indices.stats(index=indice, metric="store", filter_path=params['filter_path'])
size_in_bytes = response['indices'][indice]['total']['store']['size_in_bytes']
print(f"Index Size: '{indice}': {size_in_bytes} bytes")
thanks @RabBit_BR for response.
i tried below
index_stats = es.indices.stats(index=index_name)
if index_stats and 'indices' in index_stats:
size_in_bytes = index_stats['indices'][index_name]['total']['store']['size_in_bytes']
# Convert bytes to a human-readable format
size_in_gb = size_in_bytes / (1024**3) # Convert bytes to GB
return size_in_gb
else:
This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
© 2020. All Rights Reserved - Elasticsearch
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant logo are trademarks of the Apache Software Foundation in the United States and/or other countries.