I import data from a mySQL DB via Logstash into an Elasticsearch index.
The database contains float values in a field.
However, these values change during import.
3378.2 from the mySQL DB becomes 3378.199951171875 in the Elasticsearch Index.
Does anyone have an idea why that is and how I can fix the error?
Is there a possibility to round the values by mutations during import?
In a single precision float there are 23 bits to the mantissa. Everything else is a rounding error. 2^23 is 8MM, so you should not expect accuracy beyond 7 digits.
I have now added a Ruby filter and also installed the plugin via bin/logstash-plugin install logstash-filter-ruby.
Unfortunately I get the following error now:
root@376f1ace7f99:/opt/logstash# bin/logstash
Sending Logstash logs to /opt/logstash/logs which is now configured via log4j2.properties
[2019-11-29T17:05:02,335][INFO ][logstash.runner ] Starting Logstash {"logstash.version"=>"7.0.1"}
[2019-11-29T17:05:10,228][ERROR][logstash.plugins.registry] Tried to load a plugin's code, but failed. {:exception=>#<LoadError: no such file to load -- logstash/filters/"ruby">, :path=>"logstash/filters/\"ruby\"", :type=>"filter", :name=>"\"ruby\""}
[2019-11-29T17:05:10,259][ERROR][logstash.agent ] Failed to execute action {:action=>LogStash::PipelineAction::Create/pipeline_id:main, :exception=>"LogStash::PluginLoadingError", :message=>"Couldn't find any filter plugin named '\"ruby\"'. Are you sure this is correct? Trying to load the \"ruby\" filter plugin resulted in this error: no such file to load -- logstash/filters/\"ruby\"", :backtrace=>["/opt/logstash/logstash-core/lib/logstash/plugins/registry.rb:211:in `lookup_pipeline_plugin'", "/opt/logstash/logstash-core/lib/logstash/plugin.rb:137:in `lookup'", "org/logstash/plugins/PluginFactoryExt.java:200:in `plugin'", "org/logstash/execution/JavaBasePipelineExt.java:50:in `initialize'", "/opt/logstash/logstash-core/lib/logstash/java_pipeline.rb:23:in `initialize'", "/opt/logstash/logstash-core/lib/logstash/pipeline_action/create.rb:36:in `execute'", "/opt/logstash/logstash-core/lib/logstash/agent.rb:325:in `block in converge_state'"]}
[2019-11-29T17:05:10,833][INFO ][logstash.agent ] Successfully started Logstash API endpoint {:port=>9600}
[2019-11-29T17:05:15,631][INFO ][logstash.runner ] Logstash shut down.
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.