gpt4 book ai didi

google-cloud-platform - 我们可以安排 StackDriver Logging 导出日志吗?

转载 作者:行者123 更新时间:2023-12-01 21:58:18 24 4
gpt4 key购买 nike

我是 Google Cloud StackDriver Logging 的新手并根据这个 documentation StackDriver 将数据访问审核日志存储 30 天。在同一页上还提到,日志条目的大小限制为 100KB。
我知道日志可以导出 Google Cloud Storage使用 Cloud SDK以及使用 Logging Libraries在许多语言中(我们更喜欢 Python)。
我有两个与导出日志相关的问题,它们是:

  1. 在 StackDriver 中有没有什么方法可以安排类似于任务或 cronjob 的东西,在固定的时间间隔后自动将日志导出到 Google Cloud 存储中?
  2. 大于 100KB 的日志条目会发生什么情况。我假设他们被截断了。我的假设正确吗?如果是,是否有任何方法可以导出/查看完整(完全没有被截断)的日志条目?

最佳答案

Is there any way in StackDriver to schedule something similar to a task or cronjob that keeps exporting the Logs in the Google Cloud storage automatically after a fixed interval of time?

Stackdriver 支持通过sinks 导出日志数据。没有您可以设置的时间表,因为一切都是自动的。基本上,数据会尽快导出,您无法控制每个接收器的导出量或导出之间的延迟。我从来没有发现这是一个问题。根据设计,日志记录不用作实时系统。最接近的是下沉到 PubSub,它有几秒钟的延迟(根据我的经验)。

有两种方法可以从 Stackdriver 导出数据:

  1. 创建一个导出接收器。支持的目标是 BigQuery、Cloud Storage 和 PubSub。日志条目将自动写入目的地。然后您可以使用工具来处理导出的条目。这是推荐的方法。
  2. 用 Python、Java 等语言编写您自己的代码,以读取日志条目并根据需要对其进行操作。时间安排由您决定。此方法是手动的,需要您管理日程安排和目的地。

What happens to the log entries which are larger than 100KB. I assume they get truncated. Is my assumption correct? If yes, is there any way in which we can export/view the full(which is not at all truncated) Log entry?

超过条目最大大小的条目无法写入 Stackdriver。尝试创建条目的 API 调用将失败,并显示类似于(Python 错误消息)的错误消息:

400 Log entry with size 113.7K exceeds maximum size of 110.0K

这意味着太大的条目将被丢弃,除非作者有逻辑来处理这种情况。

关于google-cloud-platform - 我们可以安排 StackDriver Logging 导出日志吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55080391/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com