Skip to content

Instantly share code, notes, and snippets.

@karia
Created January 30, 2018 10:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save karia/57153ca44cddb2419872bff15da32600 to your computer and use it in GitHub Desktop.
Save karia/57153ca44cddb2419872bff15da32600 to your computer and use it in GitHub Desktop.
5xx status count for AWS ALB log file
echo "day,total,5xx"
for i in `seq -w 01 10`
do
echo ${i},`gzcat ${i}/*.gz | wc -l`,`gzcat ${i}/*.gz | awk '$9 ~ /^5/{print $9}' | wc -l`
done
@karia
Copy link
Author

karia commented Jan 30, 2018

Get same data from CloudWatch metrics

% aws cloudwatch get-metric-statistics --namespace AWS/ApplicationELB --dimensions "Name=LoadBalancer,Value=YOUR_ALB_NAME_IS_HERE" --metric-name RequestCount --statistics Sum --start-time 2017-12-31T15:00:00Z --end-time 2018-01-10T15:00:00Z --period 86400  | jq -r '.Datapoints[] | [.Timestamp , .Sum] | @csv' | sort > requestcount.csv
% aws cloudwatch get-metric-statistics --namespace AWS/ApplicationELB --dimensions "Name=LoadBalancer,Value=YOUR_ALB_NAME_IS_HERE" --metric-name HTTPCode_Target_5XX_Count --statistics Sum --start-time 2017-12-31T15:00:00Z --end-time 2018-01-10T15:00:00Z --period 86400 | jq -r '.Datapoints[] | [.Timestamp , .Sum] | @csv' | sort> 5xx.csv

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment