Automation API Logging with Datadog

Irwan Rosyadi
3 min readJun 23, 2021

If you had read my previous articles on Quality Engineering Transformation in Ralali.com, you’ll find that i already implement our Automation API summary logging into a Dashboard using Grafana. Maybe the architecture is not quite bit changed

But in this articles i just wanna share how to implement datadog as our logging and dashboard platform.

First i have a helper file to send the Automation API summary and the notifications like below, and this files run after all the integration test finished. You can save the file as report_helper.js but of course you can implement using any programming language from this piece of code.

After that you have to make an API Key on Datadog that will be used in line 72. The payload value can be set based on your need. The reference you can use is here in Datadog Logs Api Reference. When you finished creating you own API Key and implemented on your code, you can try to run it in your local with command node report_helper.js. Then the log will shown like this :

Also you can make dashboard from this log too like below :

Okay then, for the next step is creating incoming webhook into our Slack / Mattermost. Actually the documentation can be found in this Slack Incoming Webhook page or this Mattermost Incoming Webhook page. First you have to create a channel for your incoming webhook., and then The most important is creating the webhook URL for line 98. You can create it by yourself if you’re the Admin or ask for the URL from your sysAdmin. As i say the payload can be modified as you need. Once you set then you can try it again by running previous command node report_helper.js. Then the notification popup will shown and when you click the message will be like below :

The last but not least, you can make a trigger if your Automation Pass Percentage suddenly decreased. You can make it in Monitors → New Monitor menu, then make a threshold whether the notification should send warning or alert,

And don’t forget to notify your team,

And by the way the alert can be sent through Slack or Mattermost too, you can see the documentation here Datadog Slack

Thank you for reading, hope i can share a little thing more next time

--

--