【发布时间】:2017-09-12 22:08:39
【问题描述】:
我们正在使用我们自己的日志记录解决方案,因为 stackdriver 是 su...bpar。我想提取有关 pubsub 中有多少未确认消息的指标。开始阅读有关该文件的文档,它们到处都是。
找到这个页面: https://cloud.google.com/monitoring/api/metrics 尽管在 api 下,它没有描述任何 api 调用,但确实包含我要提取的指标的描述。
现在我想我需要使用监控 API 以某种方式提取我需要的内容: https://cloud.google.com/monitoring/api/ref_v3/rest/
所以我使用 api explorer 尝试了几种方法: https://developers.google.com/apis-explorer/#search/monitoring/monitoring/v3/monitoring.projects.groups.list
我查询并给了我一个可用的网址:
GET https://monitoring.googleapis.com/v3/projects/myprojectname/groups?key={YOUR_API_KEY}
我转到我的项目控制台(api 和凭据页面)并生成一个没有限制的 api 密钥并将其粘贴到试图 curl 中。
curl https://monitoring.googleapis.com/v3/projects/myproject/groups?key=myrandomkeylkjlkj
{
"error": {
"code": 401,
"message": "Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.",
"status": "UNAUTHENTICATED"
}
}
为什么会这样?如何获取指标?我去了提供的 url,但它解释了 oauth 令牌的创建,并且没有关于 api 密钥的内容。我只需要卷曲以确保我走的是正确的道路。
【问题讨论】:
标签: google-api google-cloud-platform monitoring google-kubernetes-engine google-authentication