Logstash pattern not working


(nivetha) #1

I have to match all m3u8 content as hls and others as pdl, but only the else part is working (displaying pdl)
Below is my code
filter{
if[Content] == "*.m3u8"
{
mutate {
add_field => [ "TrafficType", "hls" ]
}
}
else
{
mutate {
add_field => [ "TrafficType", "pdl" ]
}
}
}
Any other way to make this.


(Magnus B├Ąck) #2

You're a bit short on details, but it seems you're trying to use wildcards with the equality operator (==) but it doesn't support that. You need to use regexp matches.

filter {
  if [Content] =~ /\.m3u8$/ {
    ...
  } else {
    ...
  }
}

I'm not sure my example uses a correct regexp since I don't know what your Content field contains, but you should get the idea.


(nivetha) #3

thanks magnusbaeck . working fine


(system) #4