Slack your Tableau Extract

Some background

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.

ts-slack-extract-
Sample  text coming across the wire

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.

 

 

The Tools

  • PowerShell
  • Logentries
  • Slack
  • Tableau Server, of course

 

Implementation

Create a Slack channel where all of this chatter will go and then with Logentries, set this up. After you’ve done that, run the code to make all the magic happen.

ts-slack-extract-1
Post in a Slack channel w/ name of TWB or Data Source

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;amp;quot;StartHour&amp;amp;quot;
,COUNT(*) as &amp;amp;quot;Total&amp;amp;quot;
,AVG(EXTRACT(EPOCH FROM (completed_at-created_at))) as &amp;amp;quot;TotalTime_Avg_Sec&amp;amp;quot;
,AVG(EXTRACT(EPOCH FROM (completed_at-started_at))) as &amp;amp;quot;RunTime_Avg_Sec&amp;amp;quot;
FROM background_jobs
WHERE job_name LIKE 'Refresh Extracts' and title = '&amp;amp;lt;your extract variable&amp;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.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s