mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Prometheus/Alerting: handle datasource.timeRange is nil case (#37888)
This commit is contained in:
parent
5ab8d6a3b9
commit
668f397a8e
@ -85,9 +85,18 @@ func newInstanceSettings() datasource.InstanceFactoryFunc {
|
|||||||
return nil, errors.New("no http method provided")
|
return nil, errors.New("no http method provided")
|
||||||
}
|
}
|
||||||
|
|
||||||
timeInterval, ok := jsonData["timeInterval"].(string)
|
// timeInterval can be a string or can be missing.
|
||||||
if !ok {
|
// if it is missing, we set it to empty-string
|
||||||
return nil, errors.New("invalid time-interval provided")
|
|
||||||
|
timeInterval := ""
|
||||||
|
|
||||||
|
timeIntervalJson := jsonData["timeInterval"]
|
||||||
|
if timeIntervalJson != nil {
|
||||||
|
// if it is not nil, it must be a string
|
||||||
|
timeInterval, ok = timeIntervalJson.(string)
|
||||||
|
if !ok {
|
||||||
|
return nil, errors.New("invalid time-interval provided")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mdl := DatasourceInfo{
|
mdl := DatasourceInfo{
|
||||||
|
Loading…
Reference in New Issue
Block a user