How to refer path from filter to other?

input {
file {
path => ["/opt/Log/*.csv" ]
start_position => "beginning"
}
}

i have requirement to use if [path] == "contains string" then set type => string.

Also can i refer path in other filters such as in Filter plugin and how.

thanks in advance.

The path of the input file is saved in the path field so you can e.g. do this:

filter {
  if "substring" in [path] {
    mutate {
      replace => {
        "type" => "string"
      }
    }
  }
}

Can i refer this [path] in ruby {}.

I have requirement to extract the file name from path and add_field for them in elastic search...

the Ruby code what i have written:

def ReadFileName(filepath)
filename = File.basename("#{filepath}", ".*")
value = filename.split("")
x = value[0]
y = value[1]+"
" + value[2] +"_"+ value[3]
z = value[4]

print "#{x} \n"
print "#{y} \n"
print "#{z} \n"

return x,y,z
end

ReadFileName("d:\1431509083921_150513_E6_GHY_bing_CSV_ContentBreakdown.csv")

Hence instead ReadFileName("d:\1431509083921_150513_E6_GHY_bing_CSV_ContentBreakdown.csv") can i refer ReadFileName("[path]")

You don't have to use a ruby filter for this, but if you choose to do so you can access it with event['path'].

what you suggest except ruby. i am sorry for being so demanding here...but i appreciate your help.

It's an ideal job for a grok filter.