How to post logs to Cloudwatch with CLI?
Solution 1:
Haven’t tested but I think the timestamp
should be a unix timestamp (seconds since 1970-01-01 00:00:00) not a date, i.e. $(date +%s)
and quite possibly in millisecond precision so append 000
at the end.
Hope that helps :)
Solution 2:
1, You should use the Epoch format time. 2. The time should be milliseconds in epoch format, however you are giving the seconds in the sample. https://docs.aws.amazon.com/cli/latest/reference/logs/put-log-events.html
Try sth like this:
EPOCH_TIMESTAMP=$(($(date +%s)*1000))
aws logs put-log-events \
--log-group-name "WebsiteStatusMessage" \
--log-stream-name "$EPOCH_TIMESTAMP" \
--log-events file://$iam/logsoutput.json