【问题标题】:Using Elasticsearch and filebeats how do I only execute my pipeline on certain files?使用 Elasticsearch 和 filebeats 如何仅在某些文件上执行我的管道?
【发布时间】:2021-03-25 23:25:42
【问题描述】:

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

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

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

在 Kibana 中,我看到 log.file.path 可用作元数据,如果管道包含关键字,我只想运行它,但由于我的 if 语句而出现运行时错误。

感谢您的帮助!

编辑:我认为问题在于我如何尝试访问 log.file.path 字段,因为我不知道如何从这里正确引用它。

【问题讨论】:

    标签: elasticsearch kubernetes elastic-stack filebeat elasticsearch-painless


    【解决方案1】:

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

    【讨论】:

    • 我认为放置处理器会阻止文档在跳过时被索引?我希望它被索引而不是通过我的管道。
    • ok 只是没有被 grok 处理器处理?如果是这样,您可以尝试与 grok 处理器的 IF 中的“if”相同的合成器吗?
    猜你喜欢
    • 2022-01-20
    • 2017-08-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-10-08
    • 2021-07-24
    • 1970-01-01
    相关资源
    最近更新 更多