‫So now let's talk about
‫how Lambda does logging, monitoring, and tracing.
‫So the first thing we know is that Lambda has
‫an integration with CloudWatch Logs
‫because all of the Lambda execution logs are
‫automatically stored in CloudWatch Logs.
‫If your Lambda function has an execution role
‫with the correct IAM policy that authorizes
‫your Lambda function to write to CloudWatch Logs,
‫and this is included in the Lambda basic execution role
‫as we've seen before.
‫Then we haven't seen this yet,
‫but there are CloudWatch metrics.
‫And so they are displayed in the CloudWatch Metrics UI
‫or the Lambda UI.
‫And they will represent information about
‫your invocations, duration, concurrent execution,
‫error counts, success rate,
‫throttles, Async delivery failures.
‫And if you are reading
‫from Kinesis or DynamoDB streams, your iterator age
‫which means how far you are into your,
‫how lagging you are into your reading of the streams.
‫So we'll have a look at those in a second.
‫And then finally you can do tracing
‫with x-ray in your Lambda function.
‫So it's super easy.
‫You just enable it in your Lambda
‫configuration, it's called active tracing.
‫It will run the x-ray daemon for you.
‫Now, the only thing you have to do is to use the
‫x-ray SDK in your code.
‫You need to ensure that you're Lambda function
‫has the correct IAM execution role to write into x-ray.
‫And so there is a managed policy called
‫AWS x-ray daemon write access.
‫And then the environment variables to communicate
‫with x-ray if you needed them are these three right here.
‫And so you just need to see them once.
‫I'm not going to read them out to you, but see them once.
‫And they can come up in the exam.
‫I think the most important one is the latest
‫which is AWS x-ray daemon address
‫which presents where the IP and the port of
‫the x-ray daemon is running regarding your Lambda function.
‫And these environment variables can be accessed the same way
‫as we've done before with other environment variables.
‫So that's it now lets go into
‫the hands-on to see how that works.