I'm using logstash ruby filter to convert scientific notation from string to float which seem to be not working. I have used GROK to extract the scientific notation (1.989e-04) from the message and now converting to real number (0.0001989). The values i get is just 0
If your [sourceOffset] field contains "1.989e-04" then your ruby filter will produce
"sourceOffset" => 0.0001989,
However, you have no exception handling. The Ruby exception occurred: invalid value for BigDecimal(): "-" occurs if the [sourceOffset] field contains -.
You could use try/catch or test whether [sourceOffset] is in scientific notation using a regexp.
Yes that's working. I had to change to GROK patterns as %{USERNAME:sourceoffset}
then i ran the Ruby without the (.to_f) which worked.
the values are now coming as String.
Ruby failed to convert that to Float and so many error;s about the exceptions.
My ruby is converting the scientific notation in string but i need in float
i need help here,
Mutate filter convert is showing back the scientific notation in number type # ( -1.038e-06 ) but not in decimal -0.000001038.
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.