Configuring SAS Viya for ESM

Once the ESM Server and Agent components are installed, some additional configuration is required to integrate ESM monitoring with the various SAS Viya components.

Ansible playbooks

To assist with the configuration changes required for ESM integration with SAS Viya, Boemska provide a set of Ansible playbooks. We recommend that these are used with the assistance of Boemska Support. For basic integration with the SAS Viya microservices and SPRE runtimes, follow the steps below.

Viya Microservices

Instances of microservices can be configured to report in to ESM automatically by modifying the sas_check_pid() function in /opt/sas/viya/home/lib/envesntl/sas-init-functions. Add the following code after the result=0 # is running (typically line 125):

Values need to be updated

The snippet below contains an incomplete path starting with ###. Please update this line for your environment.

# ESM CONFIG START
export ESMHOME=###/path/to/esm-agent
export esmfuncfile=$ESMHOME/addPid.sh
if [ -f "$esmfuncfile" ]; then
  source $esmfuncfile

  esmthislogloc=${SASLOGROOT}/${SASPRODNAME}/${SASINSTANCE}/
  # uncomment this for logfile tracking
  esmservicelogfile="${esmthislogloc}$(ls -t $esmthislogloc | head -n1)"

  esmReportPid $pid "${SASPRODNAME}" "viya" "${esmservicelogfile}" "${SASINSTANCE}"
fi
# ESM CONFIG END

SPRE Sessions

Configuring SPRE workspace servers is similar to configuring a SAS9 Workspace Server instance.

In order to associate SAS sessions to their parent server types we need to configure some ESM environment variables. Add the following snippet to the following files:

  • /opt/sas/viya/config/etc/workspaceserver/default/workspaceserver_usermods.sh
  • /opt/sas/viya/config/etc/connectserver/default/connectserver_usermods.sh
  • /opt/sas/viya/config/etc/batchserver/default/batchserver_usermods.sh

Update values

The snippet below contains an incomplete path starting with ###. Please update this line for your environment.

# ESM CONFIG START

export ESMBASEDIR=###/pub/esm/esm-agent
. $ESMBASEDIR/conf/esmconfig.sh
# set the active flag as 1 for active, 0 for inactive
export ESMACTIVE=1
# This is the name given to non-job sessions (for example)
export ESMSESSIONNAME=####SAS-Studio|SAS-Connect|Batch
export ESMSESSIONTYPE=###WS|CS|Batch
# ESM CONFIG END

And then source the integration macros via each server's autoexec_usermods.sas:

/* ESM CONFIG START */
%let ESMBASEDIR=%SYSGET(ESMHOME);
%include "&ESMBASEDIR/sasautos/esmtags.sas";
/* ESM CONFIG END */

Compute Server Sessions

The compsrv configuration does not have a shell script in the configuration directory from which it is executed. As such, we need to configure the required ESM environment variables differently. To do this we will use the server's autoexec_usermods.sas file /opt/sas/viya/config/etc/compsrv/default/autoexec_usermods.sas. Add the following lines modifying the ESMBASEDIR for your environment:

/* ESM CONFIG START */
options set=ESMACTIVE=1;
options set=ESMBASEDIR="/pub/esm/esm-agent";
options set=ESMSESSIONTYPE="CMP";
options set=ESMSESSIONNAME="compsrv_default";
options set=LOGPATH="/opt/sas/viya/config/var/log/compsrv/default/";
%include "%sysget(ESMBASEDIR)/sasautos/esmtags.sas";
/* ESM CONFIG END */

JES Job Name

Minimum version requirement

The minimum version of ESM tags required for this is 1.27 and startjes.sas and endjes.sas v1.0. Please contact Boemska support for these files.

If you are using the SAS Job Execution Service to execute jobs then it can be very useful to be able to search for and track the performance of those jobs. With a small inclusion in the JESBEGIN and JESEND macros from SAS, ESM can track and measure JES jobs specifically while enabling extended searching and filtering in the ESM user interface.

  1. Ensure that you have completed the Compute Server configuration above.
  2. After making a backup, modify jesbegin.sas in /opt/sas/spre/home/SASFoundation/sasautos putting the following lines just before the closing %mendtag:

    /* ESM CONFIG START */
    %include "%sysget(ESMBASEDIR)/sasautos/startjes.sas";
    /* ESM CONFIG END */
    

  3. After making a backup, modify jesend.sas in /opt/sas/spre/home/SASFoundation/sasautos putting the following lines just before the options nonotes; (circa line 51)

    /* ESM CONFIG START */
    %include "%sysget(ESMBASEDIR)/sasautos/endjes.sas";
    /* ESM CONFIG END */