Increasing Visibility of Load Errors

The Jedox Task Manager gives you key information about a job’s execution. It notifies you every time a job is run, regardless whether there were errors or not. Sometimes though, you might require a bit more sophistication in the notifications. For instance, you might only want to receive a notification when there are errors or warnings in a job. Maybe receive the jobs’ error log in the body of an email or even attach the full server log as an attachment.

Fortunately, this is all possible with a small piece of groovy script magic.

 

Below is an example using the sampleBiker ETL Project. Note: This example and steps was created in Jedox 5.1 , using the new ETL interface.

1. Ensure you have the sampleBiker ETL Project listed in ETL. If it is not there, you should be able to find it by browsing to ..\ETL\Samples and importing it.

2. In the sampleBiker ETL project, right click on Jobs and select New. Create a new Groovy Script job.

3. Copy the following code into the script window.

load = "ProductsAll";
state = API.executeLoad(load);
/* or, for to execute a job, use */
/* state = API.executeJob(load); */

 /* Get the full log info. For log_type, enter "ERROR", "WARN" or leave blank for the full log. */
 log_type = "";
 String log=state.getLog(log_type);

if (state.getErrors()!=0 || state.getWarnings()!=0) {

 /* If the job fails or has warnings, send email and attach the log details*/
 mailer = API.getMailer();
 mailer.setServer();
 String nl = System.getProperty("line.separator");

 /* for 1 recipient (you can add multiple here)*/
 mailer.addRecipient("emailname@address.com");

 /* compose the subject line and the email message here*/
 mailer.setSubject("ETL Load Error for " + load);
 mailer.setMessage("Hi, " + nl + nl + "The Jedox ETL job " + load + " returned the following Errors: " + state.getErrors() + ", Warnings: " + state.getWarnings()+". " + nl + nl + "Attached is the Jedox ETL Log for this job: " + nl + nl + log);

 /* with 1 attachment (you can add multiple here)*/
 mailer.addAttachment("C:\\Jedox\\Logs\\tomcat\\etlserver.log");

 mailer.send();

 LOG.info("Errors:"+state.getErrors()+", Warnings:"+state.getWarnings());
}

4. You can uncomment the state line on row 4 if you want to use a job as opposed to a load.

5. The script is set to send out the full Job execution log, but by adding the log_type “ERROR” or “WARN” in the brackets on line 7 you can filter to just what you require.

6. Change the recipient email address on line 18. You can also repeat this line with different email address to add multiple recipients.

7. Change the attachment and/or path on line 25 to suit. You can add multiple attachments by adding another line. Note: ensure you include the double slash as groovy will not recognise the single slash in this script. (Note: this example is in a Windows environment)

8. Finally, go to the System Manager and ensure that a valid SMTP email address and its associated settings have been set.  This job will use these settings to send the email:

 

2014-07-31 22_00_09-Jedox Web

When you run the job, and you have an error, you should get an email that looks a bit like this:

2014-07-31 21_37_09-ETL Load Error for ProductsAll - chris.mentor@nakeddata.com - Naked Data Mail

 

This GroovyScript job can be run on its own, or scheduled as part of Task Manager. Just remember it is not necessary to add a notification email address when running this within  Task Manager.

1 thought on “Increasing Visibility of Load Errors

  1. Edward Barron

    Thanks Chris
    Excellent post – Maybe a good Future Improvement would be to have this available in Task Manager as Notification Type

    Reply

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s