fix(alert): keep datasource in alert rule export/import - #4264
Open
orangeCatDeveloper wants to merge 4 commits into
Open
fix(alert): keep datasource in alert rule export/import#4264orangeCatDeveloper wants to merge 4 commits into
orangeCatDeveloper wants to merge 4 commits into
Conversation
Exported alert rules dropped the datasource (query language) field because AlertDefineDTO lacked it, so re-imported periodic rules could not execute. Fixes apache#4256.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What's changed?
Fixes #4256.
Exported alert rules (JSON / YAML / Excel) dropped the
datasourcefield (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:AlertDefineDTOlacked the field, andBeanUtils.copyPropertiessilently dropped it in both directions.This adds
datasourcetoAlertDefineDTO(JSON / YAML pick it up automatically) and appends aDatasourcecolumn 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
Add or update API