0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

aws cli でcloudwatch log group の保持期間をまとめて設定する

Posted at

備忘録

    1. ロググループ名を列挙する
# 保持期間(retentionInDays)が設定されていないロググループを列挙する
# 数が多くて1回で取り切らない場合は --log-group-name-prefix で絞り込むとか
aws logs describe-log-groups \
--query 'logGroups[?!(retentionInDays)].logGroupName' \
--output text
    1. 保持期間を設定する
aws logs put-retention-policy \
--log-group-name <ロググループ名> \
--retention-in-days <保持日数>
    1. と 2. の合わせ技
# 保持期間が設定されていないloggroupの保持期間を7日間に設定する
for lg in `aws logs describe-log-groups --query 'logGroups[?!(retentionInDays)].logGroupName' --output text`
do
  aws logs put-retention-policy --log-group-name $lg --retention-in-days 7
done
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?