Mike DeAngelo, Developer Relations Engineer
Looker’s “Scheduled Plan” facility can be used to automatically run a Look or Dashboard at a set time each day and get the results in an email. The UI defaults to running the scheduled plan at 6am each day. Many users never change the default. Therefore, if this feature is used heavily, the Looker server and possibly the underlying database go through a period of high usage every morning at 6am.
Using Gazer, an open source tool that helps manage Looker instances, these schedules can be randomized. Gazer will alter each plan by a random amount of time +/- 30 minutes. This can help smooth out the period of high usage. In addition, alerts can also be randomized the same way.
The Gazer tool can be found at https://github.com/looker-open-source/gzr along with installation and setup instructions. If you already have Gazer installed, be sure to upgrade to version 0.3.16 or later.
Normally you can only modify your own plans and alerts. If you are an administrator you can also modify the plans and alerts of others.
To see a list of plans, you can use the command gzr plan ls --host=looker.example.com. Be sure to use the name of your Looker server instead of looker.example.com.
gzr plan ls --host=looker.example.com
+----+-------+-------------------------------------------+-------+-----------------+------+------------+-------------------+-----------+
| id|enabled|name |user.id|user.display_name|look_id|dashboard_id|lookml_dashboard_id|crontab |
+----+-------+-------------------------------------------+-------+-----------------+------+------------+-------------------+-----------+
| 9|true |Orders by Day and Category | 705|Alisa T | 326| | |35 17 * * *|
| 23|true |Week over Week Rentals | 73|Joshua M | 463| | |18 4 * * * |
| 89|true |Top 10 Companies by Vertical | 696|Abby W | 855| | |49 3 1 * * |
| 549|true |Profit By Gender, By Quarter | 1017|Jeffrey M | 1432| | |1 7 * * * |
| 786|true |Test Dasthboard DELETE:2018-01-28 | 739|Jonathan T | | 362| |20 6 * * 2 |
| 977|true |Avg spend levi's / carhartt per age tier | 1196|Jonathan H | 1714| | |28 6 1 * * |
+----+-------+-------------------------------------------+-------+-----------------+------+------------+-------------------+-----------+
To modify one specific plan you can use the command gzr plan randomize PLAN_ID --host=looker.example.com substituting the plan id from the list for PLAN_ID.
To modify all your own plans, simply don’t provide a PLAN_ID. gzr plan randomize --host=looker.example.com.
To modify all plans, assuming you are an administrator, use the --all switch. gzr plan randomize --all --host=looker.example.com.
The default window is 60 minutes - moving a plan up to 30 minutes earlier or later. But the window can be shorter if desired. A window of 30 minutes will move a plan up to 15 minutes before or after its currently scheduled time. A window of 2 minutes will move it 1 minute either way. The specific window is specified like --window=20. It must be an integer from 2 to 60.
The commands gzr alert ls and gzr alert randomize work exactly the same way as their plan counterparts.
While you are working with Gazer and scheduled plans, also take a look at some of the other features available. The commands gzr plan enable|disable PLAN_ID can be used to enable or disable a plan. The command gzr plan failures will show you the list of plans that have failed during their most recent attempt. The command gzr plan runit PLAN_ID can be used to manually run a scheduled plan, and is useful for retrying recently failed plans.
gzr plan failures --host=looker.example.com
+-----------------+-------------------------------------------+-------+----------------+--------------------+----------------+--------------------------+---------------------------+----------------------+---------------------------+----------------------------------+
|scheduled_plan.id|scheduled_plan.name |user.id| user.name |scheduled_job.status|scheduled_job.id|scheduled_job.created_time|scheduled_plan.next_run_time|scheduled_plan.look_id|scheduled_plan.dashboard_id|scheduled_plan.lookml_dashboard_i|
+-----------------+-------------------------------------------+-------+----------------+--------------------+----------------+--------------------------+---------------------------+----------------------+---------------------------+----------------------------------+
| 23|Week over Week Rentals | 73| Joshua M |failure | 37180|2024-06-27 11:19:35 |2024-06-28 11:18:00 | 463| | |
| 1875|schedules by hour | 730| Eric F |failure | 37182|2024-06-27 12:53:34 |2024-06-28 12:53:00 | 2119| | |
| 1883|look 3 | 1515| Masayuki Y |failure | 37181|2024-06-27 12:50:21 |2024-06-28 12:49:00 | 2111| | |
+-----------------+-------------------------------------------+-------+----------------+--------------------+----------------+--------------------------+---------------------------+----------------------+---------------------------+----------------------------------+
gzr plan runit 23 --host=looker.example.com
Executed plan 23
The alert commands also have some useful tools. Like plans, there are enable/disable commands: gzr alert enable|disable ALERT_ID. The command gzr alert notifications allows you to see the recent alert notifications, and gzr alert read NOTIFICATION_ID enables you to read a specific notification.
gzr alert notifications --host=looker.example.com
+---------------+------------------+-------+-------+------------------+---------------+-------------------------+-----------------------------+--------------+-----------------------------+---------------------------------------+------------------+----------------+
|notification_id|alert_condition_id|user_id|is_read|field_value |threshold_value|ran_at |alert.title |alert.alert_id|alert.investigative_content_id|alert.dashboard_name |alert.dashboard_id|alert.query_slug|
+---------------+------------------+-------+-------+------------------+---------------+-------------------------+-----------------------------+--------------+-----------------------------+---------------------------------------+------------------+----------------+
| 26982| 32| 2456|false |2320.7799999999997|300.0 |2024-06-25 10:00:15 +0000|Any Total Revenue reached 300| 32| |セットアップdashboard簡単ではありません| 868|8gp6563 |
| 26983| 32| 2456|false |2320.7799999999997|300.0 |2024-06-25 11:00:02 +0000|Any Total Revenue reached 300| 32| |セットアップdashboard簡単ではありません| 868|8gp6563 |
| 26985| 32| 2456|false |2320.7799999999997|300.0 |2024-06-25 12:00:21 +0000|Any Total Revenue reached 300| 32| |セットアップdashboard簡単ではありません| 868|8gp6563 |
| 26986| 32| 2456|false |2320.7799999999997|300.0 |2024-06-25 13:00:11 +0000|Any Total Revenue reached 300| 32| |セットアップdashboard簡単ではありません| 868|8gp6563 |
+---------------+------------------+-------+-------+------------------+---------------+-------------------------+-----------------------------+--------------+-----------------------------+---------------------------------------+------------------+----------------+
gzr alert read 26982 --host=looker.example.com
{
"notification_id": "26982",
"alert_condition_id": "32",
"user_id": "2456",
"is_read": true,
"field_value": 2320.7799999999997,
"threshold_value": 300.0,
"ran_at": "2024-06-25 10:00:15 +0000",
"alert": {
"title": "Any Total Revenue reached 300",
"alert_id": "32",
"investigative_content_id": null,
"dashboard_name": "セットアップdashboard簡単ではありません",
"dashboard_id": "868",
"query_slug": "8gp6563"
}
}
Gazer provides lots of other features. Now that you have started using it, try running gzr help to see everything Gazer can do.
Awesome, Mike!