Identify unused resources at Google Cloud Platform through Prometheus' metrics
Set up a service account on the project you want to monitor. To comprehend all collectors' required permissions, you have to grant:
roles/compute.viewer
roles/dataproc.viewer
You can authenticate by setting the Application Default Credentials (i.e: Placing the service account's JSON key and setting the environment variable GOOGLE_APPLICATION_CREDENTIALS=path-to-credentials.json
) or letting the application automatically load the credentials from metadata (Workload Identity is recommended).
You must set at least the project ID and the regions you want to monitor. Either by:
- Specifying through command args
--project_id --regions us-east1,us-central1
- Specifying through environment variables
GCP_PROJECT_ID= GCP_REGIONS=us-east1,us-central1
(if authenticating through metadata, the project doesn't need to be specified)
Prerequisites:
Building:
make build
Running:
./server -h
./server --project-id=x --regions=us-central1,us-east1
Running tests
make test
Current supported APIs:
To enable only some specific collector(s):
./server --collector.disable-defaults --collector.gce_is_disk_attached --collector.gce_disk_snapshot
Visit our wiki for more information.
cp ~/.config/gcloud/application_default_credentials.json ./credentials.json
chmod 444 credentials.json
docker build -t gcp-idleness-exporter .
docker run -it --rm --network=host \
-v $(pwd)/credentials.json:/credentials.json \
-e GOOGLE_APPLICATION_CREDENTIALS=/credentials.json \
-e GCP_PROJECT_ID= \
-e GCP_REGIONS=us-east1,us-central1,southamerica-east1 \
gcp-idleness-exporter
Check the exported metrics.
Add the Chart repository
helm repo add 7onn https://www.7onn.dev/helm-charts
helm search repo 7onn
Export its default values
helm show values 7onn/gcp-idleness-exporter > values.yaml
Edit the values according to your needs then install the application
helm upgrade -i gcp-idleness-exporter --values values.yaml 7onn/gcp-idleness-exporter