Get the top 10 slowest requests of an application load balancers access logs.


# Create a storage dir for the logs
mkdir /tmp/logs && cd /tmp/logs

# Download logs
# This example downloads all logs on 2020-01-01
logBucket=log-bucket-name
accountId=12345                 # Your AWS account id
lbName=my-awesome-load-balancer
region=us-east-1

aws s3 sync s3://${logBucket}/${lbName}/AWSLogs/${accountId}/elasticloadbalancing/${region}/2020/01/01/ ./

Show the slowest requests:


# fields used in cut:
# 7: target_processing_time
# 13,14: part of the "request field"

find . -type f -name '*.gz' -exec zcat {} \; | cut -d' ' -f7,13,14 | sort | tail -n 10