6 min read

How To Use Synthetic Monitoring Using Datadog

Synthetic monitoring is an application performance monitoring practice that emulates the paths users might take when engaging with an application. It uses scripts to generate...
How To Use Synthetic Monitoring Using Datadog

Let us first understand what exactly is Synthetic Monitoring.

Synthetic monitoring is an application performance monitoring practice that emulates the paths users might take when engaging with an application. It uses scripts to generate simulated user behavior for different scenarios, geographic locations, device types, and other variables.

Well, this is the standard definition & if you are still confused, you are on correct path. If definitions were sufficient, who would write blogs 🙂.

Let us try to understand synthetic monitoring with a practical situation.

Joe is a Project Lead of a Web Application which users use to create resumes online. It has been a stable product till now & company is now focusing aggressively on increasing users traffic to the web app so that they can monetize it to generate revenue. The stakeholders has told Joe to think of an automated strategy to keep a check on web app's production stability i.e. to keep checking(without any or one time manual involvement) if the application is working as expected on production. The company wants to go for automated production testing due to it's obvious advantages. Joe figures that to accomplish it he can use an automation QA guy who can write automated test cases for production. Once written, they can be executed on scheduled intervals to check live application's stability. Though that would seem to be a fair approach but do you see issues with that? I see following challenges which Joe may face -

  • If the company is not using any automation software right now, Joe will have to research, finalize & propose one to the stakeholders to be approved.
  • Joe will need to find or hire a QA resource who is equipped with the required skillset.
  • For executing the test cases, Joe may need a software to simulate a device i.e. a simulation may be needed that the test cases are executed for a laptop, mobile, tablet etc.
  • Joe may need a software to simulate the browser e.g. Chrome, Firefox, Edge, etc.
  • Joe may need a software to simulate the user traffic originating from US, Canada, Australia or any other region.

All of the above factors would result in longer time for implementation & would be hard to manage them as well. What if there exists a cloud based solution where we can just login &

  • configure some test cases
  • simulate user traffic region
  • simulate browser
  • simulate device

& just schedule them to be executed! Well, this is what is called Synthetic Monitoring. Now read the standard definition, which I mentioned at the top of the article, again. Pasting it here to save you from scrolling above!

Synthetic monitoring is an application performance monitoring practice that emulates the paths users might take when engaging with an application. It uses scripts to generate simulated user behavior for different scenarios, geographic locations, device types, and other variables.

I hope the definition should make more sense now.

There are many platforms available in market for Synthetic Monitoring & which one to choose is totally dependent on companies/individual's requirements.

Due to it's excellent dashboard & ease of use, I have picked Datadog to showcase the power of this cloud based automated approach. I have created a simple .Net Core MVC web app & hosted it on Azure which we will use to run our automated test cases on.

Here is the url - https://simplemvcapp.azurewebsites.net/

This application has just a simple login page & after successful login it redirects to a page with a successful login message. Below are the screenshots of the pages for better clarity -

Now let's suppose we want to test login functionality on regular intervals with the help of Datadog.

Open Datadog & create your credentials. Choose 14 days trial it offers. Once logged in you will see the dashboard. Click synthetic tests from UX Monitoring menu as shown in below pic -

Once clicked, you will see a screen mentioning different type of tests. Click on tab Record End-To-End Tests & then click Create a New Browser Test as shown below -

After clicking, you will see a screen to enter the test details. Enter Url, Test Name & select browser for simulation as shown below -

Select region for simulation & schedule frequency as shown below -

Click Save & Recording. You will see below screen -

Datadog provides a browser extension with the help of which you create your test steps without any coding! Go ahead & install the extension by clicking on Add the Extension. Once added, the screen will automatically refresh & will show the details. It will also open the Url which you entered previously.

Now on the right hand side, you can see the web app is opened. Click on Start Recording & enter user = gaurav, password = sharma, and the web app will redirect to the page showing success message. The beauty of this is that for all of the actions you are doing, datadog will create the test steps in backend & show it to you on left side. Once you see, successful message page click Stop Recording. The page will look like as below -

Now click on Assertion & follow the steps as depicted in below pics -

So what we are trying to do here? We are checking if the page after login contains successful message or not. Please notice the value in the textbox to compare I have entered. I have intentionally entered an incorrect value to show a failed test case.

Now click on Save Recording & then click on Synthetic Tests as shown below -

You will be redirected to below screen & you can see that your newly created test is sitting there. Click on your test & then click Run Test Now.

It will immediately run your test. Now wait for some minutes. Refresh the page, scroll down & you will see the steps executed.

Notice that the test case is failed because 4th step is failed(because I put incorrect message for comparison). That means the test case logic is working fine. Now edit this step & change the message to correct one. Run the test again & this time the test case will pass!

Conclusion

In the article, we have gone through the capabilities/benefits which Synthetic Monitoring offers & how Datadog can be used to achieve it successfully. Nowadays, more & more organizations are moving towards cloud based automated testing. If you or your company is not aware of this trend, now is a good time to dive into it.