Mulesoft Datadog Integration

Bhargavi k
3 min readDec 12, 2023

--

A quick review of the steps involved in integrating Mulesoft with Datadog to collect the logs.

Introduction:

In this blog, you will get a brief idea of how to push the Mulesoft logs to the external system Datadog. DataDog is a well-known observability and monitoring service. It is commonly used for monitoring the performance, health, and security of applications, infrastructure, and networks in real-time.

Whenever you are developing/implementing any integration or solution, logging is very important and plays a vital role in debugging any issue that might occur in the future.

The steps involved in integrating Mulesoft with DataDog are :

Step 1: Create a Datadog account( you can create a trial account to try it out)

Step 2: Get the API key

Click on your Username → Organization Settings → API Keys → Copy the API key and keep it handy.

Retrieving Datadog API key

Step 3: Configure log4j2.xml in your Mule project

Add the below code in the log4j2.xml file to append Datadog inside the <Appenders> tag. Make sure to add the API key collected in step 2 in the below code.

<Appenders>
<Http name="DATADOG"
url="https://http-intake.logs.us5.datadoghq.com/api/v2/logs?host=${sys:hostName}&amp;ddsource=Mulesoft&amp;service=${sys:application.name}&amp;ddtags=env:${sys:env}">
<Property name="Content-Type" value="application/json" />
<Property name="DD-API-KEY" value="PUT_YOUR_APIKEY_HERE" />
<JsonLayout compact="false" properties="true">
</JsonLayout>
</Http>
</Appenders>

Also, do not forget to refer to the Datadog appender in the same log4j2.xml

<AsyncRoot level="INFO">
<AppenderRef ref="file"/>
<AppenderRef ref="DATADOG"/>
</AsyncRoot>

Note: Make sure to add the correct URL according to your region. My region is US5 therefore, the URL looks like this: https://http-intake.logs.us5.datadoghq.com/api/v2/logs

Step 4: Deploy to theCloudhub

Note: Disable the Cloudhub logs in the Runtime manager by unchecking the log forwarding to the Anypoint monitoring option as shown below

Logging Section in Runtime Manager

Step 5: Verify Datadog logs

As soon you hit the API you deployed in Cloudhub, you should see the logs in the Datadog logs.

To segregate your logs add the below properties to filter out easily in Datadog.

Properties in Runtime Manager
Logs in Datadog
Sample Datadog integration flow

When I hit my simple App deployed in Cloudhub that has a start log, a log that prints the query param, and an end log with URL: https://datadog-integration-ucm4h0.5sc6y6-3.usa-e2.cloudhub.io/datadog?firstname=This is query param. Above is the log that we can see in Datadog.

You can click on each log and check all the detailed additional information you need. You can also filter your logs based on your requirements.

Hope this simple flow helps you to get an idea of integrating the MuleSoft logs with an external system and kickstart your learning toward Mulesoft Datadog integration :)

--

--

Bhargavi k

Mulesoft Certified Platform Architect and Developer