【问题标题】:How to use 2 conditions inside the elastic watcher如何在 elastic watcher 中使用 2 个条件
【发布时间】:2021-07-15 17:29:35
【问题描述】:

我是 ELK 的新手,我可以在 Elastic watchers 中使用 2 个条件吗?我从 data = 0 和 data = 1 之类的日志中获取一个字段,因此我需要使用该“数据”作为观察者内部的条件来详细说明事件。

提前致谢

【问题讨论】:

    标签: devops elastic-stack


    【解决方案1】:

    有很多解决方案。这是一个使用无痛脚本:

    [query sections...]
      },
      "condition": {
        "script": {
          "source": """
    def obj = ctx.payload.hits.hits.0;
    if (obj.data.value == 0 || obj.data.value == 1) {
        return true;
    }
    return false;
          """,
          "lang": "painless"
        }
      },
      "actions": {
    [actions sections to follow...]
    

    当然,我只是在制作 CTX 上下文数据路径。在示例中,我指的是第一个返回记录的“数据”字段。您必须弄清楚要检查的内容。一个常见的数据来自聚合,然后您将可以访问 ctx.payload.aggregations。*

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-05-04
      • 2014-03-06
      • 2021-05-20
      • 1970-01-01
      • 2013-06-14
      • 1970-01-01
      • 1970-01-01
      • 2019-09-01
      相关资源
      最近更新 更多