gcp-idle-resources-metrics

command module
v1.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 1, 2022 License: GPL-3.0 Imports: 21 Imported by: 0

README

gcp-idle-resources-metrics

Identify unused resources at Google Cloud Platform through Prometheus' metrics

Usage

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)

Development building and running

Prerequisites:

Building:

make build

Running:

./server -h
./server --project-id=x --regions=us-central1,us-east1

Running tests

make test

Collectors

Current supported APIs:

To enable only some specific collector(s):

./server --collector.disable-defaults --collector.gce_is_disk_attached --collector.gce_is_old_snapshot
Docker
cp ~/.config/gcloud/application_default_credentials.json ./credentials.json

chmod 444 credentials.json

docker build -t gcp-idle-resources-metrics . 

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-idle-resources-metrics

Check the exported metrics.

Kubernetes

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-idle-resources-metrics > values.yaml

Edit the values according to your needs then install the application

helm upgrade -i gcp-idle-resources-metrics --values values.yaml 7onn/gcp-idle-resources-metrics

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
Package collector includes all individual collectors to gather and export system metrics.
Package collector includes all individual collectors to gather and export system metrics.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL