As most of you might already know, I’m a pretty big fan of making things simple and more automated in order to get data to the people. When someone has to muck around in an area that might take him/her away from their analytics ‘flow’, I see opportunity.
Enter the ‘refresh-my-tableau-datasource-via-Slack’ bits.
Why would we do this? Well, perhaps tabcmd isn’t on the Server or client. Or perhaps it’s easier to make an API call and post a message at the end of a pipeline rather than write to a file and do this. But wait, even better, it might be easier for an analyst and the like to just simply type a ‘Refresh: <some data source or twb>’ message into a Slack channel.
Before you think, ‘wow, this could escalate quickly’, rest assured there are checks and balances. Here’s a few that we’ve implemented:
- Only the owner of the twb/data source can refresh
- Can’t refresh more than 1x per max refresh time (you should already be keeping these stats)
- We log all of these in addition to our regular Tableau logging
Anyway, this is pretty easy to set up because of the early work with the ‘Reset my Tableau password via Slack’ bits.
- Tableau Server, of course
NOTE: For the one of the checks and balances mentioned above, you will want to limit the overuse of the extract refresh. For example, if someone gets excited and drops the TWB/Data source name in there 15 times in an hour, this code will prevent that from happening:
SELECT date_trunc('hour',created_at) - INTERVAL '7 hour' as &amp;quot;StartHour&amp;quot; ,COUNT(*) as &amp;quot;Total&amp;quot; ,AVG(EXTRACT(EPOCH FROM (completed_at-created_at))) as &amp;quot;TotalTime_Avg_Sec&amp;quot; ,AVG(EXTRACT(EPOCH FROM (completed_at-started_at))) as &amp;quot;RunTime_Avg_Sec&amp;quot; FROM background_jobs WHERE job_name LIKE 'Refresh Extracts' and title = '&amp;lt;your extract variable&amp;gt;' GROUP BY date_trunc('hour',created_at) - INTERVAL '7 hour'
After you’ve successfully triggered the extract, you can certainly send a message back to the user and/or notify them in the event of a potential extract refresh failure. Did I mention we have code for that?
For those interested in the nuts and bolts of the implementation, please don’t hesitate to let me know.