Skip to content

Instantly share code, notes, and snippets.

@bbuechler
Created October 11, 2021 23:10
Show Gist options
  • Save bbuechler/365f85d9b48a52d9fa210701ffb39f13 to your computer and use it in GitHub Desktop.
Save bbuechler/365f85d9b48a52d9fa210701ffb39f13 to your computer and use it in GitHub Desktop.
Create log metrics filter w/ cli
# Stupid CloudFormation doesn't support this right now
TeaStackName=<TEA>-UAT-TEA
TeaLambdaName=$(aws cloudformation describe-stacks --query "Stacks[?StackName=='$TeaStackName'].Outputs" | jq -r '.[][] | select ( .OutputKey == "EgressLambdaName" ).OutputValue')
TeaLambdaLogFileName=$(echo -n "/aws/lambda/$TeaLambdaName")
dimensions='dimensions={service=$.message.timing.service}'
transformation=$(echo metricName=duration,metricNamespace=TEA,metricValue='$.message.timing.duration',$dimensions,unit=Milliseconds)
aws logs put-metric-filter \
--log-group-name $TeaLambdaLogFileName \
--filter-name TEATimingByService \
--filter-pattern '{ $.message.timing.service != "" }' \
--metric-transformations $transformation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment