I am trying to calculate a percentage from two fields which in real life calculator gives a value of 0.332 but using sql queries I am only getting "0" therefore while multiplying with 100 instead of getting 33.2 I am getting 0. Any way I can force it to show the decimals?
I came up with this query to convert the INT to FLOAT type and then the result would be the expected.
SELECT TRUNCATE(CAST(system.filesystem.free AS float)/CAST(system.filesystem.total AS float), 4) AS Free_percentage from "metricbeat-6.5.1-*" WHERE system.filesystem.free IS NOT null ORDER BY "@timestamp" LIMIT 1
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.