【问题标题】:How retrieve metrics from pubsub outside Stackdriver如何从 Stackdriver 外部的 pubsub 检索指标
【发布时间】:2017-02-18 07:28:58
【问题描述】:

我想知道如何从 API 检索指标 pubsub。 (我看到这个话题Google PubSub - Counting messages in topic,但不是同一个问题)。

当我尝试从 Logging API 检索它们时,它返回 404 错误。

这是不可能的,还是只是缺乏权利?

Client error: `GET https://logging.googleapis.com/v2/projects/my-project/metrics/pubsub.googleapis.com/topic/send_message_operation_count` resulted in a `404 Not Found`

感谢您的宝贵时间!

【问题讨论】:

    标签: google-cloud-pubsub


    【解决方案1】:

    Stackdriver MonitoringStackdriver Logging 是不同的。来自 Pub/Sub 的指标是作为 Stackdriver Monitoring 的一部分收集的。 logging.googleapis.com API 是 Stackdriver Logging 的一部分,用于搜索、分析和监控您的日志。

    要访问send_message_operation_count 指标,您需要使用timeSeries.list 方法。您可以将filter 设置为metric.type = "pubsub.googleapis.com/topic/send_message_operation_count",将interval.startTime 设置为您想要数据的区间的开头,例如2017-02-24T21:01:23.00Z,并将interval.endTime 设置为您想要数据的区间的末尾,例如,2017-02-24T22:01:23.00Z。您可以设置其他属性来更改返回的数据以及返回方式。如果要返回特定主题的数据,可以将AND resource.label.topic_id = "<topic name>" 添加到过滤器中。

    完整的请求 URL(没有必要的授权信息)如下所示:

    https://monitoring.googleapis.com/v3/projects/my-project/timeSeries?interval.endTime=2017-02-24T22%3A01%3A23.00Z&filter=metric.type%20%3D%20%22pubsub.googleapis.com%2Ftopic%2Fsend_message_operation_count%22%20AND%20resource.label.topic_id%20%3D%20%22my-topic%22&interval.startTime=2017-02-23T21%3A01%3A23.00Z

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-06-13
      • 2015-04-20
      • 2020-08-17
      • 2019-07-18
      相关资源
      最近更新 更多