使用谷歌云日志客户端后,条目从谷歌日志中消失

时间:2021-01-14 11:08:50

标签: python google-cloud-logging google-cloud-iot

我在 python 中使用谷歌日志客户端,以便从我的谷歌 IoT 核心服务中检索一些日志。

这是我使用的代码:

    client = self.create_client()
    log_filter: str = self.set_filter(device_id, timestamp)
    for _ in client.list_entries(filter_=log_filter, page_size=1):
        return False
    return True

我使用的过滤器如下所示:

<块引用>

resource.type:cloudiot_device AND jsonPayload.eventType:DISCONNECT AND resource.labels.device_num_id:my_device_num_id AND timestamp>="down_limit" AND timestamp<="up_limit"

基本上,我试图从日志中获取断开连接事件,如果我找到相应的条目,则停止运行。
所以代码有效,但不知何故我的日志似乎消失了。

我创建了单元测试并给出了设备 ID 和时间戳,我昨天能够找到相应的日志条目,但今天它不再存在..

知道这可能来自哪里吗?

1 个答案:

答案 0 :(得分:0)

数据访问审核日志 [1] 的保留期为 30 天 [2]。

近一个月的类似日志仍会出现在您的 Stackdriver 日志中。

正如文档中所建议的,如果您想要更长的保留时间,建议像任何其他 Logging 日志条目一样导出审核日志条目,并根据需要保留它们。 您可以查看此链接 [3] 了解更多信息。


[1]here

[2] https://cloud.google.com/logging/docs/audit#data-access

[3] https://cloud.google.com/logging/docs/audit#audit_log_retention

相关问题