Live: broadcast events when dashboard is saved (#27583)

Co-authored-by: kay delaney <45561153+kaydelaney@users.noreply.github.com>
Co-authored-by: Torkel Ödegaard <torkel@grafana.org>
This commit is contained in:
Ryan McKinley
2020-10-01 10:46:14 -07:00
committed by GitHub
co-authored by kay delaney Torkel Ödegaard
parent 44c9aea28c
commit 8a5fc00330
28 changed files with 980 additions and 213 deletions
+11
View File
@@ -262,6 +262,17 @@ func (hs *HTTPServer) PostDashboard(c *models.ReqContext, cmd models.SaveDashboa
}
}
// Tell everyone listening that the dashboard changed
if hs.Live != nil {
err := hs.Live.GrafanaScope.Dashboards.DashboardSaved(
dashboard.Uid,
c.UserId,
)
if err != nil {
hs.log.Warn("unable to broadcast save event", "uid", dashboard.Uid, "error", err)
}
}
c.TimeRequest(metrics.MApiDashboardSave)
return JSON(200, util.DynMap{
"status": "success",
+1 -5
View File
@@ -79,15 +79,11 @@ func (hs *HTTPServer) Init() error {
// Set up a websocket broker
if hs.Cfg.IsLiveEnabled() { // feature flag
node, err := live.InitalizeBroker()
node, err := live.InitializeBroker()
if err != nil {
return err
}
hs.Live = node
// Spit random walk to example
go live.RunRandomCSV(hs.Live, "grafana/testdata/random-2s-stream", 2000, 0)
go live.RunRandomCSV(hs.Live, "grafana/testdata/random-flakey-stream", 400, .6)
}
hs.macaron = hs.newMacaron()