Datadog Mule Integration 4 APM
Log4j
To use this operation, you need to configure the appended in the log4j2.xml file in your project as the below example. This will help to forward the logs captured in Log4J2 to the Datadog Log platform. Note that there's a system variable, ddApiKey, that is passed at runtime.
Tag Version: When you set the version property in your application, a version tag is added to all your traces. This helps correlate apps and identify errors.
The global configuration now includes a "version" property. This allows you to specify the version of your app, which will be visible in the Datadog platform.
<Http name="DD-HTTP" url="https://http-intake.logs.datadoghq.com/v1/input" verifyHostname="false" method="POST">
<Property name="DD-API-KEY" value="${sys:ddApiKey}" />
<JSONLayout compact="false" eventEol="true" properties="true" stacktraceAsString="true">
<KeyValuePair key="host" value="${sys:domain}" />
<KeyValuePair key="appName" value="${sys:domain}" />
<KeyValuePair key="ddsource" value="mule" />
<KeyValuePair key="service" value="mule" />
<KeyValuePair key="correlationId" value="$${ctx:correlationId:-}"/>
<KeyValuePair key="version" value="${sys:version}"/>
</JSONLayout>
</Http>
In Studio, you can configure this variable as a VM argument.
Logs forwarding in CloudHub
Configure the log4j2.xml file with the CloudHub appender.
<Appenders>
<Log4J2CloudhubLogAppender name="CLOUDHUB"
addressProvider="com.mulesoft.ch.logging.DefaultAggregatorAddressProvider"
applicationContext="com.mulesoft.ch.logging.DefaultApplicationContext"
appendRetryIntervalMs="${sys:logging.appendRetryInterval}"
appendMaxAttempts="${sys:logging.appendMaxAttempts}"
batchSendIntervalMs="${sys:logging.batchSendInterval}"
batchMaxRecords="${sys:logging.batchMaxRecords}"
memBufferMaxSize="${sys:logging.memBufferMaxSize}"
journalMaxWriteBatchSize="${sys:logging.journalMaxBatchSize}"
journalMaxFileSize="${sys:logging.journalMaxFileSize}"
clientMaxPacketSize="${sys:logging.clientMaxPacketSize}"
clientConnectTimeoutMs="${sys:logging.clientConnectTimeout}"
clientSocketTimeoutMs="${sys:logging.clientSocketTimeout}"
serverAddressPollIntervalMs="${sys:logging.serverAddressPollInterval}"
serverHeartbeatSendIntervalMs="${sys:logging.serverHeartbeatSendIntervalMs}"
statisticsPrintIntervalMs="${sys:logging.statisticsPrintIntervalMs}">
<PatternLayout pattern="[%d{MM-dd HH:mm:ss}] %-5p %c{1} [%t]: %m%n"/>
</Log4J2CloudhubLogAppender>
</Appenders>
When an application is deployed in CloudHub the Runtime Manager always overwrites the log4j2.xml Disable the CloudHub logs in order for Runtime Manager to apply the project’s log4j2.xml configuration file.
By default, Disable CloudHub logs is not a visible option in Runtime Manager. A special request to the Mulesoft support team is required to enable this option. More info: https://docs.mulesoft.com/runtime-manager/custom-log-appender
In order to deploy the app in CloudHub, add the ddkeyApi property. Because of security reasons, put in the mule-artifact.json ddApiKey as a secure property:
{
"minMuleVersion": "4.3.0",
"secureProperties": ["ddApiKey"]
}
The logs shown in the live console are the logs generated by the log4j2.xml file.
The same event Id can be seen in the log forwarded to Datadog Log.