Gazer: A lightweight utility to migrate User Defined Content between Looker instances

Shahnzan
4 Mile Analytics
Published in
4 min readMay 11, 2020
Source : Totemo

A year ago, I was working on a Looker project for a client where I needed to migrate number of shared dashboards and looks from the Development environment to Production environment. It was a large size project with incremental delivery to production. So, I was expected to migrate Looker content repetitively.

Looker is a great platform but one of the functionalities really missing is, not having the ability to easily migrate dashboards and looks within shared and personal spaces between Looker instances. Yes, there are couple of traditional ways to migrate such user defined content.

1. Copy dashboard and looks in another project, but it can be done on same Looker instance

2. Create LookML dashboard from one Looker instance and store in GitHub repo. Another Looker instance can retrieve from same GitHub repo. There is some manual work involved with this approach. It may work well for small projects with handful of content, but might end up consuming lot of time for large project and content.

After analyzing overall need, I paused and decided it was going to be too complex and time consuming for my requirement, especially when it needed migration repetitively. So, I wanted to develop an automated solution to accomplish some repetitive tasks. But why reinvent the wheel? So, I started searching the internet for better solution. Fortunately, I came across a lightweight and nice open source utility called Gazer. Gazer is a command line utility that can be used for many tasks concerning managing a Looker Server, but in particular, migrating User Defined Content — saved Looks and Dashboards — between Looker instances. Just what I needed! Please keep in mind that Gazer is NOT an official supported product of Looker.

Gazer’s home page on GitHub (https://github.com/deangelo-llooker/gzr/wiki) is very informative and provides necessary details to kick-start. It currently supports 11 commands and several sub-commands tailored for each command. The most common commands are user, space, dashboard, look and plan. Some of the useful sub-commands are:

  • The user sub-commands are ls, me, cat, enable, disable, and delete.
  • The space sub-commands are ls, cat, tree, rm, create, and export.
  • The look and dashboard sub-commands are cat, import, and rm.
  • The plan sub-command is used to manage schedules.

Gazer’s GitHub page provides some information about these commands and how to use it.

Now let’s jump on how we can use Gazer and its commands to transfer contents from Development to Production instance.

1. Installation:

Follow Getting Started With Gazer (https://github.com/looker-open-source/gzr/wiki/Getting-Started) page for installation and setup. Gazer is deployed using the RubyGems distribution system. To install, make sure that Ruby 2.3 is installed on your system. Then use the command

gem install gazer

2. Test Connection with both Looker instances

Looker API3 Credentials for Development and Production Looker instances should be stored in $HOME/.netrc file. Edit this file to add or update credentials for your instances.

machine devlooker.example.com
login dsagfSADFSDgdfasfsa
password erewaEWFSDFVfsG234w4
machine prodlooker.example.com
login fdsDSFdfgsdFdsAfsDgasd
password 32rDFsfdsDFSASGG

Test connection to both Development and Production instances.

$ gzr user me —-host=devlooker.example.com
$ gzr user me —-host=prodlooker.example.com

3. Export space from Development instance

Retrieve list of spaces available in your instance.

$ gzr space top --host=devlooker.example.com

Retrieve list of contents from space and check to make sure all information is correct. eg. To retrieve list of all contents from space ID 124

$ gzr space ls 124 --host=devlooker.example.com

Once all contents are verified, let’s export the space from development instance.

$ gzr space export 124 --host=devlooker.example.com

Gazer creates a new directory with space name (eg. “Test — Transfer” in above example) in your local machine and exports all the contents within space into that directory. Review space is exported to your local machine.

$ ls -ltr

Change directory to the one just created by export (eg. “Test — Transfer”) and check to make sure all contents, including dashboards and looks, have been exported.

$ cd TEST\ -\ Transfer/$ ls

4. Import content into Production instance

At this point, Gazer doesn’t have native command to import entire space, but an interim solution is available through script. Individual dashboards and Looks can be imported.

Import Dashboard to Production instance

$ gzr dashboard import Dashboard_88_Test 1 Dashboard.json --host=prodlooker.example.com

Import Look to Production instance

$ gzr look import Look_140_Test 3 Look.json --host=prodlooker.example.com

Multiple commands can also be grouped into one batch script to execute and import content at once.

What’s Next?

The discussion on this post is just an introduction of Gazer for a real use case with export and import commands. Gazer’s GitHub page also describes many other commands and examples for reference. Gazer follows the traditional ideas about creating utilities in Unix. The output of Gazer command is usually in a format so that it can be easily fed into another Unix command. It can be leveraged for powerful automation and integration of certain tasks for Looker.

This is my first post in Medium! If you have any suggestions, questions or realize that I was wrong about something, be sure to let me know in the comments!

--

--