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
CredentialsclickCreate credentials. - Select
Service account key. - Create
New service accountif needed (for Role, the limited Project > Viewer works). Key typeshould be JSON.- Click
Createand download thecredentials.jsonfile.
- 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 Keyto generate anothercredentials.jsonfile.
-
Copy
.env.exampleto.envthen copy/pasteclient_email=>GOOGLE_CLIENT_EMAILandprivate_key=>GOOGLE_PRIVATE_KEY(do not modify this at all). -
Add the value of
GOOGLE_CLIENT_EMAILwith Edit permissions to any Google Sheet(s) that will be used with this script. -
Run
npm ifrom within the project directory root. -
Copy
config.example.jstoconfig.jsand enter appropriateredashCsvUrl,spreadsheetId, andsheetIdvalues. It's an array of config objects so you can run multiple query to spreadsheet syncs.redashCsvUrlshould 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
.envandconfig.jsvalues 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_EMAILandGOOGLE_PRIVATE_KEYvalues into your Lambda Environment Variables. The.envfile 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.configcontaining 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.