Hi Logstash Gurus,
I need to build off another syntax question I asked, here. In that post, I learned how to use a Ruby Filter to create a new field, then populate that field with the product of other fields:
  ruby {
    code => '
      event.set( "[FieldC]", (event.get("[FieldA]").to_i  *  event.get("[FieldB]").to_i  *  5) )
    '
  }
This looked correct when I inspected the raw data.  But later, I realized that FieldC is a string.  This is a problem, as I need it to be an integer.
I tried the stupid solution by doing this:
  ruby {
    ...same solution from above...
  }
  mutate {
    convert => { "[FieldC]"  => "integer" }
  }
And then this:
  ruby {
    code => '
      event.set( "[FieldC]", (event.get("[FieldA]").to_i  *  event.get("[FieldB]").to_i  *  5).to_i )
    '
  }
(I added an “.to_i” at the end of the big math section)
But neither of these had an effect. (The online documentation also says “Mutating a collection after setting it in the Event has an undefined behaviour and is not allowed,” so I guess this was never going to work.)
A careful read of the Event API page (here) says:
Syntax: event.get(field)
Returns: Value for this field or nil if the field does not exist. Returned values
could be a string, numeric or timestamp scalar value.
But I don’t understand how you tell Logstash that FieldC is supposed to be an integer.  Is there a way to force this?  Thank you!