Note that the mutate{} filter contains a convert{} operation, which is very useful.
If you find yourself in ruby for another purpose, you might want to cast the variables while your there. Here are some examples:
ruby { code => " begin event['foo'] = event['foo'].to_f event['bar'] = event['bar'].to_i rescue Exception; event['ruby_exception'] = 'cast' end " }