<?xml version="1.0" encoding="utf-8"?> 
<rss version="2.0">

<channel>

<title>LEFT JOIN: blog on analytics, visualisation &amp; data science, posts tagged: alert</title>
<link>https://en.leftjoin.ru/tags/alert/</link>
<description></description>
<generator>E2 (v3386; Aegea)</generator>

<item>
<title>Setting up alerts in Redash</title>
<guid isPermaLink="false">18</guid>
<link>https://en.leftjoin.ru/all/redash-alerts/</link>
<comments>https://en.leftjoin.ru/all/redash-alerts/</comments>
<description>
&lt;p&gt;A very handy function on alert building is implemented in &lt;a href="http://leftjoin.ru/all/redash-polnocennaya-on-demand-analitika/"&gt;Redash&lt;/a&gt;. Alerts stand for notifications, arising at adjustment of some specific indicator. At that, the degree of change is set manually by a user on his own in the interface. Alerts can be set to a mail or to a channel / direct messages Slack.&lt;/p&gt;
&lt;p&gt;Let’s recall how to collect the data, using &lt;a href="http://leftjoin.ru/all/stroim-funnel-report-v-redash/"&gt;Google Analytics&lt;/a&gt;, and set up alerts for this data, applying the internal Redash database (&lt;i&gt;query-results&lt;/i&gt;). As a foundation for an alert we will focus on the reduction of number of users on the site for the previous day by more than 30%.&lt;/p&gt;
&lt;h2&gt;Building a query to Google Analytics&lt;/h2&gt;
&lt;pre class="e2-text-code"&gt;&lt;code&gt;{
    &amp;quot;ids&amp;quot;: &amp;quot;ga:128886640&amp;quot;,
    &amp;quot;start_date&amp;quot;: &amp;quot;30daysAgo&amp;quot;,
    &amp;quot;end_date&amp;quot;: &amp;quot;yesterday&amp;quot;,
    &amp;quot;metrics&amp;quot;: &amp;quot;ga:users&amp;quot;, 
    &amp;quot;dimensions&amp;quot;: &amp;quot;ga:date&amp;quot;
}&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;As a result of performance of this query, we will receive a number of users for the last 30 days.&lt;/p&gt;
&lt;div class="e2-text-picture"&gt;
&lt;img src="https://en.leftjoin.ru/pictures/ga-query@2x.png" width="175" height="391" alt="" /&gt;
&lt;/div&gt;
&lt;h2&gt;Turning on the storage of query results&lt;/h2&gt;
&lt;p&gt;One of the main &lt;i&gt;features&lt;/i&gt; of redash is an opportunity of calling upon the results of query performance, that are stored in the internal DBMS SQLite.&lt;br /&gt;
In order to turn on the storage of results, we need to go to &lt;i&gt;Data Sources&lt;/i&gt; and turn on &lt;i&gt;query-results (beta)&lt;/i&gt;.&lt;/p&gt;
&lt;p&gt;And now, with a simple command presented below:&lt;/p&gt;
&lt;pre class="e2-text-code"&gt;&lt;code&gt;select * from query_37&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;we will receive a result, similar to the one of the previous query to GA, however this one has an opportunity of using SQL language for processing of the data set obtained.&lt;/p&gt;
&lt;h2&gt;Building a query for evaluation of changes within the number of users&lt;/h2&gt;
&lt;p&gt;In order to set up the alert, first of all we need to write a query, that will eventually provide us with a target indicator for check, in our case it is growth or reduction in the number of users on the website.&lt;br /&gt;
Lets write a query, calling upon the internal DBMS of Redash:&lt;/p&gt;
&lt;pre class="e2-text-code"&gt;&lt;code&gt;SELECT sum(CASE WHEN date(ga_date)=DATE('now', '-1 day') THEN ga_users ELSE NULL END) AS yesterday,
sum(CASE WHEN date(ga_date)=DATE('now', '-2 day') THEN ga_users ELSE NULL END) AS before_yesterday,
(sum(CASE WHEN date(ga_date)=DATE('now', '-1 day') THEN ga_users ELSE NULL END)*1.0/
sum(CASE WHEN date(ga_date)=DATE('now', '-2 day') THEN ga_users ELSE NULL END)*1.0-1)*100 AS difference
FROM query_37&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;In the above-shown query we are calculating the number of users for two previous days, and also evaluating the change of number of users in percentage.&lt;br /&gt;
In the current example, we have received the following table of data, that we will use further at the process of alert setting:&lt;/p&gt;
&lt;div class="e2-text-picture"&gt;
&lt;img src="https://en.leftjoin.ru/pictures/alert-table@2x.png" width="299" height="102" alt="" /&gt;
&lt;/div&gt;
&lt;p&gt;Now, in order for us to be able to receive alerts, we need to set query performance by schedule (regular update of results / &lt;i&gt;scheduled query&lt;/i&gt; in redash terminology).&lt;/p&gt;
&lt;div class="e2-text-picture"&gt;
&lt;img src="https://en.leftjoin.ru/pictures/refresh-schedule@2x.png" width="351" height="76" alt="" /&gt;
&lt;/div&gt;
&lt;p&gt;We set an update for 10 o’clock of every morning:&lt;/p&gt;
&lt;div class="e2-text-picture"&gt;
&lt;img src="https://en.leftjoin.ru/pictures/refresh-10@2x.png" width="324" height="172" alt="" /&gt;
&lt;/div&gt;
&lt;h2&gt;Setting alert&lt;/h2&gt;
&lt;p&gt;Going to the menu &lt;i&gt;Create&lt;/i&gt; – &lt;i&gt;Alert&lt;/i&gt;. Inserting the name of query, in my case it is “&lt;i&gt;Alert on users&lt;/i&gt;”.&lt;br /&gt;
Hereafter, we can change the reflected name of notification or leave the one, proposed by the system.&lt;/p&gt;
&lt;p&gt;Choosing a target metric within the example reviewed – &lt;i&gt;difference&lt;/i&gt;. Below, in the comparison operator (&lt;i&gt;Op&lt;/i&gt;) selecting &lt;i&gt;less then&lt;/i&gt; and setting a value of &lt;i&gt;-30&lt;/i&gt;.&lt;/p&gt;
&lt;div class="e2-text-picture"&gt;
&lt;img src="https://en.leftjoin.ru/pictures/target-value@2x.png" width="781" height="341" alt="" /&gt;
&lt;/div&gt;
&lt;p&gt;In the block on the right you need to select where exactly the alert will be sent. You can read about the setting of alert’s path more thoroughly on the &lt;a href="https://redash.io/help/user-guide/alerts/creating-new-alert-destination"&gt;official website of Redash&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Now, the alert has appeared on the page with the list of alerts and is by default in the status &lt;i&gt;OK&lt;/i&gt;.&lt;/p&gt;
&lt;p&gt;As soon as the indicator exceeds the level that we’ve set, the status will change to &lt;i&gt;TRIGGERED&lt;/i&gt;, and the alert will be sent to mail / to Slack.&lt;/p&gt;
&lt;p&gt;More on the topic&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://redash.io/help/user-guide/alerts/setting-up-an-alert"&gt;Alerts setting up on the page of Redash&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://redash.io/help/user-guide/alerts/creating-new-alert-destination#Slack"&gt;Adding Slack as a new destination for alerts&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
</description>
<pubDate>Tue, 03 Dec 2019 10:55:11 +0300</pubDate>
</item>


</channel>
</rss>