【问题标题】:How to pull pubsub metrics from google api如何从 google api 中提取 pubsub 指标
【发布时间】: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


    【解决方案1】:

    为什么要这么难?杀死了我生命中的几个小时试图得到这个。

    curl -H "Authorization: Bearer $(gcloud config config-helper --format='value(credential.access_token)')" https://monitoring.googleapis.com/v3/projects/myproject/groups

    【讨论】:

      猜你喜欢
      • 2016-12-31
      • 1970-01-01
      • 2020-09-14
      • 2023-02-10
      • 1970-01-01
      • 2018-06-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多