{"id":24629571,"url":"https://github.com/framsouza/gathering-cloudsql-metrics","last_synced_at":"2026-05-13T12:34:55.966Z","repository":{"id":168612656,"uuid":"526596777","full_name":"framsouza/gathering-cloudsql-metrics","owner":"framsouza","description":"Fetch Google Cloud SQL metrics and send it to a Pub/Sub","archived":false,"fork":false,"pushed_at":"2022-08-22T08:09:46.000Z","size":33,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-29T20:53:50.940Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/framsouza.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-08-19T12:22:40.000Z","updated_at":"2022-09-07T07:38:06.000Z","dependencies_parsed_at":null,"dependency_job_id":"e2d9952a-0c11-469c-bc01-f8297f22e62a","html_url":"https://github.com/framsouza/gathering-cloudsql-metrics","commit_stats":null,"previous_names":["framsouza/gathering-cloudsql-metrics"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/framsouza/gathering-cloudsql-metrics","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/framsouza%2Fgathering-cloudsql-metrics","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/framsouza%2Fgathering-cloudsql-metrics/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/framsouza%2Fgathering-cloudsql-metrics/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/framsouza%2Fgathering-cloudsql-metrics/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/framsouza","download_url":"https://codeload.github.com/framsouza/gathering-cloudsql-metrics/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/framsouza%2Fgathering-cloudsql-metrics/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32982971,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-13T11:31:52.688Z","status":"ssl_error","status_checked_at":"2026-05-13T11:31:52.072Z","response_time":115,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":[],"created_at":"2025-01-25T06:13:17.952Z","updated_at":"2026-05-13T12:34:55.957Z","avatar_url":"https://github.com/framsouza.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Gathering Google Cloud SQL metrics\n\nThis code will connect to the Cloud Monitoring API, gather the metrics from Google Cloud SQL and send it to a Cloud Pub/Sub. This function executes each 60 seconds, right now, the metrics that are being collected are:\n\n- disk utilization\n- memory utilization\n- cpu utilization\n- active connections \n- total memory\n\nFor more metrics, please check [Google Cloud SQL metrics](https://cloud.google.com/monitoring/api/metrics_gcp#gcp-cloudsql).\n\n### Usage\n\nFirst, make sure you have the `GOOGLE_APPLICATION_CREDENTIALS` environment variable set as per the [google docs](https://cloud.google.com/docs/authentication/production).\n\nIt will require one argument which is `project` and `topic`. Make sure to create the topic before run this code, it won't automatically create it.\n\nYou can choose to build the binary by running\n```\ngo build -o gathering-cloudsql-metrics\n```\n\nand run it as\n```\n./gathering-cloudsql-metrics -project=\u003cPROJECTNAME\u003e -topic=test-topic\n```\n\nor without building the binary\n```\ngo run main.go -project=\u003cPROJECTNAME\u003e\n```\n\n## Output expected\nYou will have an output like the following:\n\n```\nConnecting with topic: pull-cloud-monitoring-db01-sub\n\nCloudSQL CPU Utilization (%)\nstarttime: 2022-08-22T07:28:00Z endttime: 2022-08-22T07:29:00Z name: my-gcp-project:db-dev value: 2.5237555640205755\nPublished a message; msg ID: 5371724353696475\nstarttime: 2022-08-22T07:28:00Z endttime: 2022-08-22T07:29:00Z name: my-gcp-project:db01 value: 2.344554992491794\nPublished a message; msg ID: 5371720838171288\n\nCloudSQL memory total usage\nstarttime: 2022-08-22T07:28:00Z endttime: 2022-08-22T07:29:00Z name my-gcp-project:db-dev value: 0 GB\nPublished a message; msg ID: 5371723455172154\nstarttime: 2022-08-22T07:28:00Z endttime: 2022-08-22T07:29:00Z name my-gcp-project:db01 value: 0 GB\nPublished a message; msg ID: 5371720838169768\n\nCloudSQL memory total size\nstarttime: 2022-08-22T07:27:00Z endttime: 2022-08-22T07:28:00Z name my-gcp-project:db-dev value: 8 GB\nPublished a message; msg ID: 5371721896997627\nstarttime: 2022-08-22T07:27:00Z endttime: 2022-08-22T07:28:00Z name my-gcp-project:db01 value: 8 GB\nPublished a message; msg ID: 5371721398656734\n\nCloudSQL Active Connections\nstarttime: 2022-08-22T07:28:00Z endttime: 2022-08-22T07:29:00Z name: my-gcp-project:db01 value: 4\nPublished a message; msg ID: 5371721741725995\nstarttime: 2022-08-22T07:27:00Z endttime: 2022-08-22T07:28:00Z name: my-gcp-project:db-dev value: 2\nPublished a message; msg ID: 5371722466560998\nstarttime: 2022-08-22T07:27:00Z endttime: 2022-08-22T07:28:00Z name: my-gcp-project:db-dev value: 0\nPublished a message; msg ID: 5371721954124203\nstarttime: 2022-08-22T07:27:00Z endttime: 2022-08-22T07:28:00Z name: my-gcp-project:db-dev value: 0\nPublished a message; msg ID: 5371721968467596\n\nCloudSQL Disk Utilization\nstarttime: 2022-08-22T07:27:00Z endttime: 2022-08-22T07:28:00Z name: my-gcp-project:db-dev value: 0 GB\nPublished a message; msg ID: 5371723698374426\nstarttime: 2022-08-22T07:27:00Z endttime: 2022-08-22T07:28:00Z name: my-gcp-project:db01 value: 1 GB\nPublished a message; msg ID: 5371722447240568\n```\n\nWhere `my-gcp-project` is the Google project name, `db01` and `db-dev` are the Cloud SQL instances running. You will see the same output on a Pub/Sub you have configured.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fframsouza%2Fgathering-cloudsql-metrics","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fframsouza%2Fgathering-cloudsql-metrics","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fframsouza%2Fgathering-cloudsql-metrics/lists"}