Skip to main content

SA Engine RE Configuration

SA Engine RE Startup Parameters

SA Engine RE startup parameters are specified in the application.properties configuration file, located in the same directory as the SA Engine RE utility.

Table of startup parameters:

ParameterDescriptionDefault Value
server.portThe port on which SA Engine RE will accept incoming connections.18080
spring.servlet.multipart.max-request-sizeMaximum file upload size in bytes.100000000
server.tomcat.max-http-form-post-sizeMaximum size for multipart/form-data requests in bytes.104857600
sme.FileRotatePeriodRequest data file rotation time in seconds.10000
sme.baseDataDirectory for storing request data files../data
sme.directoryPollerIntervalInterval for checking the request data file storage directory in seconds.50
sme.scriptConfigPathPath to the scripts.yaml configuration file../scripts.yaml
sme.LogStringSizeLog string size.300
sme.RapidDeleteWhether to delete request data files.True
sme.redis.urlAddress for connecting to Redis."127.0.0.1"
sme.redis.portPort for connecting to Redis.6379
sme.redis.passPassword for connecting to Redis.""
logging.file.pathPath for storing logs.logs
server.ssl.enabledWhether to use SSL/TLS for incoming connections.true
server.ssl.certificatePath to the public key (certificate) of the current SA Engine RE server in PKCS8 format./app/opensearch/config/node-cert.pem
server.ssl.certificate-private-keyPath to the private key of the current SA Engine RE server in PKCS8 format./app/opensearch/config/node-key.pem
server.ssl.trust-certificatePath to the Certificate Authority (CA) chain in PKCS8 format./app/opensearch/config/ca-cert.pem
server.ssl.client-authCertificate validation mode, can be need, none, want.need

General SA Engine RE Connection Settings

Table describing the general settings for connecting to SA Engine RE:

SettingDescriptionDefault ValueSetting Type
sme.core.remote_script.userUsername used to make requests to SA Engine RE.sme_re_userCluster Setting
sme.core.remote_script.passwordPassword of the user used to make requests to SA Engine RE.Keystore Setting
sme.core.remote_script.enable_sslFlag indicating whether to use SSL for connecting to SA Engine RE from the script command in search and in ScriptAction in the task scheduler.trueCluster Setting

Table describing cluster settings for connecting to SA Engine RE from the script command:

SettingDescriptionDefault Value
sme.core.remote_script.base_pathPath to the folder where scripts will be uploaded."/app/opensearch/utils/scripts/"
sme.core.remote_script.portPort on which SA Engine RE is running.18080
sme.core.remote_script.urlURL where SA Engine RE is running."https://127.0.0.1"
sme.core.remote_script.base_interpreter_nameDefault interpreter name to use the script command without the intr parameter."bash"
sme.core.remote_script.interpretersList of available interpreters, as an array of strings. String format: "interpreter name"::"path to interpreter".["python3::/app/opensearch/utils/python/bin/python3","bash::bash"]

Creating a Script

To use a script in search, you must place it in the folder specified in the sme.core.remote_script.base_path setting on all servers in the cluster, ensure the file is executable, and has opensearch:opensearch permissions.

To return data from the script for further processing in the search, output the result in JSON format.

Example for Python:

print(scriptResultJson)

If other commands are executed before the script command, their result is saved to a temporary file in the folder specified in sme.baseData. The name of this file will be passed to the script as a command-line argument.

Example for Python:

import sys

if __name__ == "__main__":
# open the file with data from the request
inputDataFile = open(sys.argv[1], "r")

# read the file with data from the request
inputData = inputDataFile.read()

inputDataFile.close() # close the file after reading

Information for Running Scripts in the Task Scheduler

Connecting to SA Engine RE from ScriptAction in the Task Scheduler

Settings can be retrieved via the following path:

GET _core/settings/job-scheduler

Table describing the settings for connecting to SA Engine RE from ScriptAction:

SettingDescriptionDefault Value
sme-re_portPort on which SA Engine RE is running.18080
sme-re_hostHost on which SA Engine RE is running."localhost"

Creating a Script

You can run any script in the task scheduler.

If you need to pass sensitive data to the script, you can use the environment variables feature. This feature allows you to store sensitive data in the keystore so that SA Engine RE adds them to environment variables when the script is run.

Algorithm for configuring environment variables:

  1. Store the necessary variables to be passed to the script in the keystore on all cluster servers, using the variable jobscheduler.script.pass.<variable_name>
  2. Specify in the task scheduler settings which task can use which variables from the keystore. To do this, execute the following command:
PUT _core/settings/job-scheduler
{
"script_environments": {
"<task_id>": ["<variable_name>"]
}
}

Now the scheduler will instruct SA Engine RE to run the script with the variables in the environment.

  1. In the script, include code to retrieve the variable from the environment.

Example for Python:

import os

if __name__ == "__main__":
# get the variable from the environment
try:
envParamData = os.getenv("<variable_name>")
except Exception as e:
envParamData = e