Is there a way in a transform to convert bytes to human readable format?
I know I can do a painless script to perform math on a byte value, but can I format to show MB or GB depending on size of the value?
Is there a way in a transform to convert bytes to human readable format?
I know I can do a painless script to perform math on a byte value, but can I format to show MB or GB depending on size of the value?
Hey,
not really. Elasticsearch has a ByteSizeValue class, that is unfortunately not exposed in painless. if you are querying a monitoring API you can use the human parameter to get human readable values. Maybe that already helps.
If it's about documents, I would highly recommend doing this on indexing with an ingest processor (still you have to write the logic yourself). Here is some inspiration https://github.com/elastic/elasticsearch/blob/master/core/src/main/java/org/elasticsearch/common/unit/ByteSizeValue.java
--Alex
Thank you. I'm reading from a metricbeat index. I can deal with just always converting to MB. Not really worth the effort to write something.
© 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.