{"id":27969183,"url":"https://github.com/future-architect/gbilling-plot","last_synced_at":"2025-10-17T02:45:44.705Z","repository":{"id":35086517,"uuid":"198406561","full_name":"future-architect/gbilling-plot","owner":"future-architect","description":"Create graphed invoice for Google Cloud Platform. You can see billing amount per GCP project.","archived":false,"fork":false,"pushed_at":"2022-02-28T12:22:37.000Z","size":222,"stargazers_count":11,"open_issues_count":7,"forks_count":6,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-07T21:08:50.501Z","etag":null,"topics":["bigquery","billing","cloud-scheduler","gcp-billing","go","golang","slack"],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/future-architect.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-07-23T10:20:07.000Z","updated_at":"2024-01-19T10:26:31.000Z","dependencies_parsed_at":"2022-08-08T05:00:33.674Z","dependency_job_id":null,"html_url":"https://github.com/future-architect/gbilling-plot","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/future-architect%2Fgbilling-plot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/future-architect%2Fgbilling-plot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/future-architect%2Fgbilling-plot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/future-architect%2Fgbilling-plot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/future-architect","download_url":"https://codeload.github.com/future-architect/gbilling-plot/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252954409,"owners_count":21830905,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bigquery","billing","cloud-scheduler","gcp-billing","go","golang","slack"],"created_at":"2025-05-07T21:08:55.407Z","updated_at":"2025-10-17T02:45:39.671Z","avatar_url":"https://github.com/future-architect.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# gbilling-plot\n![go version 1.12](https://img.shields.io/badge/go-v1.12-green.svg)\n[![Apache 2.0 License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](LICENSE)\n[![Go Report Card](https://goreportcard.com/badge/github.com/future-architect/gbilling-plot)](https://goreportcard.com/report/github.com/future-architect/gcp-instance-scheduler)\n\nCreate graphed invoice for Google Cloud Platform. You can see billing amount per GCP project.\n\n## Usage\n\nThis package uses below great services.\n\n- Google Cloud Billing（BigQuery）\n- Google Cloud Functions\n- Google Cloud Pub/Sub\n- Google Cloud Scheduler\n- Slack API\n\n## QuickStart\n\n1. Install\n    ```console\n    go get -u go get -u github.com/future-architect/gbilling-plot/cmd/gbplot\n    ```\n2. Obtain GCP Service credentials that must have `bigquery.tables.getData` and `bigquery.jobs.create` permission\n  * You can assign predefined Cloud IAM roles that are `dataViewer` and `jobUser`\n3. Set environment variable\n    ```bash\n    export GOOGLE_APPLICATION_CREDENTIALS=\u003ccredentials path\u003e\n    ```\n4. Export your GCP billing to BigQuery\n    * https://cloud.google.com/billing/docs/how-to/export-data-bigquery\n5. Run command\n    ```bash\n    gbplot -project \u003cyour project name\u003e -table \u003cyour billing table name on bigquery\u003e -out out.png\n    ```\n6. You can confirm out.png file\n\n## Options\n\n```console\n$ gbplot --help\n  Usage of gbplot:\n    -l int\n          Max display project count (default 8)\n    -limit int\n          Max display project count (default 8)\n    -o string\n          Output file name (default \"out.png\")\n    -out string\n          Output file name (default \"out.png\")\n    -p string\n          GCP project name\n    -project string\n          GCP project name\n    -t string\n          BigQuery billing table name\n    -table string\n          BigQuery billing table name\n```\n\n## Deploy Google Cloud Function \n\n### Requirements\n\n* [Go](https://golang.org/dl/) more than 1.11\n* [Cloud SDK](https://cloud.google.com/sdk/install/)\n\n### Steps\n\n1. [Get Slack API Token](https://get.slack.help/hc/en-us/articles/215770388-Create-and-regenerate-API-tokens#-internal-app-tokens)\n    * Permission Scopes is required `files:write:user`\n    * Create `Bot User OAuth Access Token` and `Install App`\n2. [Create Slack Bot User](https://get.slack.help/hc/en-us/articles/215770388-Create-and-regenerate-API-tokens#-bot-user-tokens)\n    * invite bot user to slack channel\n3. [Export your GCP billing to BigQuery](https://cloud.google.com/billing/docs/how-to/export-data-bigquery)\n4. Create Cloud Scheduler\n    ```sh\n    gcloud beta scheduler jobs create pubsub graph-billing --project \"\u003cyour project name\u003e\" \\\n      --schedule \"50 23 * * *\" \\\n      --topic graph-billing \\\n      --message-body=\"{}\" \\\n      --time-zone \"Asia/Tokyo\" \\\n      --description \"This is scheduler for graph billing.\"\n    ```\n5. Deploy to Cloud Function\n    ```sh\n    git clone https://github.com/future-architect/gbilling-plot.git\n    cd gbilling-plot\n    gcloud functions deploy graphBilling --project \"\u003cyour project name\u003e\" \\\n      --entry-point GraphedBilling \\\n      --triggerz-resource graph-billing \\\n      --trigger-event google.pubsub.topic.publish \\\n      --runtime go111 \\\n      --set-env-vars TABLE_NAME=\"\u003cyour billing table name on bigquery\u003e\" \\\n      --set-env-vars SLACK_API_TOKEN=\"\u003cyour slack api token\u003e\" \\\n      --set-env-vars SLACK_CHANNEL=\"\u003cyour slack channel name\u003e\"\n    ```\n6. Go to the [Cloud Scheduler page](https://cloud.google.com/scheduler/docs/tut-pub-sub) and click the *run now* button of *graphBilling*\n\n## Example\n\nSample output is below.\n\n![example](img/example_grapth.png)\n\n## License\n\nThis project is licensed under the Apache License 2.0 License - see the [LICENSE](LICENSE) file for details\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffuture-architect%2Fgbilling-plot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffuture-architect%2Fgbilling-plot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffuture-architect%2Fgbilling-plot/lists"}