This tool is a Google Sheets extension for capacity planning on Google Cloud. This tool extracts peak resource usage values and corresponding timestamps for a given Google Cloud project, time range and timezone.
-
Upload
capacity_planner_sheet.xlsxto Google Drive. -
Open
capacity_planner_sheet, which will be in XLSX mode. -
File > Save as Google Sheetsto convert to a Google Sheets file. -
Extensions > Apps Script. Copy all the.jsfiles in this directory to the Apps Script editor. There should be 3 files:main.gs,queries.gs, andsheets.gs. (They're saved as.jsfiles in GitHub for nice syntax highlighting, but you should save them as.gsfiles in AppsScript.) -
In Apps Script Settings, change the Google Cloud Project to a project you have permissions to use the Monitoring API in. (
roles/monitoring.vieweris sufficient) This project is only used for Monitoring API quota and billing purposes. It does not need to be the same project you want to collect metrics in.- Enable the Monitoring API in your Google Cloud project, if it is not already enabled.
- Collect the project number and paste the project number into Apps Script Settings.
-
In Apps Script settings, select the
Show "appsscript.json" manifest file in editorcheckbox. -
Go back to the editor and edit
appsscript.jsonto have theoauthScopesshown below. Do not edit the other fields.{ "timeZone": "Asia/Seoul", "dependencies": {}, "exceptionLogging": "STACKDRIVER", "runtimeVersion": "V8", "oauthScopes": [ "https://www.googleapis.com/auth/script.external_request", "https://www.googleapis.com/auth/monitoring.read", "https://www.googleapis.com/auth/spreadsheets" ] } -
Check that all Apps Script files have been saved, then refresh the Google Sheets tab. You should see a new menu item "Capacity Planner".
- Fill out the project id, end time, total duration in minutes, and the timezone.
Capacity Planner > Get Project Metrics. A sheet named{project_id}_rawis created for the specified project.- The first time you run the script, A pop up will ask you grant some permissions to your Google Account. Review the permissions and check "allow".
- Repeat 1. and 2. for any additional projects of interest.
Capacity Planner > Create Planning Sheetto create a combined sheet.- Fill in column F in the Combined Planning Sheet with the CCU value (pre-filled to 400,000) and the estimates for each metric. The rest of the sheet will update with the gap between the estimated and actual values.
Google Sheets will show a small popup if any errors occur during script execution. Click on "Details" to see more information.
During development it can be helpful to execute "Get Project Metrics" and "Create Planning Sheet" from the Apps Script UI instead of the Sheets UI. This allows you to view logs, use the debugger, and get stack traces with specific lines where the error occurred.
From main.gs, select the appropriate function:
createCapacityPlannerSheetfor "Create Planning Sheet"getProjectMetricsfor "Get Project Metrics"
The script will still fetch inputs from the sheet.


