Created
October 11, 2021 23:10
-
-
Save bbuechler/365f85d9b48a52d9fa210701ffb39f13 to your computer and use it in GitHub Desktop.
Create log metrics filter w/ cli
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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