MagicMirror MichMich module to display GCP (Google Cloud Platform) billing over the last few days.
This module helps you track expense on a GCP project over the last few days. In particular:
- spent increasing is shown in blue
- spent decreasing is shown in green
- spent over your set limit is shown in red (optional)
- amount is shown for everyday below the column bar
It relies on the @google-cloud/bigquery module. You can dig for more information those gcp node.js examples.
- if you do not have a GCP account set one up :D
- Set up billing export to BigQuery for the GCP project -> please take note of the table name for later (
lines.table
) - Create a service account with (
BigQuery User
) Role (do queries), and (Viewer
) Role (access the table). More details on BigQuery Access Control - Download the service account as JSON. More information on Service Accounts keys
- Copy this key to a location reachable by the module - path to the file will be set in the module configuration (
lines.serviceAccountKey
).
- Clone repository into
../modules/
inside your MagicMirror folder. - Run
npm install
inside../modules/MMM-GCP/
folder - Add the module to the MagicMirror config
{
module: 'MMM-GCP',
position: 'bottom_right',
header: 'GCP billing daily trend',
config: {
}
},
The lines
array contains information on the project to monitor (it will give possibility to monitor several projects).
type
: mandatory: only one possible value for the time being:billing
projectId
: mandatory: GCP project Idtable
: mandatory: name of the table as dataset.table, ex:project_billing.gcp_billing_export_v1_12321B_2343_234FD
serviceAccountKey
: mandatory: path to the Service Account Json private key, ex:/home/pi/MagicMirror/modules/MMM-GCP/SA.json
label
: optional: usual name to be displayedcostLimit
: optional: integer: cost above which the daily spent is displayed in red, ex: 700, default: nonedayTrendLength
: optional: integer: number of days to display, default: 10updateInterval
: optional: integer: number of ms to wait between two information request, default:1 * 60 * 1000 * 60 * 6
6 hours
{
lines: [
{
type: 'billing',
label: 'da4throux GCP',
projectId: 'gcp_project_id',
table: 'project_billing.gcp_billing_export_v1_12321B_2343_234FD',
serviceAccountKey: '/home/pi/MagicMirror/modules/MMM-GCP/SA.json',
costLimit: 700,
dayTrendLength: 12,
},
],
}
#0.1