1

I want to know how retrieve metrics pubsub from an API. (I saw this topic Google PubSub - Counting messages in topic, but it's not the same problem).

When I attempt to retrieve them from Logging API, but it returns a 404 error.

It's not possible or it just lacks rights ?

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`

Thanks for your time !

Community
  • 1
  • 1

1 Answers1

1

Stackdriver Monitoring and Stackdriver Logging are different. The metrics from Pub/Sub are collected as part of Stackdriver Monitoring. The logging.googleapis.com API is part of Stackdriver Logging, which is used for searching, analyzing, and monitoring your logs.

To access the send_message_operation_count metric, you'll want to use the timeSeries.list method. You would set filter to metric.type = "pubsub.googleapis.com/topic/send_message_operation_count", set interval.startTime to the start of the interval for which you want data, e.g., 2017-02-24T21:01:23.00Z, and set interval.endTime to the end of the interval for which you want data, e.g., 2017-02-24T22:01:23.00Z. There are other properties you can set to alter what data is returned and how. If you want to return the data for a specific topic, you would add AND resource.label.topic_id = "<topic name>" to the filter.

A complete request URL (without the necessary authorization info) would look something like:

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

Kamal Aboul-Hosn
  • 15,111
  • 1
  • 34
  • 46