alerting: set model refID if missing/mismatch (#114441)
This commit is contained in:
@@ -165,6 +165,21 @@ func (aq *AlertQuery) setMaxDatapoints() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// setRefID sets the model refId if it's missing or invalid
|
||||
func (aq *AlertQuery) setRefID() error {
|
||||
if aq.modelProps == nil {
|
||||
err := aq.setModelProps()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
if refID, ok := aq.modelProps["refId"].(string); !ok || refID != aq.RefID {
|
||||
aq.modelProps["refId"] = aq.RefID
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (aq *AlertQuery) GetMaxDatapoints() (int64, error) {
|
||||
err := aq.setMaxDatapoints()
|
||||
if err != nil {
|
||||
@@ -256,6 +271,11 @@ func (aq *AlertQuery) GetModel() ([]byte, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err = aq.setRefID()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err = aq.setIntervalMS()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
Reference in New Issue
Block a user