Transform to human readable values

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.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.