Send an Email notification including the error information in ETL Chainset

This guide will demonstrate how to send an email notification that includes error details within the ETL Chainset. This process is particularly useful for sending alerts or notifications when an issue occurs during the execution of a specific job in your ETL Chainset.

Note:

Do refer to the following entry below first on how to send notification using Chain If Else step in ETL

Prerequisite

Attached files.zip contains batch files and the ETL chainset used in this guideline. It is advisable to configure the email SMTP account in application.conf first prior to doing this guideline.

1/ Add the batch files to your working directory e.g below my working directory is at “C:/app/external command”. Then create a text file called TextDocument.txt in the same directory. Edit the path in each of the .bat files provided.

image

Revise the application.conf file

ambience.etl {
  external {
    run-command {
      commands {
        echo:"echo"
        # full path required in some cases
        # phantomjs:"/usr/local/bin/phantomjs-2.1.1-macosx/bin/phantomjs"
		housekeeping:"C:/app/external command/removefile.bat"
		echoSuccess:"C:/app/external command/echoSuccess.bat"

2/ Run command - This step will executes the housekeeping batch file:

3/ Reduce Concatenate - This step takes an array and returns the contents concatenated with a preset separator.

4/ Write State - This step writes a value into the state, so it can later be read by Read State. The main use of this step is to record parameters on input into a chain, so that they don’t have to be passed through every step. Key value is all and the output will be derive in field result.

5/ Array Length step will derive the value from the “error” field to the “length” field. [0=No Errors, >1=Have Error(s)]:

6/ Equal Value step derives a boolean from “length” field, 0 = True, greater or equals 1 = False

7/ Chain If Else step executes either chain #02_ExternalCommand_Success or #03_ExternalCommand_Error based on the result value

8/ To include the error information when sending an email notification, follow the steps outlined below in the #03_ExternalCommand_Error chainset.

  • Read State - This step reads the value from the previous written to the state by Write State

  • Compose Mail step, add the following parameter ${result} on the second line. The value for ${result} will be taken from the result value in step 4 in this guideline which is “Could Not Find C:\app\external command\TextDocument*.*”

image

Example email notification:

File.zip (1.5 KB)