0
votes

A previous devops engineer set up CloudWatch in AWS for my client. Now I've been asked to push some additional information to CloudWatch. I've never used CloudWatch before, but I have used the AWS CLI for other tasks.

For this task, I can see the documentation offers this example:

aws logs put-log-events \
  --log-group-name MyApp/access.log 
  --log-stream-name TestStream1 \
  --log-events \
    timestamp=1394793518000,message="Test event 1" \
    timestamp=1394793518000,message="Test event 2" \
    timestamp=1394793528000,message="This message also contains an Error"

If I log in and go here:

https://console.aws.amazon.com/cloudwatch/home?region=us-east-1#logStream:group=asi-stage-ecs-logs

I can see logs such as this:

asi-stage-prefix/sugar-naa/c2b1113a-5111-47cd-839d-79f7111caff0

I'm curious, what is this? Is this the "log-group-name" and "log-stream-name" jammed together? If not, where do I go to find that information?

1

1 Answers

1
votes

This link: https://console.aws.amazon.com/cloudwatch/home?region=us-east-1#logStream:group=asi-stage-ecs-logs will take you to the page for the asi-stage-ecs-logs log group. The list you see there are log streams for that group.

On top of the page you will see breadcrumbs like this:

CloudWatch > Log Groups > Streams for asi-stage-ecs-logs

If you click on the Logs Groups or the Logs in the menu on the left side or follow this link: https://console.aws.amazon.com/cloudwatch/home?region=us-east-1#logs: you will see all the log groups.

Keep in mind that logs are separated by region, if you want to see your logs you need to open the console for the correct region.

So your command would look something like this:

aws logs put-log-events \
  --log-group-name asi-stage-ecs-logs 
  --log-stream-name asi-stage-prefix/sugar-naa/c2b1113a-5111-47cd-839d-79f7111caff0 \
  --log-events \
    timestamp=1394793518000,message="Test event 1" \
    timestamp=1394793518000,message="Test event 2" \
    timestamp=1394793528000,message="This message also contains an Error"