Logstash配置,"如果字符串包含......"

A_E*_*ric 8 logstash logstash-grok logstash-configuration

所以,我们假设我的日志行的一部分看起来像这样:

GET /restAPI/callMethod1/8675309
Run Code Online (Sandbox Code Playgroud)

GET匹配一个http方法,得到提取,余数匹配一个URI,并且也被提取.现在在logstash配置中让我们假设我想做这样的事情......

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

有办法做到这一点吗?如果是这样,我该怎么做呢?

谢谢

Val*_*Val 23

你可以通过使用这样的=~(regexp)运算符来实现它(参见条件):

if [METHOD] == "GET" {
  if [URI] =~ /restAPI\/callMethod1/ {
     ...
Run Code Online (Sandbox Code Playgroud)