Scripts that analyze Elasticsearch configurations and svi-indexer logging can enhance configuration and performance in SAS® Visual Investigator


Three Python programs can help you determine an optimal Elasticsearch indexer configuration, and you can also check the indexer logging for information about health. The key and the cert file must be generated prior to use of the script. These commands show how to do that:

cacert=/opt/sas/viya/config/etc/SASSecurityCertificateFramework/cacerts/
trustedcerts.pem

key=/opt/sas/viya/config/var/tmp/sgadminkey.pem
cert=/opt/sas/viya/config/var/tmp/sgadmincert.pem
/opt/sas/viya/home/SASSecurityCertificateFramework/bin/sas-crypto-management req-vault-cert --common-name "sgadmin" --vault-addr "https://host-name:port-number" --vault-cafile "${cacert}" --vault-token /opt/sas/viya/config/etc/SASSecurityCertificateFramework/tokens/elasticsearch-secure/default/vault.token --out-crt "${cert}" --out-form 'pem' --out-key "${key}"
 

Notes:

This first Python program, elasticsearch-diagnostic.py, collects diagnostic data. Provide the host and port information for your environment (if a port number is not provided, it defaults to 9200):

host=host-name
 

The following command runs the program:

python3 elasticsearch-diagnostic.py --host ${host} --key ${key} --cert ${cert} --cacert ${cacert} [--ephemeral]
 

The --ephemeral option results in the information being displayed on your screen. If you do not use the --ephemeral option, all the collected information is put in a compressed ZIP file. Here are the optional parameters that you can use with the command:

-h, --help                show this help message and exit
--host HOST              the host name of Elasticsearch (default: localhost)
--port PORT             the port of Elasticsearch (default: 9200)
--key KEY                 the key file (default: /opt/sas/viya/config/var/tmp/sgadminkey.pem)
--cert CERT             the cert file (default: /opt/sas/viya/config/var/tmp/sgadmincert.pem)
--cacert CACERT       the cacert file (default: /opt/sas/viya/config/etc/SASSecurityCertificateFramework/cacerts/trustedcerts.pem)
--insecure            disable certificate validation; --cacert is not used when this option is used
--timeout TIMEOUT   the timeout for requests in seconds (default: 30)
--ephemeral           write to stdout instead of tarball
--verbose, -v         increase output verbosity

The second Python program, cat_indices_analysis.py, uses indices content that is created from the elasticsearch-diagnostic.py program. If you ran the first script to stdout (the screen), you can copy and paste the indices information into a text file and use that file as input to this script. 

However, if you ran the first script without using the --ephemeral parameter, you need to extract the indices output file from the compressed ZIP file. The extracted indices file is in the form cat_indices_yyyy-mm-*.txt. 

This script analyzes output from the Elasticsearch /_cat/indices endpoint and warns you if it detects potential problems. The script will give both suggestions for remediation and an explanation of each problem. The script looks for the following:

The following example shows the command that runs the cat_indices_analysis.py program. Replace "path" with the correct information for your environment:

Python3 cat_indices_analysis.py path/cat_indices_2021-04-19T21_04_03.732590+00_00.txt
 

The third Python program, indexer_log_analysis.py, uses the indexer logging as input. The script analyzes Indexer logs and reports common problems. It will provide both an analysis of the problem and give suggested next steps to resolve (or help mitigate) the issue.

The script will look for the following:

The following example shows the command that runs the program. Replace path with the correct information for your environment:

python3 indexer_log_analysis.py path/sas-svi-indexer_2021-04-14_10-02-25.log
 

The source files for these programs are provided in the link below.

https://gitlab.sas.com/fsitactical/diagnostic-tools/-/tree/main?ref_type=heads