Skip to content

Instantly share code, notes, and snippets.

@AlainODea
Created October 30, 2017 19:50
Show Gist options
  • Save AlainODea/5636fb9935101d87962c7546fcfff48f to your computer and use it in GitHub Desktop.
Save AlainODea/5636fb9935101d87962c7546fcfff48f to your computer and use it in GitHub Desktop.
CloudWatch: get most recently updated log stream in a group by stream prefix
#!/bin/bash
logGroupName=$1
logStreamPrefix=$2
aws --profile prod logs describe-log-streams \
--log-group-name ${logGroupName} \
--log-stream-name-prefix ${logStreamPrefix} |
jq --raw-output '.logStreams |=
sort_by(.lastEventTimestamp) |
.logStreams[-1].logStreamName'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment