At G/O we use Looker as a BI tool. The Looker UI allows us to define dashboards, and schedule the sending of those dashboards as PDF attachments in an email. Sometimes we want to include multiple dashboards in a single PDF attachment, but we can’t do that via the Looker UI, as far as we can tell. So, we’ve created our own tool to stitch Looker dashboards together into a single PDF.
We generate a Python SDK for the Looker API using Swagger, and following instructions here. We use that SDK to download the PDFs for each dashboard. We then use the PyPDF library to put the dashboards together into a single PDF. We’ve made a CLI version our dashboard combining process available on GitHub.
The CLI (defined using the Click library) takes as its arguments a JSON config file and the name of the output PDF. The JSON config file specifies the IDs of the dashboards to render, along with other optional arguments that are passed to the Looker create_dashboard_render_task API call. The config file looks something like this:
The CLI also takes parameters for authenticating with the Looker API (
—client-secret), and those authentication parameters can also be specified as environment variables (
LOOKER_CLIENT_SECRET). The full usage details for the CLI are as follows:
The code in the GitHub repo does not include scheduling/emailing functionality. In our production set-up we use Advanced Python Scheduler to schedule the creation of PDFs, and we use Mandrill to send the PDFs as email attachments.