Gazer - A Command Line Tool for Looker Content Management

MikeD
Participant II

The Problem

User Defined Content (Dashboards and Looks) are not easily portable across Looker instances, nor can they be backed up and restored to a known state easily. It is not easy to monitor content creation, user activity, etc. In particular, it is not easy to do these activities from scripts that can be run by an operations team.

The Why

Gazer is a command line tool that provides an interface to a Looker instance for the purpose of managing content, users, schedules, etc. It can be used interactively, but also be included in scripts. Finally, it serves as a reference implementation for developers that want to build their own tools.

The How

Gazer currently has 11 commands. The most common commands are user, space, dashboard, look, and plan. Each command has several subcommands tailored for that command. The ls subcommand is very common and will produce a list of objects. The cat subcommand is also common, and will provide the json representation of an object. Typing gzr alone will list all the commands as well as the most common command line switches and options. Typing gzr COMMAND will list the subcommands for that particular command.

The user subcommands are ls, me, cat, enable, disable, and delete. So typing gzr user ls will list all the users on a Looker instance. Typing gzr user disable will disable the given user.

The space subcommands are ls, cat, tree, rm, create, and export. Typing gzr space ls will list the contents of a space. Typing gzr space export will create a set of files that describe the space, all its subspaces, and all the dashboards and looks in those spaces. They can be exported as a set of folders and files on disk suitable for storing in a code repository, or they can be exported into a tar or tgz export file. If they are stored in a code repository, it is easy to track changes over time.

The look and dashboard subcommands are cat, import, and rm. The cat subcommand can be used to save a single dashboard or look to a file. Typing gzr look import will load a look from a file. Typing gzr dashboard import will import a dashboard from a file. The file for the import subcommand can be obtained from the cat subcommand, or from the gzr space export command.

The plan subcommand is used to manage schedules. There are many subcommands, but typing gzr plan failures will list schedules that did not run properly, and gzr plan runit will rerun it.

More information and examples can be found at https://github.com/deangelo-llooker/gzr/wiki

The Setup

Gazer is deployed using the Ruby Gems distribution system. To install, make sure that Ruby 2.3 is installed on your system, then use the command gem install gazer.

This tool is open source. It is not supported by Looker’s normal support channels. It may be possible to purchase support from Looker’s Professional Services team. We are hoping that a community will grow around this tool, however, and support/enhance it further. Issues can be logged at https://github.com/deangelo-llooker/gzr/issues.

*Gazer is developed by Mike DeAngelo aka @MikeD *

13 18 13K
18 REPLIES 18

@MikeD what a great idea! Thanks for doing this. Can Gazer be used to identify broken Looks or dashboard tiles like the content validator does?

MikeD
Participant II

Not at the moment, Levi. But I will look into adding that!

Hello Mike

We are facing an issue while installing on EC2 .

[ec2-user@ip-10-69-1-20 ~]$ sudo gem install gazer
ERROR: While executing gem … (Gem::DependencyError)
Unable to resolve dependencies: tty-table requires equatable (~> 0.5.0); pastel requires equatable (~> 0.6)

Do you have any solution for the above problem ?

Thanks
Karthikeya

it’s resolved you can ignore.

Hi Mike,

I have a Mac (Version 10.14.5 (18F203)) with gem version 2.5.2.3, ruby version 2.3.7p456 (2018-03-28 revision 63024) [universal.x86_64-darwin18] and when I issue the command:

gem install gazer

I get this:

ERROR:  Could not find a valid gem 'looker-sdk-fork' (~> 0.0.6) in any repository
ERROR:  Possible alternatives: looker-sdk

How can I fix this?

I think that error is just a bit confusing, and what it really wants is any kind of looker-sdk.
If you install the “Possible Alternative” with gem install looker-sdk and then install gazer, you should be in business.

Thanks for pointers - it all works now.

mguindon
Participant III

Awesome tool!

I’ve encountered an issue using it on a dashboard that has tiles containing Merged results. Are Merged Results supposed to be supported by the tool, or is this a bug?

I’ve raised an issue on Github with the details.

AFAIK there still isn’t a merge_query api endpoint so I would imagine that’s a known limitation. I’m a 🐐! The merge query API is totally out.

I think github is probably the best place to raise the issue. Thanks Martin.

Hi,
I am getting the below error when i try to run gzr user me --host=ABC --client-id=XYZ --client-secret=xyz. Can someone please help

C:/Ruby26-x64/lib/ruby/2.6.0/net/http.rb:949:in `rescue in block in connect’: Failed to open TCP connection to abc.looker.com:19999 (A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. - connect(2) for “abc” port 19999) (Faraday::TimeoutError)

ruby Version:
ruby 2.6.6p146 (2020-03-31 revision 67876) [x64-mingw32]

gem version:
3.0.3

Its working fine now . I added --port 443 to the earlier command

There is an open PR from @mguindon to add that piece of information on the readme (for GCP instances)

gzr returns the connection error with --no-verify-ssl option is specified. ERROR: Connection Failed. Did you specify the --no-ssl option for an ssl secured...

We are using Gazer version 0.2.41 and using command “gzr look import Look_XXXX.json 17 --host XXXX --port 443 --client_id=XXXX --client_secret=XXXXXX --debug --force --timeout 120” to import looks. Looker is hosted in cluster mode in GCP instance group. We are getting below error intermittently. Could you please help me in this regard.

Error creating query({
“view”: “test_view_example”
.
.
.
})
RUBY/lib/ruby/gems/2.5.0/gems/looker-sdk-0.0.7/lib/looker-sdk/response/raise_error.rb:39:in on_complete' RUBY/lib/ruby/gems/2.5.0/gems/faraday-0.15.4/lib/faraday/response.rb:9:in block in call’
RUBY/lib/ruby/gems/2.5.0/gems/faraday-0.15.4/lib/faraday/response.rb:61:in `on_complete’
.
.
logout
ERROR: nginx 502 Bad Gateway

Hi,

I managed to successfully install the gem on a windows machine. I also created the .netrc file with the designated credentials.

However I’m still getting an error: “ERROR: Invalid credentials”, which I confirmed to be correct.

The  issue doesn’t seem to be the .netrc file since previously it had a .txt extension and I was getting a different error message “Error loading credentials from netrc file...” 

Could this be related to the 2 factor authentication settings in Looker? It’s enabled for this instance.

If that is the case, how can I solve this?

If not, what could be the issue?

Thanks,

Pc

It worked now!

I was using the login and password credentials instead of the client id and client secret generated by the API3.

@MikeD Can you elaborate on the comment on top

“Gazer does not support migrating Looks between Looker instances.”

Our plan was to export all shared folders using gazer and then push to Git for version control. Then push from git to a folder use Gazer to import content to new environments like demo, qa or prod. Is this still possible? If not what would you suggest as the best practice to backup content and also migrate content?

Hey @eganpj, that section applied to a specific issue in an older release with one of the endpoints used by gazer. The issue was fixed a while ago, and any supported version of Looker can move looks without issue now. I have removed that part of the doc.

im looking to move every dashboard and looks with the folder structure to another instance of looker. i found gzr space export 1 --host abc.xyz.com --dir .
which does imports the space with all the looks and dashboards but how do i import them to another instance with the same folder structure. hope im doing it right