Remove Unused Streams
Cadence Monthly
Sites developmentproduction
Initial | Recurring | |
---|---|---|
Estimated Time | 2 min | 2 min |
Benefits:
- Decrease maintenance
- Increase focus
Goal
There are several reasons why empty streams may be present in a Qlik environment. Sometimes, applications are moved from one stream to another and the admin doesn’t notice that the former stream is now empty. Other times, streams are created in anticipation of new applications being published to them, yet none ever actually get published. It is always a good practice to periodically check on the validity of the streams and to remove those that are deemed unnecessary.
Table of Contents
- QMC - Manually Check Published Apps For Each Stream
- Get List of Unused Streams (Qlik CLI for Windows)
QMC - Manually Check Published Apps For Each Stream
In the QMC, select Streams:
To view all applications that were published to a specific stream, select the stream name and enter into edit mode.
In Edit mode, select the Apps tab.
Applications that were published to this stream will now be visible.
This process should be repeated for each Stream to find unused streams.
If there is a considerable quantity of streams, consider the Qlik CLI for Windows method.
Get List of Unused Streams (Qlik CLI for Windows)
The below script snippet requires the Qlik CLI for Windows.
Streams should always be removed manually. The below script is only used to identify what streams are empty.
Script
# Script to find empty streams
################
## Parameters ##
################
# Assumes default credentials are used for the Qlik CLI for Windows Connection
# machine name
$computerName = 'machineName'
# leave empty if windows auth is on default VP
$virtualProxyPrefix = '/default'
# directory for the output file
$filePath = 'C:\tmp2\'
# desired filename of the output file
$fileName = 'empty_streams'
# desired format of the output file (can be 'json' or 'csv')
$outputFormat = 'json'
################
##### Main #####
################
# create filePath
if (Test-Path $filePath) {
} else {
New-Item -ItemType directory -Path $filePath | Out-Null
}
# set the output file path
$outFile = ($filePath + $fileName + '_' + $(Get-Date -f "yyyy-MM-dd") + '.' + $outputFormat)
# if the output file already exists, remove it
if (Test-Path $outFile)
{
Remove-Item $outFile
}
# set the computer name for the Qlik connection call
$computerNameFull = ($computerName + $virtualProxyPrefix).ToString()
# connect to Qlik
Connect-Qlik -ComputerName $computerNameFull -UseDefaultCredentials -TrustAllCerts | Out-Null
# GET all streams
$streamJson = Get-QlikStream -raw
# GET all applications, and then get all unique stream ids
$appStreamIds = Get-QlikApp -filter "published eq true" | foreach{$_.stream.id} | Sort-Object | Get-Unique
# compare both lists to see if any stream ids belong to no apps
$emptyStreamIds = ($streamJson | foreach{$_.id}) | ?{$appStreamIds -notcontains $_}
# if there are any empty streams, retain the full detail of them
$streamEmptyJson = $streamJson | ?{$emptyStreamIds -contains $_.id}
# see if there are any empty streams
(&{If($emptyStreamIds.count) {$("Empty Streams Found: " + $emptyStreamIDs.count); $streamEmptyJson} Else {"No Empty Streams Found"}})
# if there are any empty streams, write them to $outfile
If ($emptyStreamIds.count) {
(&{If($outputFormat.ToLower() -eq 'csv') {
$streamEmptyJson | ConvertTo-Csv -NoTypeInformation | Set-Content $outFile
} Else {
$streamEmptyJson | ConvertTo-Json | Set-Content $outFile
}
})
}
Tags
#monthly
#asset_management
#streams