googleapis / google-cloud-java

Google Cloud Client Library for Java
https://cloud.google.com/java/docs/reference
Apache License 2.0
1.89k stars 1.06k forks source link

API Quotas for Monitoring #2576

Closed keitwb closed 6 years ago

keitwb commented 6 years ago

Hi, I'm using the MetricServiceClient for getting StackDriver timeseries. I am authenticating using a user oauth token (this user has access to multiple projects), but there seems to be a global quota across multiple projects because when I fetch only one or two projects at a time I have no throttling, but when I fetch four or five different projects at a time, I start getting throttled with errors like the following:

io.grpc.StatusRuntimeException: RESOURCE_EXHAUSTED: Insufficient tokens for quota 'DefaultGroup' and limit 'USER-100s' of service 'monitoring.googleapis.com' for consumer 'project_number:764086051850'.

The strange thing is, that project_number doesn't correspond to any project I am fetching, or even have access to -- it is meaningless to me.

This appears to be the quota for # of requests per 100 seconds, but I have that set to 10,000 on all projects and I'm not doing nearly that many requests, as the quota historical chart in the web console confirms.

Is there really some global quota that applies across multiple projects and if so, is there some way to work around it?

anthmgoogle commented 6 years ago

This looks like it might be because of using shared credentials such as with "gcloud auth application-default login". We recommend using a downloaded service account key and setting the environment variable GOOGLE_APPLICATION_CREDENTIALS to point to it: https://developers.google.com/identity/protocols/application-default-credentials#howtheywork This should let you adjust the quota for your API.

Please advise if this does not fixed the problem.

pongad commented 6 years ago

I'll close this due to inactivity. Please reopen if required.