By Ruhan Wagener
Acting Director, Managed Services & Architecture

With all the wonderful things going on in the Qlik world and most of us being captivated by the latest and greatest acquisitions and new tech that’s available, some basics have often been overlooked. Today I’d like to share a simple yet elegant solution to a common problem, monitoring scheduled tasks in Qlik.

This will be the first in a multi part series of blog posts regarding monitoring in Qlik and how you can be better at it. So, on to the meat and potatoes. Receiving automated alerts via email when failures occur: Qlik uses the Apache log4net library for logging and this comes with many “hidden” benefits.

By default, file logging is enabled as has been the case since the inception of Qlik Sense. Centralized logging was since introduced and at first, I didn’t really find much use for it – until recently. More to come on that later in this series. Something many people ask for is to receive an email alert when a reload task had failed. A simple, yet not available “out of the box” functionality. There are various bits and pieces out there on the community to resolve this, however many of the proposed solutions were somewhat convoluted or just overkill.

What I wanted was to leverage Amazon SES for sending mails and having the log4net SMTPAppender watch for an error status on reload tasks. Now bear in mind, you can take this very configuration and apply it to anything within the Qlik logging framework. For example, you want to be notified when users are being denied access to your environment or you’re running out of licenses. Endless possibilities.

Below you’ll find the config file example which I used to accomplish this. To deploy, simply create an XML file called _LocalLogConfig.xml_ and save it to _%ProgramData%\Qlik\Sense\Scheduler_. You can use the example attached below and simply adjust the needed fields. You can also have multiple recipients of these notifications by using a comma separated list of emails in the “to,” “cc” and “bcc” parameters.

[sourcecode language=”xml”]
<?xml version="1.0"?>
<configuration>
<!– Mail appender–>
<appender name="MailAppender" type="log4net.Appender.SmtpAppender">
<filter type="log4net.Filter.LevelRangeFilter">
<param name="levelMin" value="ERROR" />
<!–Sets the level of logging, in this case any ERROR in the log will be sent as an email–>
</filter>
<filter type="log4net.Filter.DenyAllFilter" />
<evaluator type="log4net.Core.LevelEvaluator">
<param name="threshold" value="ERROR"/>
<!–Sets the level of logging, in this case any ERROR in the log will be sent as an email–>
</evaluator>
<param name="to" value="john@newco.com,admin@newco.com" />
<param name="from" value="itadmin@newco.com" />
<param name="bcc" value="senseadmin@newco.com" />
<param name="subject" value="Qlik Sense" />
<param name="smtpHost" value="your-hostname-here" /> <!– EXAMPLE: email-smtp.us-west-1.amazonaws.com –>
<param name="port" value="587" />
<param name="EnableSsl" value="true" />
<param name="Authentication" value="Basic" />
<param name="username" value="your-username-here" />
<param name="password" value="your-password-here" />
<param name="bufferSize" value="0" /> <!– Set this to 0 to make sure an email is sent on every error –>
<param name="lossy" value="true" />
<layout type="log4net.Layout.PatternLayout">
<param name="conversionPattern" value="%newline%date %-5level %newline%property{TaskName}%newline%property{AppName}%newline%message%newline%newline%newline" />
<!–Defined conversion pattern for the output. To be able to output custom properties in the log (example, Taskname), append %property{propertyname} to the output pattern–>
</layout>
</appender>
<!–Send mail on task failure–>
<logger name="System.Scheduler.Scheduler.Slave.Tasks.ReloadTask">
<!–Logger name identifies the component to monitor. This can be found by investigating the actual log file
For example, open C:\ProgramData\Qlik\Sense\Log\Scheduler\Trace\[your-hostname-here]_System_Scheduler and review the various components available
The same principle applies to other areas like Engine, Proxy, Repository etc–>
<appender-ref ref="MailAppender" />
<!–appender-ref should match the name identifying the appender. More than one appender can be configured in the same configuration file–>
</logger>
</configuration>
[/sourcecode]

There are many more Appenders available in the log4net library which you can find in the Qlik help documentation here.

I hope this saves you some time in getting it deployed within your own environment and getting those notifications! If they start filling up your inbox, well, maybe we need to take a closer look.