Keep an eye on your GCP costs right from your wrist. Don't let autoscaling silently run up your bill — stay informed with a quick glance at your iPhone or Apple Watch.
Here's the plan:
- Configure GCP billing export to a BigQuery table
- Create an n8n workflow that queries BigQuery for cost data
- Set up a widget in API Widgets to display the results
Configure GCP Billing Export to BigQuery
1. Enable the BigQuery API in GCP
2. Enable billing export to BigQuery
3. Create a service account for BigQuery access
gcloud iam service-accounts create n8n-bigquery-reader \
--display-name="n8n BigQuery Reader" \
--project=YOUR_PROJECT_ID
4. Assign minimal permissions
The service account needs just two roles:
-
bigquery.jobUser— allows running queries -
bigquery.dataViewer— allows reading tables and views (read-only)
# Allow running queries and reading results
gcloud projects add-iam-policy-binding YOUR_PROJECT_ID \
--member="serviceAccount:n8n-bigquery-reader@YOUR_PROJECT_ID.iam.gserviceaccount.com" \
--role="roles/bigquery.jobUser"
# Allow reading data from datasets and tables
gcloud projects add-iam-policy-binding YOUR_PROJECT_ID \
--member="serviceAccount:n8n-bigquery-reader@YOUR_PROJECT_ID.iam.gserviceaccount.com" \
--role="roles/bigquery.dataViewer"
5. Generate a service account key for n8n
gcloud iam service-accounts keys create n8n-bigquery-key.json \
--iam-account=n8n-bigquery-reader@YOUR_PROJECT_ID.iam.gserviceaccount.com
This generates a n8n-bigquery-key.json file containing the service account credentials. You'll use this file to authenticate the BigQuery node in n8n.
Set Up the n8n Workflow
The workflow exposes a webhook endpoint that API Widgets can call. When triggered, it queries BigQuery for your billing data, groups costs by date and service, and returns the results as JSON.
The workflow consists of five nodes:
-
Webhook — listens for incoming requests (accepts an optional
daysquery parameter, defaults to 14) - Configure variables — sets the BigQuery table name and the number of days to query
- Execute BigQuery — runs a SQL query that aggregates daily costs by service
- Format data — transforms the results into a structured JSON response with daily totals and per-service breakdowns
- Respond to Webhook — sends the formatted data back to the caller
You can import the workflow into your n8n instance using the JSON file: GCP Billing costs.json. Make sure to update the table_name variable in the "Configure variables" node to match your BigQuery billing export table.
Configure API Widgets
1. Download API Widgets from the App Store.
2. Create a new widget and configure the API endpoint in the Source tab, pointing it to your n8n webhook URL.
3. Set up the visualization in the Design tab.
4. Add a home screen widget and link it to the one you just created.
The widget also works on Apple Watch — view your costs at a glance from your wrist:









Top comments (0)