DEV Community

Derrick Sherrill for WayScript

Posted on

How to Automatically Execute Python Code Based on Datadog DevOps Alerts


In today’s video, we’re going to take a look at how to setup the Datadog Trigger in WayScript and how to use it. Datadog is a powerful monitoring program that can be utilized in many different ways through WayScript, including triggering code executions and more. Keep reading to learn more!

Building our Script

For this tutorial we’ll simply explore how to set up and connect a Datadog account to WayScript. First, we’ll add the Datadog Trigger module to our program tree. We’ll need to authenticate the account using an API key. To do this, navigate to the toolbar at right and select the button with three bars; from here, click “Add Account.”

tutorial step #1

From here, you will need a nickname, and API key, and an Application key.

To get the API and Application keys, visit the Datadog HQ and access your API key. The Application key can also be found here. You can create a new Application key to use solely for this program. Remember to keep both of these keys hidden and don’t share them with others. Paste both of these keys in the right toolbar in WayScript. Now, WayScript has access to your Datadog account.

After clicking “Update” and the refresh button in the toolbar, select your preferred organization. Next, turn on events in the toolbar by activating the toggle switch. To activate the trigger, switch the toggle within the Trigger module in the tree. Now, we’ve activated the Datadog Trigger module within WayScript. However, we need to visit the Datadog HQ website to take care of a few more things before we can start using it.

First, we’ll go to the Monitors tab on the website. For our account, we already have one running titled Demo Events. Clicking on this we see that we’re sending notifications to @webhook-wayscript-datadog-trigger. We can then copy this, go back to the Monitors tab, and create a new monitor. There are many different things we can monitor using various monitor types, like Events, Custom Checks, and Networks. We’ll monitor an event for this tutorial.

tutorial step #1

For our new event monitor, we’re just sending an event when a user uses an application built through Heroku and hosted on GitHub. We have a default string that says “something big has happened,” so we’ll type “something big” in the “Match events containing” text box to match our string. Next, we’ll set alert conditions above zero, and then in the text box at the bottom we’ll type “Notify” and pass in the @webhook-wayscript-datadog-trigger from earlier.

tutorial step #1

Now add a title and click save, and the new monitor will be found in the monitors tab. We’re now ready to start using Datadog for a number of other applications within WayScript.

Having the ability to use Datadog within WayScript adds even more usability to the program. We can use Datadog to monitor our program and automatically trigger code executions to solve any issues that may arise, along with many other potential uses. Stay tuned for future tutorials using the Datadog trigger!


Questions about this script or anything else? Join our discord. We're always around to help.

Top comments (0)