Skip to content

Leaving PopSQL?

Import from PopSQL →

Google Sheets

Wiring up Google Sheets: what to create at the provider, what to paste here, what goes in Target, and how to test before depending on it.

What it is

Writes the report rows to a tab of a Google Sheets spreadsheet, through a service account. Each run replaces the tab, or adds rows under it.

Set up

About 10 minutes to a working channel.

  1. 01Create a service account key. In Google Cloud, enable the Google Sheets API on a project. Then create a service account, and add a JSON key to it (IAM → Service accounts → Keys → Add key → JSON).
  2. 02Share the spreadsheet with the service account. Open the spreadsheet → Share, and add the client_email from the key file (it ends in .iam.gserviceaccount.com) as Editor.
  3. 03Paste the key and the spreadsheet. Paste the whole JSON file into Service account JSON, and the spreadsheet link or id into Spreadsheet. Test reads the spreadsheet to confirm it can see it.
  4. 04Attach it to a report. Report → Destinations → Channel, and set the Target to the tab name. The rows are the run’s result as masked for delivery, the same ones the e-mail carries.

Fields

FieldRequiredWhat it is
SpreadsheetYesThe browser link, or the id between /d/ and /edit in it. (https://docs.google.com/spreadsheets/d/…/edit)
Service account JSONYesPaste the whole key file. Treated as a secret. Share the spreadsheet with its client_email as Editor. ({"type":"service_account", …})

What goes in Target

The tab name in the spreadsheet, e.g. Sheet1. Add |append to add rows under the existing ones (Sheet1|append); without it, each run replaces the tab. Leave it empty for the first tab.

Target is optional for this channel. — tab name, e.g. Sheet1 (or Sheet1|append)

Test

Every channel has a Test button in the channel list (Settings → Channels). The result is kept (date, status and the provider's error when there was one), and a channel that was never tested is marked in the list.

Check it end to end

  1. 01Report: open a report, add this channel under Destinations (with the Target when the channel needs one), click Run now and open the run. The log says which channel each recipient went through and what the provider answered.
  2. 02Alert: under Monitoring → Alert routes, create a route with this channel as an escalation step. Routes match on severity and source; the first match wins.
  3. 03To fire an alert without breaking anything: use a test database you can switch off, and create a database monitor pointing at it, on a short interval. When it goes down the alert leaves through the route; delete the monitor afterwards. The message carries an acknowledge link; click it and the escalation stops.
  4. 04Report rules (new rows, value out of range) arrive through the same route, with source "report rule".

What most often goes wrong

The service account only sees spreadsheets shared with its client_email. Share the spreadsheet with that address as Editor, or every run and Test fails with 403.