Datadog Gold Partner logo

Have You Heard? How To Automate Datadog Synthetic Monitoring using Terraform

By Surajtikoo.Apr 17, 2023

Articl Have You Heard How To Automate Datadog Synethic Monitoring using Terraform 1

https://www.datadoghq.com/product/synthetic-monitoring/

Datadog Synthetic Monitoring is a cloud-based service that allows you to monitor your web applications and APIs from different locations worldwide. It uses artificial transactions to simulate user behavior and tests the availability and performance of your application at regular intervals. Synthetic monitoring enables you to proactively detect and diagnose issues before they impact your end-users.

In today’s digital age, it’s essential for businesses to have reliable and efficient application programming interfaces (APIs). One way to ensure this is by implementing synthetic monitoring, which allows for automated sanity checks on APIs.

Current Setup

Within the current setup we see there are different teams which have configured the Synethic monitoing for each & every environments

Articl Have You Heard How To Automate Datadog Synethic Monitoring using Terraform 2
Image designed by Surajtikoo

Challenges

Manual creation of tests from the Datadog user interface can be time-consuming and prone to errors
Cloning tests for each environment makes it challenging to manage and maintain when the number of APIs increases
Manual creation of necessary credentials as global variables in the Datadog UI poses a security risk and adds an additional layer of complexity to the process

Solution

To overcome the limitations of the current synthetic monitoring process an auotmated script is written using terraform. The below picture depicts how it can be easily developed once and can be easily reused for multiple environments.

Articl Have You Heard How To Automate Datadog Synethic Monitoring using Terraform 3
Image designed by Surajtikoo
  1. This solution involves storing the necessary credentials securely in secret Manager once it is read from there the same will be stored in the global variables in the Datadog UI.
  2. Additionally, this will ensure a backup of the code is available in case anyone accidentally modifies or deletes the test from the UI.
  3. The automation of the test creation process means that tests can be created or deleted at the click of a button using terrafrom commands which in turn reduces the time and effort required to maintain and manage the tests across multiple environments.

For our usecase we were using Multistage API of Datadog. In Mutlistep Api the output of first API is used an input for the second API.

Below is the terraform configuration for the global variables

Articl Have You Heard How To Automate Datadog Synethic Monitoring using Terraform 4
Image created by Surajtikoo

Below is the terraform configuration for the API end point where we are passing password as an input from the global variables.

Articl Have You Heard How To Automate Datadog Synethic Monitoring using Terraform 5
Image created by Surajtikoo

Conclusion

Overall, using Terraform for synthetic monitoring can help you save time and resources while also providing you with greater visibility into the health and performance of your applications and infrastructure.


The original article published on Medium.

Related Posts