如何配置生命周期管理以自动删除 Google Cloud Platform 日志存储中的日志?

问题描述 投票:0回答:1

我有几个 Google Cloud 项目积累了大量日志,每月大约 200GB,预计在下一时期将增加近一倍。最初,我认为通过调整保留设置来管理它会很简单:编辑日志存储桶,设置以天为单位的保留期,然后更新存储桶。

我在六个多月前配置了此设置,将其设置为非生产项目的一天。然而,似乎直到下月初才删除任何内容。日志每天持续累积,仅在下个月的第一天重置。

在查看了文档和各种 Stack Overflow 问题后,我发现保留期并不是日志删除的期限;而是保留期。它实际上是保存日志的持续时间。为了解决这个问题,我们需要为存储桶中的对象建立生命周期。不幸的是,有问题的存储桶(_Default日志存储桶)是系统存储桶,我无法配置它。

即使我使用

gcloud logging logs delete
删除日志,存储空间也保持不变,直到下个月才会重置。有没有办法将日志的生命周期设置为小于一个月?

编辑:实际上,保留应该删除日志,但我不认为这种情况正在发生。我所有项目的日志。

retentionDays   integer

Logs will be retained by default for this amount of time, after which 
they will automatically be deleted. The minimum retention period is 1 
day. If this value is set to zero at bucket creation time, the 
default time of 30 days will be used.

https://cloud.google.com/logging/docs/reference/v2/rest/v2/locations.buckets

google-cloud-platform logging google-cloud-storage google-cloud-logging
1个回答
0
投票

我相信我解决了自己的问题。

  • Cloud Logging 不对存储桶中当前存储的日志大小收费,而是对已索引或已处理的日志收费。这就是为什么存储大小只会增加,即使删除日志也不会减少。
Logging charges for the pre-indexed volume of logs data that is stored in
 the _Default log bucket and in user-defined log buckets, when the total
 volume exceeds the free monthly allotment. Every write of a log entry to
 the _Default log bucket or to a user-defined log bucket counts toward your
 storage allotment. For example, if you have sinks that route a log entry to
 three log buckets, then that log entry is stored three times.
  • 此外,如果免费后不到 30 天,保留也无关紧要。保留数据超过 30 天会产生额外费用。
Logging charges retention costs when the logs are retained longer than the
 default retention period. You can't configure the retention period for the
 _Required log bucket. There are no retention costs when logs are stored
 only for the default retention period of the log bucket.

https://cloud.google.com/stackdriver/pricing#storage-pricing

© www.soinside.com 2019 - 2024. All rights reserved.