【问题标题】:gcloud monitoring_v3 query fails on AttributeError 'WhichOneof'gcloud monitoring_v3 查询在 AttributeError 'WhichOneof' 上失败
【发布时间】:2021-02-17 11:41:20
【问题描述】:

我使用这个库有一段时间了,一切都很好。用它来查询gcloud机器的cpu利用率。

这是我的代码:

query_obj = Query(metric_service_client, project, "compute.googleapis.com/instance/cpu/utilization", 
minutes=mins_backward_check)
metric_res = query_obj.as_dataframe()

一切都很好,直到最近它开始失败。

我明白了:

{AttributeError}'WhichOneof'

Deubbing 它,我看到它在“as_dataframe()”代码中失败了,特别是在这部分:

data=[_extract_value(point.value) for point in time_series.points]

当它试图从点对象中提取值时。 _extract_value 值代码似乎使用了似乎与 protobuff lib 相关的 WhichOneof 属性。

我没有更改任何这些库版本,有人知道是什么导致它现在失败了吗?

【问题讨论】:

  • 您好,您还有问题吗?您能否发布您的 requirements.txt 以尝试复制您的案例

标签: python gcloud


【解决方案1】:

如果您确信 (!) 您没有更改任何内容,那么这似乎是 Google 破坏了其 API,您可能希望在以下组件之一的 Google 问题跟踪器上提交问题:

我认为 Cloud Monitoring 本身就是一个基于 gRPC 的 API,可以解释 protobuf 参考。

一个好的健全性检查是使用APIs Explorer 并检查您在那里使用的方法,看看您是否可以解释请求|响应,也许:

https://cloud.google.com/monitoring/api/ref_v3/rest/v3/projects.timeSeries/query

注意对于熟悉 Cloud Monitoring Python SDK 的人来说,您的问题可能很容易解析,但不容易重现。请考虑提供您问题的简单重现,包括 requirements.txt 和完整代码 sn-p。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2023-03-27
    • 2021-10-25
    • 1970-01-01
    • 1970-01-01
    • 2015-07-11
    • 2019-03-22
    • 1970-01-01
    相关资源
    最近更新 更多