启动 logstash 的 grok 过滤器出错

Error in grok filter which starting logstash

我有以下 logstash 配置文件

input {
  tcp {
    port => 12345
    codec => json
  }
}

filter {
  grok {
    break_on_match => true
    match => [
        "message", "%{TIMESTAMP_ISO8601:timestamp} (verbose|info|debug) (hostd|vpxa)",
    ]
    mutate {
      add_tag => "esxi_verbose"
    }
  }
}

if "esxi_verbose" in [tags] {
  drop{}
}

output {
      stdout { codec => rubydebug }
      elasticsearch { 
        hosts => ["localhost:9200"] 
        index => "logstash-%{+YYYY.MM.dd}"
      }
}

我正在尝试删除任何冗长的调试信息消息。当我启动 logstash 时,出现错误

[2019-03-03T16:53:11,731][ERROR][logstash.agent] Failed to execute action {:action=>LogStash::PipelineAction::Create/pipeline_id:main, :exception=>"LogStash::ConfigurationError", :message=>"Expected one of #, \", ', -, [, { at line 13, column 5 (byte 211) after filter {\n  grok {\n    break_on_match => true\n    match => [\n        \"message\", \"%{TIMESTAMP_ISO8601:timestamp} (verbose|info|debug) (hostd|vpxa)\",\n    "

谁能帮我看看我做错了什么。

您的配置有 3 个问题:

  1. grok 消息行末尾有一个逗号,它是 冗余
  2. 突变在 grok 过滤器中,但它应该会出现 在它之后
  3. 'if' 语句应该在 'filter' 部分。

这是更新后的工作配置:

input {
  tcp {
    port => 12345
    codec => json
  }
}

filter {
  grok {
    break_on_match => true
    match => [
        "message", "%{TIMESTAMP_ISO8601:timestamp} (verbose|info|debug) (hostd|vpxa)"
    ]
  }

  mutate {
    add_tag => "esxi_verbose"
  }

  if "esxi_verbose" in [tags] {
    drop{}
  }

}

output {
      stdout { codec => rubydebug }
      elasticsearch {
        hosts => ["localhost:9200"]
        index => "logstash-%{+YYYY.MM.dd}"
      }
}