812 Views
5 minutes read
Categories
Tableau

Archive Logs On Tableau Server Using Ziplogs

Tableau server is widely used as a collaborating platform, data analytics and many more. It is a product from Tableau, it means you can use the functionality of Tableau, without needing to always be downloading and opening workbooks to open with Tableau desktop.

Tableau server can connect to any data source, enables everyone to see and understand data in an organization in the form of charts, workbooks, and dashboards, etc.

As like any operational platform, Tableau Server generates log files for all its activities as a normal functionality. Sometime the Logs files may fill up your server disk causing the server performance issue. It is always advisable not to clean up the logs as those may require for troubleshooting issues of Tableau Server. The focus of this article is how best to archive such log files without deleting them, thereby protecting vital references.

The goal is to archive the Tableau server logs and move them to the outside of the server to free up the disk space.

Tableau Server has a functionality to generate a snapshot of log files for archival purposes. This blog describes a step by step procedure to archive the log files to an off-server storage location before deleting them from original location.

To create a snapshot archive of Tableau Server log files we used the “tsm maintenance ziplogs” command on the below script. You need to automate the process by running this script on a schedule to reduce administrative overhead.

Before you begin:

Check current status and Log file size of Tableau Server

Check the current status of the Tableau server whether all the Services are running.

Check the current log folder size on the below-mentioned path –

<Drive>\Program Files\tableau\Tableau Server\data\tabsvc\Logs
The <Drive> is where you installed Tableau Server

PowerShell script for Logs Archive

Here is a PowerShell script to archive the log files. Copy the script and create a “.ps1” file. The following two-parameter needs to be changed as per your environment.

  • a) $FilePath – It is the path to the file where the password for Tableau Service Account is available
  • b) $netdir – This the network path where you want to move the log archives.
$FilePath = "E:\TableauBackup\BackupScript\cred.txt"

#Change Username appropriately, remembering to add the correct Domain and a \ to the username
$Username = "Domain\TableauServiceAccount"
$PwdText= Get-Content $FilePath

#Write-host $PwdText
$encryptedCred = $PwdText | ConvertTo-SecureString -AsPlainText -force
$cred = New-Object System.management.Automation.PsCredential($Username, $encryptedCred)

<#
    At this point, you can substitute the following for the password in any tsm command
    $cred.GetNetworkCredential().Password
#>

$Pass = $cred.GetNetworkCredential().Password
tsm login -u "$Username" -p "$Pass"
$Pass = ""
tsm status -v

#Create the file name & intialize the Backup directory, Network directory
$FileName = Get-Date -uformat "LogBackup-%Y-%m-%d"
$bakdir = "E:\Program Files\Tableau\Tableau Server\data\tabsvc\files\log-archives"
$netdir = "\\Network path\Log-archives\"

# Going inside Tabsvc folder
cd "E:\Program Files\Tableau\Tableau Server\packages\tabsvc.20182.18.0627.2230\"

#Zip the logs
tsm maintenance ziplogs -l -f $FileName

$FileName=$FileName+".zip" 

# Copy to Network Backup folder
copy-item $bakdir\$FileName $netdir\$FileName

# Cleanup local backup -- delete date-stampled file, since this has been uploaded 
remove-item $bakdir\$FileName

#Clean up old log files, cache, etc.
tsm maintenance cleanup

# Logs files retention steps

#Specify the number of days to retain log files.
$Retain = “60”

# Removes log files in the specified log folder directory according to the number of days specified to retain the log files.

Get-ChildItem $netdir -recurse | where {$_.Lastwritetime -lt (date).adddays(-$Retain)} | Remove-Item -Force

Create a Task on Task scheduler

Now that the script is ready, it needs to be configured in the Tableau server such that it runs on a schedule. Create a task on Task scheduler to run the script and choose the schedule. The following parameters can also be set, e.g. user context, specifying a weekly schedule, etc. All such details and more are given in the following screenshots.

Archive Logs On Tableau Server Using Ziplogs
Archive Logs On Tableau Server Using Ziplogs
Archive Logs On Tableau Server Using Ziplogs
Archive Logs On Tableau Server Using Ziplogs
Archive Logs On Tableau Server Using Ziplogs

Conclusion

It’s a routine administrative process in any live Tableau production system that stale data needs to be backed up and flushed out to secondary storage. In this particular case, the log files were identified as the prime candidate due to its less immediate use and growth. This automated process achieves the same quickly and keeps the live environment fresh and agile minimizing any unpredictable choking condition. Follow this and reduce your headache!

LinkedinTwitterFacebook

Leave a Reply

Your email address will not be published. Required fields are marked *