Code doesn't get executed

Hi ,
I have a block of code like this:

if "vlan" in [tags] {
    grok {
      patterns_dir => ["./patterns/custom-patterns"]
      match => { "message" => ["configure vlan %{WORD:vlan} add ports %{PORTS:ports} %{TAG_INFO:tagInfo}",
                             "configure vlan %{WORD:vlan} tag %{NUMBER:vid}",
                             "configure vlan %{WORD:vlan} ipaddress %{IP:ip} %{IP:subnet}" ]}
      add_tag => ["vlan_info"]

  if "vlan_info" in [tags] {

    # TODO: Doesn't Work !!! investigate why.
    # Extract the 'Correct' list of the ports ; the line contains the port in this format 19, 28, 46-48
    # and this code convert it to 19, 28, 46, 47, 48
    ruby {
      code => "
        if (defined?(ports))
          correct_ports = []
          comma_separated_ports = ports.split(',')
            p.gsub!(/\s+/, '')

            if p.include? '-'
              dash_separated_ports = p.split('-')
              for i in dash_separated_ports.first..dash_separated_ports.last

          event.set('ports', correct_ports)

the part written in Ruby plugin doesn't seem to get executed and I am not sure why ports is always undefined even though I am adding it to the event.
any idea?

ok I found my mistake. I should have used event.get('ports') instead of 'ports'

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.