I was wondering if there is a way to fetch the actual quota usage of a Google Cloud Service via the Google API like the information provided in the Cloud Console.
As far as I've researched there are multiple APIs regarding this topic:
This API only lists services and allows enabling/disabling services.
These endpoints only allow viewing (and modifying) the Quota limits. Going by the screenshot above, values 50k, 1.8m, 180k.
Would be the closest candidate but haven't figured out how to configure the permissions yet (Permission monitoring.monitoredResourceDescriptors.list denied
) and it looks like those endpoints would only deliver data from their infrastructure products like Compute, Storage, Data Analytics, etc.
Did anyone manage to get actual usage metrics / remaining quota counts for a Google Cloud service - here especially for the YouTube Data API? Unfortunately Google also doesn't send any Rate-Limit headers with their API responses.
Thanks!!
I just passed through all you described above, and finally succeed:
Cloud Monitoring API
to your app to get access to the monitoring.googleapis.com
domain (listed as Stackdriver Monitoring API
in the API list).Cloud Monitoring API
is an Entreprise
product and is not free anymore after a certain amount of requests (> 1Million request so you will be probably fine).https://monitoring.googleapis.com/v3/projects/{YourProjectId}/timeSeries
route using an interval.startTime
and a interval.endTime
interval parameter (I'm personally using start and end of the day based on my current GMT+ diff as the quota is reset every day). {YourProjectId}
is displayed when you go in Google Cloud Console and select your project in the drop box top left. The most difficult part of all of that is the last parameter named filter
that took me a big while to figure out: 'metric.type="serviceruntime.googleapis.com/quota/rate/net_usage" AND resource.labels.service="youtube.googleapis.com"',
YoutubeApi
quota.Note: Keep in mind that the value you get from their API is the one at the moment you make the query, if you have parallels calls, you will probably get a wrong value. I'm personally using this call just to help sync the quota reset on the beginning of the day.
Sources: