Depends on some condition I want to re-calculate field value. Please, give me a hand.
ruby {
code => "event.set('my_field', event.get('my_field')*1024)"
}
Depends on some condition I want to re-calculate field value. Please, give me a hand.
ruby {
code => "event.set('my_field', event.get('my_field')*1024)"
}
If that’s not working then use a temporary variable that you remove after you’re done calculating.
Event.set(‘my_field’, ‘temp’); Event.set(‘my_field’, event.get(‘temp’)*1024);
remove_field => “temp”
Hi. I've resolved this issue. You gave me a good prompt ))
if [@metadata][csv][Flag] == "1" {
ruby {
init => "@var_tmp"
code => "
event.set('var_tmp', event.get('my_field'))
event.set('my_field', event.get(''var_tmp')*1024);"
}
}
And in the end we need to remove this temporary variable.
mutate {
remove_field => ["var_tmp"]
}
Guys, but not forget firstly to convert type of your field to some numeric ones!
This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
© 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.