使用elasticsearch和filebeats如何只在某些文件上执行管道?

uqcuzwp8  于 2021-06-13  发布在  ElasticSearch
关注(0)|答案(1)|浏览(301)

我只想在日志路径包含某个关键字的文件上运行管道,如何在管道中执行此操作?
管道(删除了我的模式和不相关的模式):

{
  "description" : "...",
  "processors": [
    {
      "grok": {
        "if": "ctx['log']['file']['path'].value.contains('keyword')",
        "field": "message",
      }
    }
  ]
}

在kibana中,我看到log.file.path作为元数据可用,我只想在管道包含关键字时运行管道,但由于if语句,我得到了一个运行时错误。
谢谢你的帮助!
编辑:我认为问题在于如何访问log.file.path字段,因为我不知道如何从这里正确引用它。

ncecgwcz

ncecgwcz1#

你也许可以使用drop处理器https://www.elastic.co/guide/en/elasticsearch/reference/current/drop-processor.html

"drop": {
   "if": "ctx.log.file.path.contains('keyword');"
}

你可以在这里找到更多复杂的例子:https://www.elastic.co/guide/en/elasticsearch/reference/master/ingest-conditional-complex.html

相关问题