‫So let's have a look at CloudWatch Logs.
‫And for this, on the left hand side
‫let's go into Log groups.
‫So as you can see
‫we already have one log group available to us, which is,
‫AWS lambda, demo-lambda.
‫Well that's because before we created a lambda function
‫that we ran and that automatically
‫created some log into CloudWatch logs.
‫So if we click on this function,
‫and this is what it was doing, he was running this code.
‫And so if we go into CloudWatch logs
‫and click on this log group,
‫we can see we have one or more log streams.
‫So here's my log stream.
‫And within log stream, as you can see,
‫this represents all the log lines that were logged by
‫my lambda function. So we have the request ID,
‫the loading function. Then we get some values,
‫so value one... and so on,
‫then end of the request ID and end of the reports and we can
‫play with it. So that means that
‫any log line logged by my lambda is going to appear here.
‫So for example, I can change my lambda function,
‫and say, "print an extra log line",
‫and then we're going to deploy this and then I'm going to
‫test my changes.
‫So we're going to test it with this test events and then
‫create, and then demo events perfect
‫and create now tests.
‫So now my function is running.
‫And so what should happen is that
‫if we go back into CloudWatch logs,
‫go to my log groups and then within log group,
‫we have a new log stream. This log stream right here,
‫contains the log line and extra log line. Okay.
‫So this is excellent. And this is good for just monitoring,
‫obviously information about your lambda functions,
‫but also what happens if there's an exception.
‫So in this case, what I'm going to do is
‫I'm going to put a hash sign
‫in front of this line to comment it.
‫And now we're going to remove the hash sign
‫from the line 13,
‫to have this raise exception, something went wrong.
‫We're going to deploy the changes again
‫and test our function.
‫So now something went wrong and what's going to happen is
‫that if I go into my Lambda,
‫there's a new log stream, click on this log stream.
‫And in here, I'm able to see that exception right here,
‫and we can look at why our function went wrong.
‫So this is very handy.
‫That means that every time a Lambda function is going to run
‫the logs are going to appear in CloudWatch logs.
‫But this is not just true for lambda functions.
‫Obviously this is true for any kind of logs that you want to
‫appear in CloudWatch logs.
‫So CloudWatch logs is very handy because you can
‫troubleshoot maybe errors in your programs
‫or applications and so on by just looking at the log lines,
‫within your log groups,
‫for your services or for your applications directly within
‫CloudWatch Logs.
‫And then you can do some login analytics, similar things,
‫some monitoring and so on. Okay.
‫And this is super cool again,
‫and something to definitely go deeper into when you are a
‫DevOps in a company. So that's it for this lecture.
‫I hope you liked it. And I will see you in the next lecture.