Qlik Community

Qlik Sense Enterprise Documents & Videos

Documents & videos about Qlik Sense.

Sending e-mail alerts in Qlik Sense Enterprise Task Failures

Employee
Employee

Sending e-mail alerts in Qlik Sense Enterprise Task Failures

There´s a common request to any Qlik Sense Enterprise Administrator:

"Is there any way to be informed by e-mail when a reload task fails?"  Yes, there is!

Before that, let´s have some technical small talk (you can jump to session "Creating your config xml" if you want)

Qlik Sense Enterprise relies on log4Net a very mature Apache Project  that is very reliable and powerful. It, besides a lot of features  , has the concept of Appender. That concept means that the application being logged (Qlik Sense in our case) does not to take care where the log is being stored, log4net config files handles this.

You can change a config file and choose if your log are meant to be stored into a database, a flat file, a hadoop data lake and you can even send an e-mail for each error message.   Qlik Sense Enterprise help to Appenders

1 - Creating your config xml

Pick your favorite text editor and write your config file according this https://logging.apache.org/log4net/release/config-examples.html

No, wait!

I´m posting here a functional config file, you can copy and paste it.

I´m supposing you´re going to use Gmail as the SMTP but is up to you chose any working SMTP that you want

<?xml version="1.0"?>

<configuration>

    <!-- Mail appender-->

    <appender name="MailAppender" type="log4net.Appender.SmtpAppender">

        <filter type="log4net.Filter.LevelRangeFilter">

            <param name="levelMin" value="WARN" />

            <param name="levelMax" value="ERROR" />

        </filter>

        <filter type="log4net.Filter.DenyAllFilter" />

        <evaluator type="log4net.Core.LevelEvaluator">

            <param name="threshold" value="ERROR"/>

        </evaluator>

        <param name="to" value="admin@domain.com" /> <!-- please use your admin e-mail address here -->

        <param name="cc" value="someone.else@domain.com" />

        <param name="from" value="yourgmailaccount@gmail.com" /> <!-- you´re supposed to change this -->

        <param name="subject" value="Qlik Sense Task Fail!!!" />

        <param name="smtpHost" value="smtp.gmail.com" />

        <param name="port" value="587" />

        <param name="EnableSsl" value="true" />

        <param name="Authentication" value="Basic" />

        <param name="username" value="yourgmailaccount@gmail.com" /> <!-- you´re supposed to change this -->

        <param name="password" value="yourpasswordforGmail" /> <!-- you´re supposed to change this -->

        <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">7

<!-- You can change below code if you want to pretify your e-mail message -->

            <param name="conversionPattern" value="%newline%date %-5level %newline%property{TaskName}%newline%property{AppName}%newline%message%newline%newline%newline" />

        </layout>

    </appender>

    <!--Send mail on task failure-->

    <logger name="System.Scheduler.Scheduler.Slave.Tasks.ReloadTask"> <!-- Filter what kind of exceptionname is beeing captured -->

        <appender-ref ref="MailAppender" />

    </logger>

</configuration>

2 - Saving your config xml

You must save your file with LocalLogConfig.xml name and under C:\ProgramData\Qlik\Sense\Scheduler (at least until version April2018). Anything different from this will cause your configuration not work.

Capture.PNG


3 - Restarting your Scheduler Service


Check if any task is running before restarting the service!!

Capture.PNG



4 - Test

  • Create an app and create an very "silly always fail" script like Store notable into [lib://neverland/notable.qvd](qvd)
  • Schedule your app as usual (under QMC/Apps/[your app]/More options button/Create New Reload Task

    (https://help.qlik.com/en-US/sense/April2018/Subsystems/ManagementConsole/Content/create-reload-tasks...)

Get a cup of coffee and wait for your task fail and your alert e-mail arrives at your inbox.



This blog post was written with fundamental contribution of ile‌ that sent me a functional config file


Comments
mike_rowe
New Contributor II

Hi

 

This happened to me when I tried to do more than one email as:

email1@test.co.uk; email2@test.co.uk

But when i separated by a comma it works ok. Eg.

email1@test.co.uk, email2@test.co.uk

I did read an article about why it had to be like this but was quite a while ago and can't remember the reason for it needing to be like this.

 

Anyway hopefully this will work for you.

 

Mike

0 Likes
Partner
Partner

Hi Mike,

        I separated email ids using comma only and it worked fine when I had one email id in TO (abc@domain1.com) and in CC, I had two email ids (cde@domain2.com, fge@domain2.com).

       But I had problem when I tried to add one more email id of domain1.com to TO and CC.

       Not able to understand the reason.

0 Likes
mike_rowe
New Contributor II

Do you mean it didn't work when you had more than one email separated by a comma in both the To and CC parameters? But when you had just one in To parameter and two in CC parameter it worked ok?

0 Likes
Partner
Partner

I meant that it worked fine when I had one in To parameter and two in CC parameter.

  But when I tried to make it two in TO and three in CC, it is not working.

0 Likes
mike_rowe
New Contributor II

Hi

I've tested it on mine and it seems to be working fine. This is how I have written the code:

<param name="to" value="email1@wwl.nhs.uk,email2@wwl.nhs.uk,email3@wwl.nhs.uk,email4@wwl.nhs.uk" />

<param name="cc" value="email1@wwl.nhs.uk,email2@wwl.nhs.uk,email3@wwl.nhs.uk" />

 

Not sure what to suggest other than checking your code against mine.

Mike

Partner
Partner

Guys, I've configured the xml as shown above and restarted the Scheduler Service, but when a task fail I don't see anything being sent. Do you know if this is supposed to work in Qlik Sense 3.2?

This is my xml in C:/ProgramData/Qlik/Sense/Scheduler/LocalLogConfig.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" />
</filter>
<filter type="log4net.Filter.DenyAllFilter" />
<evaluator type="log4net.Core.LevelEvaluator">
<param name="threshold" value="ERROR"/>
</evaluator>
<param name="to" value="mypersonal@account.com" />
<param name="from" value="email@gmail.com" />
<param name="subject" value="Qlik Sense Task Alert" />
<param name="smtpHost" value="smtp.gmail.com" />
<param name="port" value="587" /> <!-- 25, 465, 567 -->
<param name="EnableSsl" value="true" /> <!-- True False -->
<param name="Authentication" value="Basic" /> <!-- None Basic NTML -->
<param name="username" value="email@gmail.com" />
<param name="password" value="password" />
<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="The Task '%property{TaskName}' failed at %date with the Errorlevel '%-5level' %newline%newlineThe App Name is '%property{AppName}' %newline%newlineThe Message was '%message' %newline%newline%newline" />
</layout>
</appender>
<!--Send mail on task failure-->
<logger name="System.Scheduler.Scheduler.Slave.Tasks.ReloadTask">
<appender-ref ref="MailAppender" />
</logger>
</configuration>

0 Likes
Version history
Revision #:
1 of 1
Last update:
‎2018-04-26 07:31 PM
Updated by: