Skip to content

Instantly share code, notes, and snippets.

@chrisdpa-tvx
Last active July 24, 2017 09:38
Show Gist options
  • Save chrisdpa-tvx/cb7ccf53be0756a52a104eb083969a84 to your computer and use it in GitHub Desktop.
Save chrisdpa-tvx/cb7ccf53be0756a52a104eb083969a84 to your computer and use it in GitHub Desktop.
Find Unhappy services
CLUSTER=$1
sts aws ecs list-services --cluster ${CLUSTER} |\
jq -r '.[] | .[]' | xargs -J % -n10 sts \
aws ecs describe-services --cluster ${CLUSTER} \
--services % | jq -r '.services[] | select(.desiredCount!=.runningCount) | .serviceArn' > services
while read r;do
sts aws ecs update-service \
--cluster ${CLUSTER} \
--service ${r} \
--desired-count=2
done < services
sts aws ecs describe-clusters \
--cluster ${CLUSTER} | jq -r ' .clusters[] | .pendingTasksCount'
while read r;do
sts aws ecs update-service \
--cluster ${CLUSTER} \
--service ${r} \
--desired-count=3
sleep 60
done < services
# Describe a service with message history
sts aws ecs describe-services --cluster ${CLUSTER} --services ${SERVICE} | jq -r '.services[].events|=sort_by(.createdAt)'
# Describe services that are currently unstable
sts aws ecs list-services --cluster ${CLUSTER} |\
jq -r '.[] | .[]' | xargs -J % -n10 sts \
aws ecs describe-services --cluster ${CLUSTER} \
--services % | jq -r '.services[] | select(.desiredCount!=.runningCount) | [.serviceArn, .desiredCount, .runningCount]'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment