Skip to content

fix(alert): keep datasource in alert rule export/import - #4264

Open
orangeCatDeveloper wants to merge 4 commits into
apache:masterfrom
orangeCatDeveloper:fix/issue-4256-export-datasource
Open

fix(alert): keep datasource in alert rule export/import#4264
orangeCatDeveloper wants to merge 4 commits into
apache:masterfrom
orangeCatDeveloper:fix/issue-4256-export-datasource

Conversation

@orangeCatDeveloper

Copy link
Copy Markdown
Contributor

What's changed?

Fixes #4256.

Exported alert rules (JSON / YAML / Excel) dropped the datasource field (the "Query Language" selected in the UI, promql / sql), so re-imported periodic rules had an empty query language and could not execute. Root cause: AlertDefineDTO lacked the field, and BeanUtils.copyProperties silently dropped it in both directions.

This adds datasource to AlertDefineDTO (JSON / YAML pick it up automatically) and appends a Datasource column to the Excel export. The column is appended last so Excel files exported before this fix still import correctly.

Export of the same periodic rule, before and after (verified on a local instance):

     "alertDefine": {
+        "datasource": "promql",
         "enable": true,
         "expr": "cpu_usage{instance=\"server1\"} > 80",
         "name": "test",
         "period": 300,
         ...
     }

Checklist

  • I have read the Contributing Guide
  • I have written the necessary doc or comment.
  • I have added the necessary unit tests and all cases have passed.

Add or update API

  • I have added the necessary e2e tests and all cases have passed.

Exported alert rules dropped the datasource (query language) field
because AlertDefineDTO lacked it, so re-imported periodic rules could
not execute. Fixes apache#4256.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Exported alert rule is missing the query language field, so importing it back doesn't work

2 participants