The execution of commands is primarily verified in AWS Cloud9.
If you would like to provide command examples, please submit them through the contact form.
You may also use this form to request corrections for the listed command examples.
Create a log group
aws logs create-log-group \
--log-group-name ExampleLogGroup
output
None
by anonymous
Create a log stream
aws logs create-log-stream \
--log-group-name ExampleLogGroup \
--log-stream-name ExampleLogStream
output
None
by anonymous
Output log events
TIME="`date +%s`000"
TEXT="This is example message."
EVENT="timestamp=${TIME},message=\"${TEXT}\""
aws logs put-log-events \
--log-group-name ExampleLogGroup \
--log-stream-name ExampleLogStream \
--log-events "${EVENT}"
output
{
"nextSequenceToken": "49647012347438648207383750719339122106922125597460136466"
}
by anonymous
Check log events
aws logs get-log-events \
--log-group-name ExampleLogGroup \
--log-stream-name ExampleLogStream
output
{
"events": [
{
"timestamp": 1717663812000,
"message": "This is example message.",
"ingestionTime": 1717663813481
}
],
"nextForwardToken": "f/49647012347438648207383750719339122106922125597460136466/s",
"nextBackwardToken": "b/49647012347438648207383750719339122106922125597460136466/s"
}
by anonymous
Set retention period in bulk for log groups with matching prefixes
logs=$(aws logs describe-log-groups \
--log-group-name-prefix /aws/lambda \
--query 'logGroups[*].[logGroupName]' \
--output text)
for i in $logs; do aws logs put-retention-policy --log-group-nam $i --retention-in-days 7 ;done
output
None
by anonymous