我正在使用一个用 python2.7 编写的应用程序引擎应用程序来收集来自不同项目的监控指标。我从云外壳运行这个应用程序引擎应用程序部署在 projectA 中,它能够通过以下调用从 projectA 收集指标
service = build('monitoring', 'v3', cache_discovery=True)
project_name = 'projects/{project_id}'.format(
project_id=project_id
)
metrics = service.projects().metricDescriptors().list(
name=project_name,
pageSize=config.PAGE_SIZE,
pageToken=next_page_token
).execute()
这个调用是循环编写的,现在我需要收集 ProjectB 指标,我拥有 ProjectB 的所有者访问权限。当 ProjectB 作为参数传递给 project_id 时,我收到以下错误:
logMessage: "Error: <HttpError 403 when requesting https://monitoring.googleapis.com/v3/projects/ProjectB/metricDescriptors?pageToken=&alt=json&pageSize=500 returned "Permission monitoring.metricDescriptors.list denied (or the resource may not exist).">"
severity: "ERROR"
sourceLocation: {
file: "/base/data/home/apps/s~ProjectA/list-metrics:20200706t123743.427891295940019389/main.py"
functionName: "post"
line: "665"
}
time: "2020-07-06T16:10:43.724399Z"
我不确定应该做些什么来完成这项工作?我对谷歌云及其api非常陌生,对应用引擎也很陌生,python2.7请帮忙,谢谢