Skip to content

Instantly share code, notes, and snippets.

@hmit208
Forked from jsyi/cwl-last-used.sh
Created October 27, 2022 06:40
Show Gist options
  • Select an option

  • Save hmit208/c09365ea2758d044ec81f598c291d6b9 to your computer and use it in GitHub Desktop.

Select an option

Save hmit208/c09365ea2758d044ec81f598c291d6b9 to your computer and use it in GitHub Desktop.

Revisions

  1. @jsyi jsyi revised this gist Dec 5, 2017. 1 changed file with 10 additions and 1 deletion.
    11 changes: 10 additions & 1 deletion cwl-last-used.sh
    Original file line number Diff line number Diff line change
    @@ -12,4 +12,13 @@ aws logs describe-log-groups | jq ".logGroups[].logGroupName" | grep -E "homeplu

    # xargs -t -n 1 date -r
    # (MacOS X) Format seconds timestamp into human-readable format.
    # (Other) Change `date -r` to `date -d` or other option appropriate to the installation of `date` included with your OS
    # (Other) Change `date -r` to `date -d` or other option appropriate to the installation of `date` included with your OS

    # BONUS: After verifying LogGroups as old/unused delete them
    # aws logs describe-log-groups | jq ".logGroups[].logGroupName" | grep -E "homeplus|mcdonalds" | grep -v "mcdonalds-v1-production" | xargs -n 1 -p aws logs delete-log-group --log-group-name

    # grep -v "mcdonalds-v1-production"
    # (Optional) Filter rule to excluded any LogGroups that should be kept.

    # xargs -n 1 -p aws logs delete-log-group --log-group-name
    # The -p option specifies that xargs should prompt for user confirmation before each command execution.
  2. @jsyi jsyi created this gist Dec 5, 2017.
    15 changes: 15 additions & 0 deletions cwl-last-used.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,15 @@
    aws logs describe-log-groups | jq ".logGroups[].logGroupName" | grep -E "homeplus|mcdonalds" | xargs -n 1 -t aws logs describe-log-streams --query "logStreams[*].lastEventTimestamp" --log-group | jq "max/1000|floor" | xargs -t -n 1 date -r

    # aws logs describe-log-groups | jq ".logGroups[].logGroupName"
    # Get LogGroup names

    # grep -E "homeplus|mcdonalds"
    # (Optional) Filter LogGroup names

    # xargs -n 1 -t aws logs describe-log-streams --query "logStreams[*].lastEventTimestamp" --log-group | jq "max/1000|floor"
    # Get last event timestamp for each LogGroup.
    # (Optional) Convert milliseconds timestamp to seconds timestamp.

    # xargs -t -n 1 date -r
    # (MacOS X) Format seconds timestamp into human-readable format.
    # (Other) Change `date -r` to `date -d` or other option appropriate to the installation of `date` included with your OS