Skip to content

Instantly share code, notes, and snippets.

@jonprindiville
Last active November 28, 2023 17:34
Show Gist options
  • Save jonprindiville/a12744c26027fcb88e8a96ea9844e257 to your computer and use it in GitHub Desktop.
Save jonprindiville/a12744c26027fcb88e8a96ea9844e257 to your computer and use it in GitHub Desktop.
Tell me about ECS startup timing...
set -euo pipefail
CLUSTER="${1}"
TASKS="${2}"
aws ecs describe-tasks --cluster "${CLUSTER}" --tasks "${TASKS}" \
| jq '.tasks[]
| {
meta: {
clusterArn: .clusterArn,
connectivity: .connectivity,
desiredStatus: .desiredStatus,
healthStatus: .healthStatus,
lastStatus: .lastStatus,
taskDefinitionArn: .taskDefinitionArn
},
timing: {
createdAt: .createdAt|match("[-:0-9T]+").string|strptime("%Y-%m-%dT%H:%M:%S")|mktime,
connectivityAt: .connectivityAt|match("[-:0-9T]+").string|strptime("%Y-%m-%dT%H:%M:%S")|mktime,
pullStartedAt: .pullStartedAt|match("[-:0-9T]+").string|strptime("%Y-%m-%dT%H:%M:%S")|mktime,
pullStoppedAt: .pullStoppedAt|match("[-:0-9T]+").string|strptime("%Y-%m-%dT%H:%M:%S")|mktime,
startedAt: .startedAt|match("[-:0-9T]+").string|strptime("%Y-%m-%dT%H:%M:%S")|mktime
}
} as $result
| {
deltas: {
createdToConnectivity: ($result.timing.connectivityAt - $result.timing.createdAt),
connectivityToPullStarted: ($result.timing.pullStartedAt - $result.timing.connectivityAt),
pullStartedToPullStopped: ($result.timing.pullStoppedAt - $result.timing.pullStartedAt),
pullStoppedToStarted: ($result.timing.startedAt - $result.timing.pullStoppedAt),
createdToStarted: ($result.timing.startedAt - $result.timing.createdAt)
}
} as $deltaResult
| {meta: $result.meta, timing: $result.timing, deltas: $deltaResult.deltas}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment