Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set an alert when quota API limit is reached on GCP

Is there a way to setup Stackdriver to receive an alert when ANY of my Google APIs usage have reached its limit?

I used to manually check at https://console.cloud.google.com/iam-admin/quotas but I can't figure out how to be automatically alerted.

like image 968
Frantz Gauthier Avatar asked Oct 16 '22 10:10

Frantz Gauthier


2 Answers

It looks like you can do at least some through Stackdriver. Open Stackdriver Monitoring and use theMetrics Explorer. Search for "Consumer Quota" as the resource and choose your metric. It'll display all the APIs enabled. Locate your API and add a filter.

For example, I wanted to monitor Vision API landmark detection calls so my filter was quota_metric and the value was "vision.googleapis.com/landmark_detection_requests". Once you know the filter you need, you should be able to create an alert.

See how you get on.

like image 146
gmerrall Avatar answered Nov 03 '22 23:11

gmerrall


There's this Github repo that shows how you can integrate GCE Quotas into Stackdriver.

It basically gets the amount of CPUs available per region and gives you the % that is in use, storing these values into Stackdriver as custom metrics. Then, you can configure alerts in Stackdriver to notify you when you pass a threshold.

The script may be a guide that can be used to integrate additional metrics.

like image 33
medarz Avatar answered Nov 03 '22 23:11

medarz