Custom plugin doesn't autoRefresh when added to a dashboard

Hi
I developed a custom plugin for Kibana 7.17.0 and when I enable the autoRefresh in the Visualization editor page it works ok, but when I add the custom plugin to an empty dashboard it doesn't refresh when autoRefresh is enabled in the dashboard

Also, I noticed that if besides the custom plugin I add a default Kibana plugin like "Metric" of "Cloud Tag" to the dashboard, the custom plugin starts to autoRefresh as expected.

I see that not all of Kibana default plugins work with the dashboard autoRefresh, for example the Markdown plugin autoRefreshes in the editor but not when added to a dashboard.

Besides calling the handler.done after the custom plugin is rendered, is there anything additional I need to implement in the custom plugin to make it work with the autoRefresh of the dashboards?

Your plugin needs to re-fetch data manually. It can learn when it's time to fetch data with Autorefresh API

I was able to include the autoRefreshFetch code in my plugin and still the auto refresh loop only executed once when the plugin is inside a dashboard.

I debugged the code and in auto_refresh_loop.ts I saw that the following condition never happened, so the counter didn’t restart

if (pendingDoneCount === 0) {

start();

}

In the end I found out that the issue is happening in this file https://github.com/elastic/kibana/blob/7.17/src/plugins/dashboard/public/application/lib/sync_dashboard_filter_state.ts , in this section of the code:

// best way in a dashboard to estimate that panels are updated is to rely in search session service state waitUntilNextSessionCompletes$(search.session).pipe(finalize(done))

The session needs to be marked as complete, and after that the auto_refresh_loop done method is called. I found out that in the timeline plugin they are calling trackSession and untrackSession and this triggers changing the session state to complete, see kibana/timelion_request_handler.ts at 7.17 · elastic/kibana · GitHub

After calling those methods in my code the auto refresh worked and I didn’t have to call the autoRefresh API. The way that Kibana handles the dashboard session was affecting the autoRefresh logic, not sure if this only happens in Kibana 7.17.0

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.