Alerting: use raw query data in provisioning to bypass interpolation of macros (#54293) (#54357)

(cherry picked from commit a932428057)

Co-authored-by: Jean-Philippe Quéméner <JohnnyQQQQ@users.noreply.github.com>
This commit is contained in:
Grot (@grafanabot)
2022-08-26 18:07:47 -04:00
committed by GitHub
co-authored by Jean-Philippe Quéméner
parent 867c695646
commit 200a901829
@@ -151,7 +151,12 @@ func (queryV1 *QueryV1) mapToModel() (models.AlertQuery, error) {
// in json.RawMessage. We do this as we cannot use
// json.RawMessage with a yaml files and have to use
// JSONValue that supports both, json and yaml.
encoded, err := json.Marshal(queryV1.Model.Value())
//
// We have to use the Raw field here, as Value would
// try to interpolate macros like `$__timeFilter`, resulting
// in missing macros in the SQL queries as they would be
// replaced by an empty string.
encoded, err := json.Marshal(queryV1.Model.Raw)
if err != nil {
return models.AlertQuery{}, err
}