{
    "version": "https:\/\/jsonfeed.org\/version\/1",
    "title": "LEFT JOIN: blog on analytics, visualisation & data science, posts tagged: alert",
    "home_page_url": "https:\/\/en.leftjoin.ru\/tags\/alert\/",
    "feed_url": "https:\/\/en.leftjoin.ru\/tags\/alert\/json\/",
    "icon": "https:\/\/en.leftjoin.ru\/user\/userpic@2x.jpg",
    "author": {
        "name": "Nikolay Valiotti",
        "url": "https:\/\/en.leftjoin.ru\/",
        "avatar": "https:\/\/en.leftjoin.ru\/user\/userpic@2x.jpg"
    },
    "items": [
        {
            "id": "18",
            "url": "https:\/\/en.leftjoin.ru\/all\/redash-alerts\/",
            "title": "Setting up alerts in Redash",
            "content_html": "<p>A very handy function on alert building is implemented in <a href=\"http:\/\/leftjoin.ru\/all\/redash-polnocennaya-on-demand-analitika\/\">Redash<\/a>. 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.<\/p>\n<p>Let’s recall how to collect the data, using <a href=\"http:\/\/leftjoin.ru\/all\/stroim-funnel-report-v-redash\/\">Google Analytics<\/a>, and set up alerts for this data, applying the internal Redash database (<i>query-results<\/i>). 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%.<\/p>\n<h2>Building a query to Google Analytics<\/h2>\n<pre class=\"e2-text-code\"><code>{\r\n    &quot;ids&quot;: &quot;ga:128886640&quot;,\r\n    &quot;start_date&quot;: &quot;30daysAgo&quot;,\r\n    &quot;end_date&quot;: &quot;yesterday&quot;,\r\n    &quot;metrics&quot;: &quot;ga:users&quot;, \r\n    &quot;dimensions&quot;: &quot;ga:date&quot;\r\n}<\/code><\/pre><p>As a result of performance of this query, we will receive a number of users for the last 30 days.<\/p>\n<div class=\"e2-text-picture\">\n<img src=\"https:\/\/en.leftjoin.ru\/pictures\/ga-query@2x.png\" width=\"175\" height=\"391\" alt=\"\" \/>\n<\/div>\n<h2>Turning on the storage of query results<\/h2>\n<p>One of the main <i>features<\/i> of redash is an opportunity of calling upon the results of query performance, that are stored in the internal DBMS SQLite.<br \/>\nIn order to turn on the storage of results, we need to go to <i>Data Sources<\/i> and turn on <i>query-results (beta)<\/i>.<\/p>\n<p>And now, with a simple command presented below:<\/p>\n<pre class=\"e2-text-code\"><code>select * from query_37<\/code><\/pre><p>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.<\/p>\n<h2>Building a query for evaluation of changes within the number of users<\/h2>\n<p>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.<br \/>\nLets write a query, calling upon the internal DBMS of Redash:<\/p>\n<pre class=\"e2-text-code\"><code>SELECT sum(CASE WHEN date(ga_date)=DATE('now', '-1 day') THEN ga_users ELSE NULL END) AS yesterday,\r\nsum(CASE WHEN date(ga_date)=DATE('now', '-2 day') THEN ga_users ELSE NULL END) AS before_yesterday,\r\n(sum(CASE WHEN date(ga_date)=DATE('now', '-1 day') THEN ga_users ELSE NULL END)*1.0\/\r\nsum(CASE WHEN date(ga_date)=DATE('now', '-2 day') THEN ga_users ELSE NULL END)*1.0-1)*100 AS difference\r\nFROM query_37<\/code><\/pre><p>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.<br \/>\nIn the current example, we have received the following table of data, that we will use further at the process of alert setting:<\/p>\n<div class=\"e2-text-picture\">\n<img src=\"https:\/\/en.leftjoin.ru\/pictures\/alert-table@2x.png\" width=\"299\" height=\"102\" alt=\"\" \/>\n<\/div>\n<p>Now, in order for us to be able to receive alerts, we need to set query performance by schedule (regular update of results \/ <i>scheduled query<\/i> in redash terminology).<\/p>\n<div class=\"e2-text-picture\">\n<img src=\"https:\/\/en.leftjoin.ru\/pictures\/refresh-schedule@2x.png\" width=\"351\" height=\"76\" alt=\"\" \/>\n<\/div>\n<p>We set an update for 10 o’clock of every morning:<\/p>\n<div class=\"e2-text-picture\">\n<img src=\"https:\/\/en.leftjoin.ru\/pictures\/refresh-10@2x.png\" width=\"324\" height=\"172\" alt=\"\" \/>\n<\/div>\n<h2>Setting alert<\/h2>\n<p>Going to the menu <i>Create<\/i> – <i>Alert<\/i>. Inserting the name of query, in my case it is “<i>Alert on users<\/i>”.<br \/>\nHereafter, we can change the reflected name of notification or leave the one, proposed by the system.<\/p>\n<p>Choosing a target metric within the example reviewed – <i>difference<\/i>. Below, in the comparison operator (<i>Op<\/i>) selecting <i>less then<\/i> and setting a value of <i>-30<\/i>.<\/p>\n<div class=\"e2-text-picture\">\n<img src=\"https:\/\/en.leftjoin.ru\/pictures\/target-value@2x.png\" width=\"781\" height=\"341\" alt=\"\" \/>\n<\/div>\n<p>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 <a href=\"https:\/\/redash.io\/help\/user-guide\/alerts\/creating-new-alert-destination\">official website of Redash<\/a>.<\/p>\n<p>Now, the alert has appeared on the page with the list of alerts and is by default in the status <i>OK<\/i>.<\/p>\n<p>As soon as the indicator exceeds the level that we’ve set, the status will change to <i>TRIGGERED<\/i>, and the alert will be sent to mail \/ to Slack.<\/p>\n<p>More on the topic<\/p>\n<ul>\n<li><a href=\"https:\/\/redash.io\/help\/user-guide\/alerts\/setting-up-an-alert\">Alerts setting up on the page of Redash<\/a><\/li>\n<li><a href=\"https:\/\/redash.io\/help\/user-guide\/alerts\/creating-new-alert-destination#Slack\">Adding Slack as a new destination for alerts<\/a><\/li>\n<\/ul>\n",
            "date_published": "2019-12-03T10:55:11+03:00",
            "date_modified": "2020-05-13T14:19:34+03:00",
            "image": "https:\/\/en.leftjoin.ru\/pictures\/ga-query@2x.png",
            "_date_published_rfc2822": "Tue, 03 Dec 2019 10:55:11 +0300",
            "_rss_guid_is_permalink": "false",
            "_rss_guid": "18",
            "_e2_data": {
                "is_favourite": false,
                "links_required": [
                    "system\/library\/highlight\/highlight.js",
                    "system\/library\/highlight\/highlight.css",
                    "system\/library\/highlight\/highlight.js",
                    "system\/library\/highlight\/highlight.css",
                    "system\/library\/highlight\/highlight.js",
                    "system\/library\/highlight\/highlight.css"
                ],
                "og_images": [
                    "https:\/\/en.leftjoin.ru\/pictures\/ga-query@2x.png",
                    "https:\/\/en.leftjoin.ru\/pictures\/alert-table@2x.png",
                    "https:\/\/en.leftjoin.ru\/pictures\/refresh-schedule@2x.png",
                    "https:\/\/en.leftjoin.ru\/pictures\/refresh-10@2x.png",
                    "https:\/\/en.leftjoin.ru\/pictures\/target-value@2x.png"
                ]
            }
        }
    ],
    "_e2_version": 3386,
    "_e2_ua_string": "E2 (v3386; Aegea)"
}