3

是否可以从 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
4

1 回答 1

3

num_outstanding_messages表示发送给订阅者但尚未确认的消息数量,仅适用于推送订阅者。请注意,尽管 API 没有明确区分这一点,但在Stackdriver中,该指标显示为“推送未完成的消息”。订阅者指南讨论了推送订阅者和拉取订阅者之间的区别。

于 2016-12-19T17:36:44.177 回答