Logstash config, "if string contains..."
Asked Answered
J

1

13

So, let's assume that I have a portion of a log line that looks something like this:

GET /restAPI/callMethod1/8675309

The GET matches a http method, and get's extracted, the remainder matches a URI, and also gets extracted. Now in the logstash config let's assume that I wanted to do something like this...

if [METHOD] == "GET" {
    if [URI] (CONTAINS <--Is there a way to do this?) =="restAPI/callMethod1"{
        ....

Is there some way to do this? If so how would I go about doing that?

Thanks

Job answered 18/8, 2016 at 16:8 Comment(0)
P
35

You can achieve it simply by using the =~ (regexp) operator like this (see conditionals):

if [METHOD] == "GET" {
  if [URI] =~ /restAPI\/callMethod1/ {
     ...
Pyrone answered 19/8, 2016 at 4:40 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.