SAS 9 Content Assessment is a very popular way to examine and document the content of a SAS 9.4 environment. Did you know you have similar functionality in SAS Viya? In this blog post, I will look at the inventory options in SAS Viya. In Viya 4 recent improvements have made scanning your environment and examining the configuration and content even easier. It is a recommended best practice to run a scan before and after any major changes in your Viya environment. For example, scan before and after a system migration, an update of the Viya software, before a backup, and after a restore, and before and after migrating content.
In this post, we will focus on Viya 4, but first, let us recap what is available on Viya 3.5.
In SAS Viya 3.5 the scanning functionality that collects the inventory data is provided by the inventory plug-in of the sas-admin
-line interface. The inventory plug-in of the CLI:
The Plan and Backup playbook is the way you run a scan, the playbook creates and publishes all the data that supports the Viya Inventory reports. I covered this process in the first part of this YouTube video. Recent updates to the playbook have added support for scanning a Viya 3.x multi-tenant environment.
In Viya 2022.09 and later inventory scanning in Viya 4 became easier. A Cronjob the sas-viya-inventory-collector makes it simple to scan and inventory the Viya 4 environment. The Cronjob also supports the ability to compare the two most recent scans. Additionally then Cronjob provides support. for scanning deployments that are multi-tenant and/or SCIM-enabled.
The Inventory Reports are delivered when Viya is installed, there are two reports available at Products > SAS Environment Manager > Dashboard
The reports are supported by data loaded into the SystemData CAS library by the scan process. Two tables hold the results of the most recent inventory scan.
To enable comparison after the second scan runs each scan also keeps a copy of the prior SASVIYAINVENTORY4 table. If you have run at least two scans you should also have the table SASVIYAINVENTORY4_PRIOR.
Scan functionality is delivered by the sas-viya-inventory-collector Kubernetes Cronjob. The Cronjob, by default, is not scheduled. Instead, it is delivered as a convenient way of performing a scan. The following command runs a scan by creating and running a Kubernetes job from the Cronjob. The new job is named sas-inventory-collector-job (you can give it any name).
kubectl create job --from=cronjob/sas-inventory-collector sas-inventory-collector-job
To follow the log as the job runs execute:
kubectl logs -l job-name=sas-inventory-collector-job -f | klog
Select any image to see a larger version.
Mobile users: To view the images, select the "Full" version at the bottom of the page.
The example scan will scan a non-multi-tenant environment. In a multi-tenant environment an inventory can be performed on a per-tenant basis by setting the tenant environment variable to the tenant name prior to running a scan.
kubectl set env cronjob/sas-inventory-collector TENANT=tenant_name
When the job is complete you can view the SAS Viya Inventory Report (more on the report later).
If you have run at least two scans you can do a comparison. The comparison scan will compare the most recent scan results to the previous scan results. To perform a comparison set the COMPARISON environment variable to true and create a job (When the job is completed it is a good practice to reset the environment variable.)
kubectl set env cronjob/sas-inventory-collector COMPARISON=true
kubectl create job --from=cronjob/sas-inventory-collector sas-inventory-comparison-job
kubectl set env cronjob/sas-inventory-collector COMPARISON-
Follow the job log:
kubectl logs -l job-name=sas-inventory-collector-comparison -f | klog
The output of the comparison scan process looks like this.
In a migration from Viya 3.x you can compare your new Viya 4 environment to the source Viya 3.x environment. In order to do this
To run a Viya 4 to 3 comparison, set the COMPARISON environment variable to migration and then run the job. The scan will compare the most recent Viya 4 scan results to the scan results that were migrated from Viya 3.5. When the job is completed it is a good practice to reset the environment variable.
kubectl set env cronjob/sas-inventory-collector COMPARISON=migration
kubectl create job --from=cronjob/sas-inventory-collector sas-inventory-comparison-job
kubectl logs -l job-name=sas-inventory-comparison-job -f | klog
kubectl set env cronjob/sas-inventory-collector COMPARISON-
The SAS Viya 4 Inventory Report surfaces the inventory results. The Status tab gives a summary of the scan results. Let's look at a couple of the useful Tabs on the report.
The CAS Inventory lists the defined CAS Libraries, the types of CAS Libraries, and the number of tables and file system size of each CAS Library.
The Object Inventory tab lists all the objects in the SAS Viya Environment. You can filter on Internal Objects versus Customer Created Objects. The screenshot shows a count and list of the Visual Analytics Reports in the Viya environment.
NOTE: if you have a report named "Viya Inventory Report" your system was most likely migrated from Viya 3 and that is the Viya 3 version of the report.
The SAS Viya Inventory Comparison report compares the two most recent scans or, if you have migrated from Viya 3.x it can compare to the scan results the Viya 3.x scan results. The report flags if the:
The inventory collector Cronjob makes it very easy to perform an inventory scan of a SAS Viya environment. The inventory reports surface the results of the scan. It is a recommended best practice to run a scan before and after any major changes in your Viya environment. For example, scan before and after migration from 3.5 or 4 to 4, an update of the Viya software, before a backup, and after a restore and before and after migrating content. The documentation for SAS Viya Inventory was recently updated and moved to the Tools area of the Viya Administration Guide.
SAS Viya Inventory Documentation
Find more articles from SAS Global Enablement and Learning here.
hello Gerry,
thank you for this article, now I know what for the inventory report is. After reading this blog, I have installed klog as well. However, I am not able to execute the inventory scan probably because of large number of audit entries. On request of our users which are interested to see who is reading the reports, we have set audit recording.level to high but we only retain 7 days of audit records. The inventory scan has scanned more than one million audit entries and then it has generated the following error at audit.entry 1086000:
kubectl -n viya logs -l job-name=sas-inventory-collector-job | klog
Defaulted container "sas-inventory-collector" out of: sas-inventory-collector, sas-certframe (init)
WARN 2023-09-25 12:43:48.720 +0000 [sas-inventory-collector] - Error invoking API /audit/entries 401 /audit/entries
INFO 2023-09-25 12:43:48.720 +0000 [sas-inventory-collector] - 1086000 inventory items collected /audit/entries
When I changed back the level of audit records to low, then I was able to execute the scan. The same happens when you have a lot of files in content. Is possible to make the inventory job to be able to perform also when there are a lot of items? Maybe you have some other advise or there is another reason. Thank you
I don't believe there is any documented limit on the scanning process. I will provide this feedback to the development team to see if they can address the problem.
Hi @GerryNelson ,
Thanks for sharing this article. I wasn't able to download the 'klog' filtering tool or even to locate the executable.
I searched the GitHub page of Technical Support, for instance, but to no avail.
- could you, please, provide a download link ?
Ronan
Thanks to a wonderful Learning Guide 😉 - SAS Viya Operations Course Notes, namely, I discovered its jq one-liner equivalent :
jq -R -r '. as $line | try (fromjson|"\(.level | ascii_upcase) \(.timeStamp) [\(.source)] \(.properties.sessionUser )\(.message)" ) catch $line | sub("null";"")'
Better defined as a function in .bashrc for further reuse:
fklog(){
jq -R -r '. as $line | try (fromjson|"\(.level | ascii_upcase) \(.timeStamp) [\(.source)] \(.properties.sessionUser )\(.message)" ) catch $line | sub("null";"")'
}
Hi @Ronan_Lincoln glad you found the function. We have also switched to using a similar function instead of log.
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
Data Literacy is for all, even absolute beginners. Jump on board with this free e-learning and boost your career prospects.