The following instructions allows you to extract refresh data sources in the online Tableau server through exMon. This provides better insight of the refreshes and more control over the refresh schedule.

Extract Refresh in exMon

1. Start by saving the following python scripts to the C: drive.

Name of script:

import sys
import argparse

from API_Handler import APIHandler

# ----------------------------------------------------
# ----------------------------------------------------
# ----------------------------------------------------

parser = argparse.ArgumentParser(description='Bakvordur Datapump')
parser.add_argument('--user', required=True, help='Type of .')
parser.add_argument('--pw', required=True, help='Type of .')
parser.add_argument('--url', required=True, help='Type of .')
parser.add_argument('--site', required=True, help='Type of .')
parser.add_argument('--datasource', required=True, help='Type of .')
args = parser.parse_args()

pumpConfig = {}
pumpConfig['user'] = args.user
pumpConfig['pw'] =
pumpConfig['url'] = args.url
pumpConfig['site'] =
pumpConfig['datasource'] = args.datasource

# ----------------------------------------------------
# ----------------------------------------------------
# ----------------------------------------------------

apiHan = APIHandler(pumpConfig['user'], pumpConfig['pw'], pumpConfig['url'], pumpConfig['site'], pumpConfig['datasource'])

test = apiHan.RunRefresh()

temp = ''

Name of script:

import requests
import xml.etree.ElementTree as ET 
import time
import datetime

import tableauserverclient as TSC

class APIHandler(object):
    def __init__(self, user, pw, url, site, datasource):
        self.user = user = pw = site
        self.url = url 
        self.datasource = datasource


    def Initialize(self):
        tableau_auth = TSC.TableauAuth(self.user,,
        self.server = TSC.Server(self.url, use_server_version=True)

    def RunRefresh(self):
        all_datasources, pagination_item = self.server.datasources.get()

        for dSource in all_datasources:
            if == self.datasource:
                    datasource = self.server.datasources.get_by_id(
                    refreshed_datasource = self.server.datasources.refresh(datasource)
                except Exception as e:
                    print('Refresh failed with error: ' + str(e))

    def HandleRefreshWait(self, jobId):
        complete_time = None 
        counter = 0
        started = False
        sleep_timer = 10
        while complete_time is None: 
            extract =

            if str(extract._finish_code) == "0": 
                complete_time = (extract._completed_at).strftime('%Y-%m-%d %H:%M:%S') 
                if extract.started_at is None: 
                    print("Refresh has not started.") 
                    if started == False: 
                        print("Refresh started at " + (extract._started_at).strftime('%Y-%m-%d %H:%M:%S') + '.')
                        started = True
                    if counter == 0:
                        print("Refresh is running.")
                        print("Refresh is still running.")

                    counter += 1

            if complete_time is None: 

        refresh_time = counter*sleep_timer

2. Create a Package for the refresh extract for the data source. It is necessary to create a package for each data source.

3. In the extract refresh package put the following information in the Production - PROD command

  • Identify the Execution Connection
  • Establish the location of the python script in the command window, as well as the highlighted parameters that can be determined in the Tableau online server.
  • NOTE, we highly recommend using Global Parameter to hide the password used in the command window for increased security


Execution Example

  • site url and site name
The site url and site name are established in the online path of the Tableau online server


  • username and password
These parameters are used when signing into the Tableau online server


  • Data source name:

In the Tableau online server the name of the data source can be identified


Given that the python scripts have been located in C:\location\ the command for the Extract Refresh package will be as follows:

Finally save and deploy the package.

Command to copy.

Working directory: E:\Python36-32\

Command: E:\Python36-32\python.exe c:\Expectus\Tableau_Refresh_Extract\ --user "username" --pw "password" --url "site url" --site "site name" --datasource "datasource name"