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

Using Elasticsearch and filebeats how do I only execute my pipeline on certain files?

我只想 运行 我的管道处理日志路径包含特定关键字的文件,我该如何在管道中执行此操作?

管道(删除了我的模式和模式,因为它不相关):

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

在 Kibana 中,我看到我有 log.file.path 可用作元数据,如果它包含关键字,我只想 运行 管道,但我收到 运行time 错误,因为我的 if 语句。

感谢您的帮助!

编辑:我认为问题在于我试图访问 log.file.path 字段的方式,因为我不知道如何从此处正确引用它。

您或许可以使用 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