fix: include full query data in alert rule get response#733
Open
hanks wants to merge 1 commit intografana:mainfrom
Open
fix: include full query data in alert rule get response#733hanks wants to merge 1 commit intografana:mainfrom
hanks wants to merge 1 commit intografana:mainfrom
Conversation
The alerting_manage_rules get operation only returned a querySummary (ref_id, datasource_uid, expression) which discards datasource-specific fields like Graphite 'target', 'datasource', 'textEditor', and OpenSearch 'bucketAggs', 'metrics', 'queryType'. This made it impossible to round-trip get -> update without silently losing query data for non-PromQL datasources. Add a 'data' field to alertRuleDetail that contains the full models.AlertQuery slice from the provisioning API response, preserving all datasource-specific model fields alongside the existing summary. Fixes grafana#732
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.
Summary
The
alerting_manage_rulesgetoperation returns only aquerySummary(ref_id,datasource_uid,expression) for each query, discarding the full query model from the provisioning API. This makesget->updateround-trips silently lose datasource-specific fields for non-PromQL datasources (Graphite, OpenSearch, Elasticsearch, etc.).Fixes #732
Changes
Data []*models.AlertQueryfield toalertRuleDetailstructDatafromprovisioned.DatainmergeRuleDetail, preserving full query models alongside the existingQueriessummarytarget,textEditor,datasource) survive in theDatafieldmergeRuleDetailtest verifyingDatais populated for Prometheus queriesWhy both
QueriesandData?Queries(summary) is compact and useful for LLM context — shows ref_id, datasource, and expression at a glanceData(full) contains the completemodels.AlertQuerywith all model fields, enabling safe round-trip updatesRemoving
Querieswould be a breaking change for existing consumers. AddingDataalongside is backward-compatible.Test Plan
go vet ./tools/passesgo test ./tools/— all unit tests passTestMergeRuleDetail/Data_preserves_full_Graphite_query_model_for_round-trippingmerges_provisioned_config_with_runtime_statenow verifiesDatafieldNote
Low Risk
Low risk, additive API response change that preserves existing
queriesbehavior while returning additionaldatapayload for round-tripping; main risk is unexpected larger responses for consumers that deserialize strictly.Overview
The
alerting_manage_rulesgetresponse now includes full provisioning query payloads (data: []*models.AlertQuery) in addition to the existing compactqueriessummaries, preventing loss of datasource-specific query fields duringget→updateround-trips.mergeRuleDetailnow copiesprovisioned.Datainto the newalertRuleDetail.Datafield, and unit tests were extended to assert round-tripping for Prometheus queries and a Graphite query model (e.g.,target,textEditor,datasource).Reviewed by Cursor Bugbot for commit 5bc6d44. Bugbot is set up for automated code reviews on this repo. Configure here.