How to detect operational issues in Lambda Function automatically with Amazon DevOps Guru for Serverless?

Reading Time: 8 minutes

Hands-on

In this hands-on, we will see how we can detect operational issues in Lambda Function with Amazon DevOps Guru for Serverless. We will first log in and navigate to the AWS console. Then, we will change the region to the one that has Amazon DevOps Guru available. Navigating to the Amazon DevOps Guru dashboard, we will enable the analysis of all the resources in the account. We will then create a new lambda function with the node.js runtime. Replacing the default code, we will publish a new version for the lambda function. We will then add configuration for adding provisioned concurrency for the published version of the lambda function. Once the status of the same changes to Ready, we will navigate to the Amazon CloudWatch Events dashboard and create 6 rules to trigger the lambda function at an interval of 1 minute adding the target value as either the default lambda function or the published version of Lambda. Verifying the addition of CloudWatch as a trigger to the lambda function, we will wait for a few hours for Amazon DevOps Guru to capture the insights. Once the insights are captured, we will navigate to the details page of the same and look at the different flexibilities including the recommendations provided to fix the anomaly.

How to detect operational issues in Lambda Function automatically with Amazon DevOps Guru for Serverless?

To implement the same, we will do the following:

  • Log in and navigate to the AWS console.
  • Change the region to the one that has Amazon DevOps Guru available.
  • Navigate to the Amazon DevOps Guru dashboard and enable the analysis for all resources in the AWS account.
  • Traverse to the Lambda Function dashboard and create a new function with Node.js runtime.
  • In the code editor pane, replace the default code with the one provided in this blog and deploy the same.
  • Publish a new version of the deployed code.
  • Add configuration for provisioned concurrency for the published version of Lambda Function.
  • Navigate to the CloudWatch dashboard’s rules section.
  • Create 6 rules with Event source as scheduled with an internal of 1 minute and the target as either the published version of Lambda or the default.
  • Navigate to the Lambda Function dashboard and check if the CloudWatch Event trigger is added.
  • After a few hours, navigate to the Amazon DevOps Guru dashboard and check if the insights are captured.
  • Navigate to the details page of the captured insights and explore the different flexibilities.

Log in and navigate to the AWS console.

How to detect operational issues in Lambda Function automatically with Amazon DevOps Guru for Serverless?

Change the region to us-east-1 since devops guru is available in that region.

How to detect operational issues in Lambda Function automatically with Amazon DevOps Guru for Serverless?

On success, you should see the region as shown in the image below.

How to detect operational issues in Lambda Function automatically with Amazon DevOps Guru for Serverless?

Now, search for the service Amazon DevOps Guru and open its dashboard.

You will see the following screen on the browser. Expand the left navigation pane.

How to detect operational issues in Lambda Function automatically with Amazon DevOps Guru for Serverless?

Under settings, click on Analyzed resources.

You’ll get to see the process of how the Amazon DevOps Guru works.

How to detect operational issues in Lambda Function automatically with Amazon DevOps Guru for Serverless?

Scroll down and select Analyze all AWS resources…. Option. Click on Enable.

On success, you will see the screen as shown in the image below. Click on Analyzed resources in the left navigation pane.

How to detect operational issues in Lambda Function automatically with Amazon DevOps Guru for Serverless?

You can edit the configurations by clicking on Edit.

How to detect operational issues in Lambda Function automatically with Amazon DevOps Guru for Serverless?

You will get the following options available.

Now, search for Lambda and navigate to its dashboard.

How to detect operational issues in Lambda Function automatically with Amazon DevOps Guru for Serverless?

Click on Create function on its dashboard.

Select Author from scratch and a name for the Lambda function. Keep the runtime as Node.js.

How to detect operational issues in Lambda Function automatically with Amazon DevOps Guru for Serverless?

Scroll down and leave the other configurations as default and click on Create function.

On success, you will be navigated to the Lambda function dashboard.

How to detect operational issues in Lambda Function automatically with Amazon DevOps Guru for Serverless?

Navigate to the code editor pane and remove the default code and add the below code. Click on Deploy.

On success, you will see the message as shown below.

