Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationEventAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
0
Help us understand the problem. What are the problem?

More than 1 year has passed since last update.

@turugina

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

備忘録

  • 1. ロググループ名を列挙する
# 保持期間(retentionInDays)が設定されていないロググループを列挙する
# 数が多くて1回で取り切らない場合は --log-group-name-prefix で絞り込むとか
aws logs describe-log-groups \
--query 'logGroups[?!(retentionInDays)].logGroupName' \
--output text
  • 2. 保持期間を設定する
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
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
0
Help us understand the problem. What are the problem?