You can use a ruby filter to change all values to requested format, after assigning it to a field, Try this below filter for authorize field as example
The best way will be to use a ruby filter with some code to convert the data.
Those the unites can change on a document basis? For example, the phaseTimes.authorize will always be in micro seconds or it can be in miliseconds or seconds as well?
If so, you will need to check the unit in your ruby code to convert it correctly.
.to_f ignores the alpha suffix, so you do not need to split the v into digits and suffix using the regexp, although stylistically that might be better.
Wow, this is brilliant, thanks all for taking me in the right direction and for the code @Badger .
I ended up coding the following, but your solutions seems more elegant.
def str_to_ms(val)
if val.end_with?("ms") then
return val[0..-3].to_f
elsif val.end_with?("µs") then
return val[0..-3].to_f / 1000
elsif val.end_with?("s") then
return val[0..-2].to_f * 1000
elsif val.end_with?("m") then
return val[0..-2].to_f * 1000 * 60
elsif val.end_with?("h") then
return val[0..-2].to_f * 1000 * 60 * 60
end
end
def filter(event)
fields = ["authorize", "filter", "indexScan", "instantiate", "run" ]
fields.each do |key|
val = event.get(key)
if !val.nil? then
event.set(key, str_to_ms(val))
end
end
return [ event ]
end
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.