How to detect operational issues in Lambda Function automatically with Amazon DevOps Guru for Serverless?

Click on the Versions tab and click on Publish new version.

In the opened modal, add a description and click on Publish.

How to detect operational issues in Lambda Function automatically with Amazon DevOps Guru for Serverless?

A new version will be created. Click on the Configurations tab.

Click on Add configuration.

How to detect operational issues in Lambda Function automatically with Amazon DevOps Guru for Serverless?

Select version for the Qualifier type and the other settings as shown in the image below.

The setup might take a few minutes.

How to detect operational issues in Lambda Function automatically with Amazon DevOps Guru for Serverless?

On success, you will see the status updated to Ready.

Now, search for the service CloudWatch.

How to detect operational issues in Lambda Function automatically with Amazon DevOps Guru for Serverless?

Click on Back to CloudWatch Events.

Click on Create rule.

How to detect operational issues in Lambda Function automatically with Amazon DevOps Guru for Serverless?

Under Event Source, select Schedule and enter the fixed rate as 1 minute. For the Target, select the newly created Lambda function and select versions and select the first version that we published.

You can keep it default to keep the Lambda function as the target. Click on configure details.

Enter name as Rule1 and make sure the status is Enabled. Click on Create rule.

How to detect operational issues in Lambda Function automatically with Amazon DevOps Guru for Serverless?

On success, you will see the screen as shown in the image below.

How to detect operational issues in Lambda Function automatically with Amazon DevOps Guru for Serverless?

Repeat the above event creation process multiple times to create 6 rules overall.

Navigate to the Version 1 lambda function dashboard. If you selected the target as version 1 in the rule, then you will see the trigger in the version 1 dashboard as shown in the image below.

If you selected the target as default then you would see it in the normal functions dashboard.

Navigate to the Amazon DevOps Guru.

After a few hours, when the lambda functions will start getting triggered, on the dashboard, you will get to see the count of Ongoing reactive insights changed to 1. Click on it or click on insights in the left navigation pane.

You will see the lambda function insight captured with its severity and status as ongoing. Click on it to open its dashboard.

You will get to see the details of the insights that were captured.

Scroll down and you will get to see the Aggregated metrics. Click on the Graph anomalies tab.

Over here you will get to see the metrics in the graph format.

Under Relevant events, you will get to see when the lambda function was invoked. There is flexibility to view the same in a tabular format. Finally, Amazon DevOps Guru provides us with recommendations as to what can we do to resolve the errors. We can click on the recommendations and follow the steps thereby.

How to detect operational issues in Lambda Function automatically with Amazon DevOps Guru for Serverless?

Conclusion

In this hands-on, we saw how we can detect operational issues in Lambda Function with Amazon DevOps Guru for Serverless. We first logged in and navigated to the AWS console. Then, we changed the region to the one that has Amazon DevOps Guru available. Navigating to the Amazon DevOps Guru dashboard, we enabled the analysis for all the resources in the account. We then created a new lambda function with the node.js runtime. Replacing the default code, we published a new version for the lambda function. We then added configuration for adding provisioned concurrency for the published version of the lambda function. Once the status of the same changes to Ready, we navigated to the Amazon CloudWatch Events dashboard and created 6 rules to trigger the lambda function at an interval of 1 minute adding the target value as either the default lambda function or the published version of Lambda. Verifying the addition of CloudWatch as a trigger to the lambda function and after waiting for a few hours for Amazon DevOps Guru to capture the insights, we navigated to the details page of the same and had a look at the different flexibilities including the recommendations provided to fix the anomaly. 

We will come up with more such use cases in our upcoming blogs.

Meanwhile …

If you are an aspiring DevOps Engineer and want to explore more about the above topics, here are a few of our blogs for your reference:

Stay tuned to get all the updates about our upcoming blogs on the cloud and the latest technologies.

Keep Exploring -> Keep Learning -> Keep Mastering 

At Workfall, we strive to provide the best tech and pay opportunities to kickass coders around the world. If you’re looking to work with global clients, build cutting-edge products and make big bucks doing so, give it a shot at workfall.com/partner today!

Back To Top