【问题标题】:Logstash config, "if string contains..."Logstash 配置,“如果字符串包含...”
【发布时间】:2016-08-18 16:08:34
【问题描述】:

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

GET /restAPI/callMethod1/8675309

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

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

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

谢谢

【问题讨论】:

    标签: logstash logstash-grok logstash-configuration


    【解决方案1】:

    您可以像这样使用=~ (regexp) 运算符来实现它(参见conditionals):

    if [METHOD] == "GET" {
      if [URI] =~ /restAPI\/callMethod1/ {
         ...
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2022-09-24
      • 2017-03-21
      • 1970-01-01
      • 2014-06-12
      • 1970-01-01
      • 2015-11-08
      • 2016-06-15
      相关资源
      最近更新 更多