This repo is not maintained. It also has a complex setup and requires configuration in a lot of different places.
Please use the python-based redash-uploader (https://github.com/MoveOnOrg/redash-uploader)
This Node.js script fetches Redash query results and inserts them into a specified Google Sheet via API.
Google Sheets Node.js API Reference
-
Enable Sheets API in your new project.
-
Create Service Account Key:
- Under
Credentials
clickCreate credentials
. - Select
Service account key
. - Create
New service account
if needed (for Role, the limited Project > Viewer works). Key type
should be JSON.- Click
Create
and download thecredentials.json
file.
- Under
- If you already have a Service Account Key created, but do not have the Private Key, you will need to create another by selecting the existing Service Account, select
Edit
, and then+ Create Key
to generate anothercredentials.json
file.
-
Copy
.env.example
to.env
then copy/pasteclient_email
=>GOOGLE_CLIENT_EMAIL
andprivate_key
=>GOOGLE_PRIVATE_KEY
(do not modify this at all). -
Add the value of
GOOGLE_CLIENT_EMAIL
with Edit permissions to any Google Sheet(s) that will be used with this script. -
Run
npm i
from within the project directory root. -
Copy
config.example.js
toconfig.js
and enter appropriateredashCsvUrl
,spreadsheetId
, andsheetId
values. It's an array of config objects so you can run multiple query to spreadsheet syncs.redashCsvUrl
should probably be an http:// URL, unless you want to edit this program so it can use the VPN certificate. -
Run
npm test
.-
If your Redash instance is hosted behind a VPN you will need to be logged in or the tests will timeout.
-
Otherwise, if tests fail your
.env
andconfig.js
values likely need to be fixed.
-
-
To run script locally or in traditional server deployment, run
npm start
.
Running npm run prepare-lambda-script
from within a working local install will generate a redash-to-google-sheets.zip
file that can be uploaded and run on Amazon Lambda. This file is built using Webpack in order to tree-shake and minify.
-
Set your Lambda Node.js version to v8.10.0
-
Enter your
GOOGLE_CLIENT_EMAIL
andGOOGLE_PRIVATE_KEY
values into your Lambda Environment Variables. The.env
file is not contained in the deployment .zip file. -
The config.js file is also not deployed to Lambda, so you will need to add
event.config
containing a single object with config values (see above). Each query to spreadsheet sync needs to be it's own event configuration. -
Configure Lambda to have access to VPN resources if Redash is hosted behind VPN.