That's not how you do string interpolation in ruby. sprintf references are a logstash thing, not a ruby thing. Try
event.set("parameter_#{index}", value)
As a point of style I think it would be more common to do
ids = event.get("parameter")
if ids
...
thus getting rid of the intermediate variable.