【问题标题】:Manipulating Time Series data in Google-cloud library在谷歌云库中操作时间序列数据
【发布时间】:2017-06-26 16:34:02
【问题描述】:

我正在尝试使用 Google-Cloud Python 库从自定义 Stackdriver 指标中获取数据,但除了将其作为 pandas 数据框返回之外,我无法获得所需的值。

例如查询,它看起来像:

query = client.query(metric_type, minutes=5)

使用 pandas 时会返回如下内容:

resource_type                                 l7_lb_rule
project_id                                    my_id
backend_name
backend_zone
forwarding_rule_name                          foo-http     foo-https
instance_group_name
matched_url_path_rule
target_proxy_name                           foo-target-1 foo-https-060417
target_proxy_type
url_map_name                                         foo              foo
log                                             requests         requests
2017-06-26 15:43:06.750                               26               25

但我不知道如何操作它来获得我需要的值,本质上是 http 和 https 请求的数量(我想总结这些)。

例如,如果我要使用 iterrows(),我该如何过滤它以显示我需要的数据?

或者也许将它显示为数据框不是我应该做的,我只是看不出如何使用这个库获取这些数据。

提前致谢

【问题讨论】:

  • 如果您只想查看数据,您应该使用 Cloud Console,因为它有一些很好的过滤数据的方法。如果您正在处理日志,我建议使用接收器将它们写入 bigquery,然后从 bigquery 查询数据并将其加载到 pandas 数据帧中。

标签: python google-cloud-platform stackdriver google-cloud-python


【解决方案1】:

我决定完全避免使用数据帧,而只是遍历时间序列对象以提取我需要的值。

【讨论】:

    猜你喜欢
    • 2016-06-03
    • 1970-01-01
    • 2018-09-23
    • 2017-08-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-09-25
    相关资源
    最近更新 更多