GeezerVison is showing github.com — Wrong project ID when running cloud monitoring custom metrics sample · Issue #244 · GoogleCloudPlatform/python-docs-samples
Wrong project ID when running cloud monitoring custom metrics sample #244Labels 🚨This issue needs some love.triage meI really want to be triaged. DescriptionTrying to run this sample:
https://github.com/GoogleCloudPlatform/python-docs-samples/blob/master/monitoring/api/v3/custom_metric.py
Command is:
python custom_metric.py --project_id=evennia-game-directory
Output is:
File "/home/gtaylor/workspace/evennia-game-dir/evennia_gamedir/views/game_list.py", line 13, in game_list
metric_poop()
File "/home/gtaylor/workspace/evennia-game-dir/evennia_gamedir/views/game_list.py", line 60, in metric_poop
name=project_resource, body=metrics_descriptor).execute()
File "/home/gtaylor/workspace/evennia-game-dir/lib/oauth2client/util.py", line 137, in positional_wrapper
return wrapped(*args, **kwargs)
File "/home/gtaylor/workspace/evennia-game-dir/lib/googleapiclient/http.py", line 760, in execute
raise HttpError(resp, content, uri=self.uri)
HttpError: <HttpError 403 when requesting https://monitoring.googleapis.com/v3/projects/evennia-game-directory/metricDescriptors?alt=json returned "Google Monitoring API has not been used in project 32555940559 before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/monitoring/overview?project=32555940559 then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.">
INFO 2016-04-07 05:43:27,970 module.py:787] default: "GET / HTTP/1.1" 500 291
It's tossing out a weird project ID, so when I follow the link I get something odd:

Seems like it's got me in some invalid project.
If I go to the actual project and look at the permissions, I've got them enabled (as of 20+ minutes ago):

Any ideas? I'm aiming to get this working within App Engine, which I'm not sure is even possible. I'm running these samples from my dev machine with the latest gcloud SDK after having done gcloud auth login. Activitywaprin commented on Apr 7, 2016 Use gcloud beta auth application-default login instead of gcloud auth login.
It's a long story, but the short one is that monitoring is a unique API in that the project making the project is billed, so gcloud auth login does not provide the correct credentials. The new command is designed to fix it, and eventually will be recommended for all local code samples (gcloud auth login will only be for actual gcloud commands).
You may also just need to wait a few minutes and/or click on the actual Stackdriver Monitoring screen in the Cloud console and add your account to Stackdriver.
Sorry for the complexity :-\ gtaylor commented on Apr 7, 2016 ContributorAuthor More actions Using your suggested beta equivalent seems to have fixed things. Thanks! waprin commented on Apr 7, 2016 Cool, @gtaylor just FYI some other APIs might not work with the beta command and will need gcloud auth login. We realize this is a messy story right now, trying to fix it up. The most reliabiable, consistent way to make sure this works is to create a service account and download a JSON key file and point GOOGLE_APPLICATION_CREDENTIALS environment variable to the key file. Just a heads up. gtaylor commented on Apr 7, 2016 ContributorAuthor More actions Thanks, I might go on ahead and do that.
MetadataMetadata🚨This issue needs some love.triage meI really want to be triaged. DevelopmentNo branches or pull requestsIssue actions
|