File tree Expand file tree Collapse file tree 1 file changed +4
-5
lines changed Expand file tree Collapse file tree 1 file changed +4
-5
lines changed Original file line number Diff line number Diff line change 73
73
74
74
# Currently only collects the last 24h of logs, but it might be good to be able to specify a different value for this.
75
75
76
- logAge=$( date --date=" 1day" " +%s000" )
77
-
78
- # check if we're running on a macOS based system
76
+ # check if we're running on a macOS based system, otherwise use the GNU-based date syntax
79
77
if [[ $OSTYPE == ' darwin' * ]]; then
80
78
logAge=$( date -v-1d " +%s000" )
79
+ else
80
+ logAge=$( date --date=" 1day" " +%s000" )
81
81
fi
82
82
83
-
84
-
85
83
# Collect some information about the Lambda function and associated log groups
86
84
lambdaFunction=$( aws cloudformation describe-stack-resources --stack-name " $stackName " --logical-resource-id Autoscaling --query " StackResources[*].PhysicalResourceId" --output text | sed -nr ' s/.*stack\/(.*)\/.*/\1/p' )
87
85
lambdaLogGroup=$( aws cloudformation describe-stack-resources --stack-name " $lambdaFunction " --logical-resource-id LogGroup --query " StackResources[*].PhysicalResourceId" --output text)
88
86
logStreams=$( aws logs describe-log-streams --log-group-name " $lambdaLogGroup " --order-by LastEventTime --query " logStreams[?creationTime > \` $logAge \` ] | [*].logStreamName" --output text | tr -s ' [:space:]' ' \n' )
89
87
90
88
# Iterate through all of the log streams we collected from the lambda log group
91
89
echo " Collecting Lambda logs for $lambdaFunction "
90
+
92
91
for i in $logStreams
93
92
do
94
93
fileName=$( echo " $i " | sed -r ' s/\//-/g' )
You can’t perform that action at this time.
0 commit comments