Moving from application development in a traditional data center or the cloud to a serverless environment like AWS Lambda, Azure Functions or Google Cloud Functions requires a distinct change in how we approach problems and solution design.
Similarly, the way in which we monitor our environment needs to change as well. In this blog, we're going to look specifically at what form monitoring should take in a serverless world, what metrics are necessary to monitor, and best practices to ensure our applications are functioning optimally.
We'll also look at tools available to make monitoring easier to set up and maintain, specifically the Application Performance Monitoring and Management solution offered by CA Technologies — CA APM.
Monitoring a Serverless Application
The serverless world is not a world without servers, but from the perspective of the DevOps engineer, the server and its performance isn't a concern. Traditional monitoring solutions involve tracking memory usage, processing capacity, and network throughput as critical metrics. None of these are important metrics in a serverless environment.
Many common monitoring tools use an agent installed on the server to collect and report metrics, and in an environment where we don't have access to the server, this isn't a viable option either.
The point of an application which is hosted using a solution such as AWS Lambda is that the functions themselves should be lightweight and very performant. With this in mind, we don't want our monitoring solution to add unduly to the workload for each invocation.
With a serverless application, we want to ensure that we're monitoring:
■ Memory usage
■ Error conditions
Let's look at how we can implement monitoring for our serverless application.
Capturing Metrics from a Serverless Environment
I created a simple API and implemented it using AWS Lambda functions. The application's purpose was to store and return a collection of user-based preferences. To generate traffic, I set up a scheduled test using Runscope, which also allowed me to send additional traffic with the click of my mouse.
The APM that I decided to use to monitor the application was CA Application Performance Management (APM) from CA Technologies. The advantage of this particular tool is that it doesn't require the installation of an agent of the target machine, something which, as I mentioned above, is not something we can do with serverless solutions. CA Technologies offers a 30-day trial of the tool, and you can be signed up for the trial and monitoring your application in a matter of minutes.
The tool requires you to install an agent on a machine which has access to your environment. In my case, the target system was my AWS account. I went through the installation on both my local Windows 10 workstation and on an EC2 Instance running Amazon Linux in the Cloud. Both installations were easy to complete and configure and worked seamlessly.
Fig. 1 Download Link and Installation Instructions for the AWS Linux Agent
An additional advantage of this tool is that the connection to your AWS account is configured on your machine and results are gathered and sent to the APM. This setup ensures that you own and manage the configuration, and you don't need to grant access to your AWS account to an external entity.
Monitoring Your Application with CA APM
Once I had the agent installed and configured, I triggered the tests from my Runscope account and then logged into my CA APM Dashboard. I clicked on the Metric View, found the name of the machine hosting my agent, and navigated the tree to locate my functions.
Fig. 2 Metrics View Tree Showing My Lambda Functions
Within each function, I was able to view graphs from a configurable time frame for:
Fig. 3 Metrics from an AWS Lambda Function
The CA APM environment allows you to create your monitoring dashboards, automated error alerting, and also provides an extensive help system to walk you through how best to monitor your data using the tool.
Transitioning your applications to a serverless environment is going to require a change of mindset, and will provide you with technical hurdles which you need to overcome. Monitoring, as an essential part of a professional DevOps organization, shouldn't be cause for concern. It's a matter of selecting the right tool and connecting it to your serverless environment.
Get started with a free 30-day trial today at www.ca.com/tryapm