Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Elasticsearch rule builder broken / Elasticsearch聚合规则构造错误 #1362

Open
stevapple opened this issue Mar 18, 2025 · 0 comments
Open

Comments

@stevapple
Copy link

stevapple commented Mar 18, 2025

夜莺后端支持使用 ES 聚合规则,但是当数值提取策略设置为聚合类型(即不为 count)时,前端所示的 Field key 字段未与 value.field 产生双向关联,即:

  1. 当后端返回的规则设置了 value.field 时,前端无法正确将其显示在输入框中;
  2. 在前端输入框输入了目标值后,无法将其正确传给后端,亦无法使用“数据预览”。
Image

Related: ccfos/nightingale#2547

示例规则:

[
  {
    "cate": "elasticsearch",
    "name": "系统内存用量大于10%",
    "note": "触发值:{{.TriggerValue}} 主机:{{index $labels \"host.name\"}}",
    "prod": "logging",
    "algorithm": "",
    "algo_params": null,
    "delay": 0,
    "severity": 0,
    "severities": [
      2
    ],
    "disabled": 0,
    "prom_for_duration": 60,
    "prom_ql": "",
    "rule_config": {
      "anomaly_trigger": {
        "algo_params": {
          "lower_bound": 1,
          "lower_times_num": 1,
          "seasonal_duration": 86400,
          "upper_bound": 1,
          "upper_times_num": 1
        },
        "severity": 2
      },
      "exp_trigger_disable": false,
      "nodata_trigger": {
        "enable": false,
        "resolve_after": 1800,
        "resolve_after_enable": false,
        "severity": 2
      },
      "queries": [
        {
          "date_field": "@timestamp",
          "group_by": [
            {
              "cate": "terms",
              "field": "host.name",
              "params": [
                {
                  "alias": "",
                  "query": ""
                }
              ]
            }
          ],
          "index": ".ds-metrics-system.memory-server-*",
          "index_type": "index",
          "interval": 300,
          "keys": {
            "labelKey": "",
            "metricKey": "",
            "valueKey": ""
          },
          "prom_ql": "",
          "ref": "A",
          "severity": 2,
          "unit": "percentUnit",
          "value": {
            "field": "system.memory.used.pct",
            "func": "avg"
          }
        }
      ],
      "triggers": [
        {
          "exp": "$A > 0.1",
          "expressions": [
            {
              "comparisonOperator": ">",
              "logicalOperator": "&&",
              "ref": "A",
              "value": 0.1
            }
          ],
          "join_ref": "A",
          "mode": 0,
          "recover_config": {
            "judge_type": 1
          },
          "severity": 2
        }
      ]
    },
    "event_relabel_config": null,
    "prom_eval_interval": 15,
    "enable_stime": "00:00",
    "enable_stimes": [
      "00:00"
    ],
    "enable_etime": "00:00",
    "enable_etimes": [
      "00:00"
    ],
    "enable_days_of_week": [
      "0",
      "1",
      "2",
      "3",
      "4",
      "5",
      "6"
    ],
    "enable_days_of_weeks": [
      [
        "0",
        "1",
        "2",
        "3",
        "4",
        "5",
        "6"
      ]
    ],
    "enable_in_bg": 0,
    "notify_recovered": 1,
    "notify_channels": [],
    "notify_repeat_step": 60,
    "notify_max_number": 0,
    "recover_duration": 0,
    "callbacks": [],
    "runbook_url": "",
    "append_tags": [],
    "annotations": {},
    "extra_config": {
      "enrich_queries": []
    },
    "uuid": 0,
    "cur_event_count": 2,
    "update_by_nickname": "超管",
    "cron_pattern": "@every 15s",
    "notify_rule_ids": [],
    "notify_version": 1
  }
]
jsers added a commit that referenced this issue Mar 19, 2025
jsers added a commit that referenced this issue Mar 19, 2025
jsers added a commit that referenced this issue Mar 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant