Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW

Sending e-mail alerts in Qlik Sense Enterprise Task Failures

No ratings
cancel
Showing results for 
Search instead for 
Did you mean: 
Clever_Anjos
Employee
Employee

Sending e-mail alerts in Qlik Sense Enterprise Task Failures

Last Update:

Apr 26, 2018 7:31:47 PM

Updated By:

Clever_Anjos

Created date:

Apr 26, 2018 7:31:47 PM

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
Michael_Leigh
Employee
Employee

If using gmail you may need to enable less secure applications in your Google mail settings:

Let less secure apps access your account - Google Account Help.

Michael_Leigh
Employee
Employee

I also tested this in the Qlik Sense April 2018 release, using FakeSMTP for the mail server. This is useful to test and if you need to eliminate your mail service as having issues. Below is an example LocalLogConfig.xml config file.

Note that I used 2525 as the SMTP port and localhost for the smtpHost, as FakeSMTP was running on the Sense server. Fake SMTP can be run on a remote machine, as long a there's network connectivity and your chosen port is open.

<?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="senseadmins@yourcomapny.com" />

        <param name="cc" value="brian@yourcomapny.com,ted@yourcomapny.com" />

        <param name="bcc" value="sienna@yourcomapny.com,tony@yourcomapny.com" />

        <param name="from" value="sysadmin@yourcomapny.com" />

        <param name="subject" value="Qlik Sense Reload Error" />

        <param name="smtpHost" value="localhost" />

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

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

        </layout>

    </appender>

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

    <logger name="System.Scheduler.Scheduler.Slave.Tasks.ReloadTask">

        <appender-ref ref="MailAppender" />

    </logger>

</configuration>

huangjing
Contributor
Contributor

According to your method, we have succeeded in testing.

But what we need now is that only a part of task send wrong messages, what should i do?

For example, the prefix of the tasks is A , sending mail, others do not send.

0 Likes
Michael_Leigh
Employee
Employee

You can use the StringToMatch filters in log4net, see Apache log4net™ SDK Documentation - Table of Content and look for StringMatchFilter

I don't have a working example of this, but if my understanding is correct it should work. As far as I know StringToMatch uses OR only, not AND, for multiple filters, and make sure <filter type="log4net.Filter.DenyAllFilter" /> is the last filter line used.

e.g.

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

            <StringToMatch value="Your Text Here" />

   </filter>

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

millan123
Creator II
Creator II

Thank you for the info Michael.

Could we use same for the June 2018 version ?

Br,

Clark

0 Likes
Michael_Leigh
Employee
Employee

As far as I can see nothing has changed around this, so it should work as per previous releases - but I have not tested.

0 Likes
millan123
Creator II
Creator II

Thank you , I tried using it about I am not getting any mails.

Where should I check Locallogconfig.xml log ? any troubleshooting idea will be helpful to us.

Thank you so much

0 Likes
Michael_Leigh
Employee
Employee

Initially I recommend opening a support case with Qlik as I won't have time to test it anytime soon. I'm not sure where any errors would be logged; but probably either in the Logging service or the Schedule logs somewhere

0 Likes
millan123
Creator II
Creator II

thank you sure , we will create a log in to Qlik support

0 Likes
miskin_m
Partner - Creator
Partner - Creator

Hi Clark/ Mick

I am also trying to send gmail mails from June 18 but no luck. Did anyone of you found the solution.

Regards

Miskin

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