是否可以从 google-cloud-python访问subscription/num_outstanding_messages
列出的指标https://cloud.google.com/monitoring/api/metrics#gcp-pubsub ?我已经使用类似的代码成功访问了该num_undelivered_messages
指标,但迭代以下查询的结果(成功)总是产生一个空列表。
Python 2.7.6 (default, Oct 26 2016, 20:30:19)
[GCC 4.8.4] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from google.cloud import monitoring
>>> client = monitoring.Client()
>>> q = client.query(
... "pubsub.googleapis.com/subscription/num_undelivered_messages",
... minutes=90
... )
>>> len(list(q)) > 0
True
>>> q = client.query(
... "pubsub.googleapis.com/subscription/num_outstanding_messages",
... minutes=90
... )
>>> len(list(q)) > 0
False
相关 google-cloud-python 库版本:
~:pip freeze | grep google
gapic-google-logging-v2==0.10.1
gapic-google-pubsub-v1==0.10.1
google-cloud==0.21.0
google-cloud-bigquery==0.21.0
google-cloud-bigtable==0.21.0
google-cloud-core==0.21.0
google-cloud-datastore==0.21.0
google-cloud-dns==0.21.0
google-cloud-error-reporting==0.21.0
google-cloud-happybase==0.20.0
google-cloud-language==0.21.0
google-cloud-logging==0.21.0
google-cloud-monitoring==0.21.0
google-cloud-pubsub==0.21.0
google-cloud-resource-manager==0.21.0
google-cloud-runtimeconfig==0.21.0
google-cloud-storage==0.21.0
google-cloud-translate==0.21.0
google-cloud-vision==0.21.0
google-gax==0.14.1
googleapis-common-protos==1.5.0
grpc-google-iam-v1==0.10.1
grpc-google-logging-v2==0.10.1
grpc-google-pubsub-v1==0.10.1