Creating alert in SQL runner

I created a nice graph in the SQL runner showing the number of customers added per day at my company. I tweaked it slightly which required me to do this in SQL runner rather than the explore tab. I would like to create an automatic alert when a certain number of customers is reached / day but the alert functionality only seems possible in the explore tab. Do you have any advice how I can create alerts in SQL runner. 

Thanks, 

Alex

0 2 308
2 REPLIES 2

Hi Akidwell,

The closest SQL aprroach you can try is by creating a Looker- Derived table (see SQL-based derived table version here).

In this example a Postgres DB was used to create the SQL statement that is going to check if there are more than 1 check out row every day :

(SQL validation and dialect might be different from your datasource)

view: view_current_day {
derived_table: {
sql: SELECT date_of_discharge FROM hospital.patient_history
WHERE date_of_discharge = current_date ;;
}
dimension:date_of_discharge {
type: date
}
measure:counter_alert {
type: number
sql: count(date_of_discharge) ;;
}
}

Notice that "current_date”  is a value retrieved from your datasource.

After creating the derived table, create a new explore in your model file  with 0 Looker - Persist .

For Instance:

explore: view_current_day {
persist_for:"0 hours"
}

After saving the changes in your LooMKL ( See Looker - Git control ) 

Create a new tile in any dashboard related to your project, for instance:

81cefb2e-7ca2-4280-b0f3-7bc75950d4e9.png

Your new tile should look like this:

b11a2010-1e8f-434a-87f6-68ffc05935ae.png

In the next step, you must disable “development Mode” , otherwise you will not be able to see the alert icon:

5a1ad0fe-0fa2-470e-bedd-392e7ba750b6.png

In this step, the alert notification is set based on your counter measure:

(In this example, if the number of check-out is greater than 2 patients per day, an email is going to be send)

32d84b13-5519-462a-943e-3691c6bcc779.png

In this doc  Looker - Alerts  you may find additional settings and custom parameters.

Regards,

Leo

Thanks very much! Really helpful! 

Top Labels in this Space