我已经设置了一个计算引擎实例来运行我们管道的一部分,现在我对我得到的错误感到困惑,所以我真的很喜欢只是想要澄清所有这些如何工作以及如何使其正常工作,这样我就可以开始运行。
这是堆栈跟踪:
username@dev-instance-1:/var/local/path/to/pipeline$ python -m path.to.pipeline.file.properties sample-name-of-program-to-run
Setting up code base here...
INFO:urllib3.connectionpool:Starting new HTTPS connection (1): user.sample.com
DEBUG:urllib3.connectionpool:"POST /users/refresh_token.json HTTP/1.1" 401 41
INFO:urllib3.connectionpool:Starting new HTTPS connection (1): user.sample.com
DEBUG:urllib3.connectionpool:"POST /users/sign_in.json HTTP/1.1" 200 156
{'instance_zone': 'us-central1-a', 'project_resource': 'projects/sample-project', 'user': 'username', 'sample_config': '', 'metric_type': '', 'name': None, 'metric_name': '', 'server': None, 'instance': 'dev-instance-1', 'metric_type_base': 'custom.googleapis.com/', 'project_id': 'sample-project', 'metric_kind': 'GAUGE'}
INFO:googleapiclient.discovery:URL being requested: POST https://monitoring.googleapis.com/v3/projects/sample-project/metricDescriptors?alt=json
INFO:oauth2client.transport:Attempting refresh to obtain initial access_token
WARNING:googleapiclient.http:Encountered 403 Forbidden with reason "forbidden"
ERROR:root:CRASH! <HttpError 403 when requesting https://monitoring.googleapis.com/v3/projects/sample-project/metricDescriptors?alt=json returned "User is not authorized to access the project monitoring records.">
ERROR:root:<HttpError 403 when requesting https://monitoring.googleapis.com/v3/projects/sample-project/metricDescriptors?alt=json returned "User is not authorized to access the project monitoring records.">
Traceback (most recent call last):
File "/var/local/path/to/pipeline/file/properties.py", line 396, in <module>
main()
File "/var/local/path/to/pipeline/file/properties.py", line 392, in main
client.launch()
File "/var/local/path/to/pipeline/file/properties.py", line 205, in launch
self.stackdriver()
File "/var/local/path/to/pipeline/file/properties.py", line 104, in stackdriver
"description": "Server the data originates from: (US) Dev or (US) Field"
File "path/to/another/file/stackdriver.py", line 310, in create_metric
name=self.config['project_resource'], body=body).execute()
File "/usr/local/lib/python2.7/dist-packages/oauth2client/util.py", line 137, in positional_wrapper
return wrapped(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/googleapiclient/http.py", line 838, in execute
raise HttpError(resp, content, uri=self.uri)
HttpError: <HttpError 403 when requesting https://monitoring.googleapis.com/v3/projects/sample-project/metricDescriptors?alt=json returned "User is not authorized to access the project monitoring records.">
EXCEPTION!
如何使其正常工作?我正在开发一个单独的项目,而不是样本项目,所以这可能是问题,那么如何设置服务帐户以使这个系统在两者之间运行?