You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: utils/log-collector
+9-2Lines changed: 9 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -69,10 +69,16 @@ done
69
69
70
70
# CloudWatch stores the creationTime as milliseconds since epoch UTC.
71
71
# Since macOS doesn't support calculating the time since epoch in milliseconds, we don't have perfect accuracy on this, but it should be as close to 24 hours as possible
72
-
#while still being inclusive to all platforms that might run the script
72
+
#We'll check to see if we're running on a macOS-based OS and adjust appropriately, otherwise use the standard date command
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
-
logAge=$(date -v-1d "+%s000")
75
+
76
+
# check if we're running on a macOS based system, otherwise use the GNU-based date syntax
77
+
if [[ $OSTYPE=='darwin'* ]];then
78
+
logAge=$(date -v-1d "+%s000")
79
+
else
80
+
logAge=$(date --date="1day""+%s000")
81
+
fi
76
82
77
83
# Collect some information about the Lambda function and associated log groups
78
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')
0 commit comments