Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I write logs to cloudwatch using aws-cli?

i'm trying to write a log to cloudwatch (just to understand how it works)

so from the aws-cli (already configured) i'm issuing this command

aws logs put-log-events --log-group-name testgroup --log-stream-name teststream1 --log-events timestamp=1587488538,message=hello

on cloudwatch the group-name and the stream-log already exist and the the names are correct

the output of the command is the following

{ "rejectedLogEventsInfo": { "tooOldLogEventEndIndex": 1 } }

the user i'm using has the "AdministratorAccess" policy attached (and to be sure i've added "CloudWatchFullAccess" policy as well)

like image 356
alex Avatar asked Sep 08 '26 21:09

alex


1 Answers

You need to convert your timestamp to milliseconds version (multiply with 1000 in your case)

aws logs put-log-events --log-group-name testgroup --log-stream-name teststream1 --log-events timestamp=1587488538000,message=hello

please check AWS CLI examples

like image 64
Ersoy Avatar answered Sep 10 '26 21:09

Ersoy



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!