That will work for the add_field because the decorator calls sprintf on the fieldname. The convert function just does a get of the field. Since it does not sprintf you cannot use %{} in the convert.
You would have to use a ruby filter to do it. The following
input { generator { count => 1 lines => [ '' ] } }
filter {
mutate { add_field => { "fieldName" => "foo" "foo" => "1" } }
ruby {
code => '
name = event.get("fieldName")
event.set(name, event.get(name).to_i)
'
}
}
output { stdout { codec => rubydebug { metadata => false } } }
will produce
"foo" => 1