How to pass variable from Logstash filter into ruby parameter

Hi @Jirka_Liska ,
you need to use the event.get api to access the variable or to first get it and then use it as a variable.
also, you must return the event (returning an empty array is like drop). In addition, you need to import uri module.

Kindly try the following (I have ommited to_s as PK is probably already a string)

require 'uri';
def filter(event)
    primary_key =  event.get("[PK]");

    url = URI('http://rest_api:8000/api/' + primary_key + "/")
   
   return [event]

end

Also please notice that you are not manipulating the event in the filter (you init url variable but not using it).

Ofir