Skip to content

Instantly share code, notes, and snippets.

@jweyrich
Created May 10, 2017 22:01
Show Gist options
  • Save jweyrich/5e5a683b8461c600d73fdfa95a589fe1 to your computer and use it in GitHub Desktop.
Save jweyrich/5e5a683b8461c600d73fdfa95a589fe1 to your computer and use it in GitHub Desktop.
AWS ELB Log Parser
#!/usr/bin/awk -f
#
# AUTHOR: Jardel Weyrich <jweyrich at gmail dot com>
# REQUIRES: awk >= 4.0.0 (macOS awk won't work as of macOS 10.12.4)
#
#
# ELB log format - REFERENCE: http://docs.aws.amazon.com/elasticloadbalancing/latest/classic/access-log-collection.html
#
# 1 timestamp
# 2 elb
# 3 client:port
# 4 backend:port
# 5 request_processing_time
# 6 backend_processing_time
# 7 response_processing_time
# 8 elb_status_code
# 9 backend_status_code
# 10 received_bytes
# 11 sent_bytes
# 12 "request"
# 13 "user_agent"
# 14 ssl_cipher
# 15 ssl_protocol
#
BEGIN {
FPAT = "([^ ]+)|(\"[^\"]+\")"
}
{
print "timestamp=" $1 ", request_processing_time=" $5 ", backend_processing_time=" $6 ", response_processing_time=" $7 ", elb_status_code=" $8 ", backend_status_code=" $9 ", request=" $12
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment