Hi all, I’m trying to embed pre-prepared Grafana dashboards (iframes or otherwise) into an application* and need some means to interact programmatically with those dashboards. Typical interaction will include changing time interval, template variables and to listening on mouse over events to read the current timestamp. Is there a structured way to do that or do I need to dig into the dashboard internals to make this interaction happen? I know I can reload the whole iframe with new url-params but that makes it clunky for the user, I just want to make the dashboards reload their dataseries with new values…
*) the application is providing a view of a complex telecom system, an essential part is to provide interactive statistics as an integrated part of the application. The dashboards are “only” used to present data, as opposed to design dashboards/graphs in the application.
There is nothing built into Grafana for this use case. You can access an iFrame’s content with JavaScript (as long as you obey all the cross origin rules). Then you can navigate to a page using Angular $location. It does not cause a full page reload when the browser URL is changed.
I’m also interested in this point - I’m specifically interested in understanding when there has been a change in the embedded grafana dashboard (eg a change in the time period that is displayed) and how the web app can know about this.
I guess the solution is to listen to events - if so, any pointers to a list of grafana events?
add listeners to the Angular app to detect activity within the Grafana embedded iframe - we listened for click, keyup and popstate events
on activity, perform a check to see if there is a URL change in the Grafana iframe
if there is a change, grab the from and to fields from the URL and do whatever magic you need to…
It is probably possible to have more sensible listeners, tuned to specific activity within Grafana, but this approach worked fine for us in a prototype setting.