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

This commit is contained in:
Jean-Philippe Quéméner
2022-08-26 23:54:30 +02:00
committed by GitHub
parent 49b1182f34
commit a932428057

View File

@@ -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
}