mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
feat(test metrics): fixed issue with built in Grafana test data source, fixes #5299
This commit is contained in:
parent
36b0802789
commit
67ad903556
@ -12,7 +12,7 @@ import (
|
||||
"github.com/grafana/grafana/pkg/util"
|
||||
)
|
||||
|
||||
func GetTestMetrics(c *middleware.Context) {
|
||||
func GetTestMetrics(c *middleware.Context) Response {
|
||||
from := c.QueryInt64("from")
|
||||
to := c.QueryInt64("to")
|
||||
maxDataPoints := c.QueryInt64("maxDataPoints")
|
||||
@ -37,7 +37,7 @@ func GetTestMetrics(c *middleware.Context) {
|
||||
result.Data[seriesIndex].DataPoints = points
|
||||
}
|
||||
|
||||
c.JSON(200, &result)
|
||||
return Json(200, &result)
|
||||
}
|
||||
|
||||
func GetInternalMetrics(c *middleware.Context) Response {
|
||||
|
@ -200,6 +200,11 @@ class MetricsPanelCtrl extends PanelCtrl {
|
||||
this.panel.snapshotData = result.data;
|
||||
}
|
||||
|
||||
if (!result || !result.data) {
|
||||
console.log('Data source query result invalid, missing data field:', result);
|
||||
result = {data: []};
|
||||
}
|
||||
|
||||
return this.events.emit('data-received', result.data);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user