Integrating agentless Datadog log monitoring to Red Hat JBoss EAP 7.x

Integrating agentless Datadog log monitoring to Red Hat JBoss EAP 7.x

Authors

Introduction

Red Hat JBoss Enterprise Application Platform 7 (JBoss EAP) is a middleware platform built on open standards and compliant with the Java Enterprise Edition 7 specification. For more information on JBoss EAP, refer [JBoss EAP introduction]

Datadog is a monitoring platform which has integrations to over 500+ systems. For more information, refer [Datadog site]

The way Datadog typically operates is by installing an agent in the host environment of the software to be monitored. The agent, running as a separate process, collects the logs from a file and pushes them to Datadog's cloud service. But, In this post we would like to integrate the agentless Datadog logging with JBoss EAP.

Note that this setup is not supported by Red Hat. All the details provided is for educational purpose only.

Pre-requisite

For us to start with the configuration, we would need a JBoss EAP7.x running a simple web application.

In Our case we already have the KIE web app on JBoss EAP 7.3.5+. The KIE web component is part of Red Hat Decision Manager [RHDM]

Configuration

The agentless Datadog installation that will consists of modifying the underlying JBoss logging subsystems in a way that, logs are pushed directly to Datadog server instead of going to an intermediate step such as a file.

Step1: Set the JBOSS_HOME to the installation path

export JBOSS_HOME= /Users/pramodpadmanabhan/tools/servers/cubic/jboss-eap-7.3        

Step2: Create a folder in modules to hold the required libraries

mkdir -p $JBOSS_HOME/modules/system/layers/base/ch/qos/logback/mai
n        

Step3: Create a module file with required dependencies and resources

vim $JBOSS_HOME/modules/system/layers/base/ch/qos/logback/main/module.xml        

sample content is as given below

<?xml version="1.0" encoding="UTF-8"?

<module xmlns="urn:jboss:module:1.1" name="ch.qos.logback">

??<resources>

????<resource-root path="logback-classic-1.2.5.jar"/>

????<resource-root path="logback-core-1.2.5.jar"/>

????<resource-root path="logstash-logback-encoder-6.6.jar"/>

??</resources>

??<dependencies>

????<module name="org.slf4j" />

????<module name="javax.api" />

????<module name="javax.mail.api" />

????<module name="com.fasterxml.jackson.core.jackson-annotations" export="true"/>

????<module name="com.fasterxml.jackson.core.jackson-core" export="true"/>

????<module name="com.fasterxml.jackson.core.jackson-databind" export="true"/>

??</dependencies>

</module>>        

Step4: Download the logstash-logback-encoder, logback-classic, logback-core libraries to this location

$ curl 
https://repo1.maven.org/maven2/net/logstash/logback/logstash-logback-encoder/6.6/logstash-logback-encoder-6.6.jar \
--output $JBOSS_HOME/modules/system/layers/base/ch/qos/logback/main/logstash-logback-encoder-6.6.jar


$ curl \

https://repo1.maven.org/maven2/ch/qos/logback/logback-classic/1.2.5/logback-classic-1.2.5.jar \

--output $JBOSS_HOME/modules/system/layers/base/ch/qos/logback/main/logback-classic-1.2.5.jar


$ curl \

https://repo1.maven.org/maven2/ch/qos/logback/logback-core/1.2.5/logback-core-1.2.5.jar \

--output $JBOSS_HOME/modules/system/layers/base/ch/qos/logback/main/logback-core-1.2.5.jar\        

Step5: Create a jboss logging folder in modules and copy the jars from system modules

$ mkdir -p $JBOSS_HOME/modules/org/jboss/logging

$ cp -rf $JBOSS_HOME/modules/system/layers/base/org/jboss/logging/* modules/org/jboss/logging/        

Step6: Modify the module.xml file to point to the logback module

vim $JBOSS_HOME/modules/org/slf4j/main/module.xml        

sample content is as below


...

??<dependencies>

??????<module name="ch.qos.logback"/>

??</dependencies>

...        

Step7: Create a logback.xml file in the configuration along with your DATADOG API key.

vim $JBOSS_HOME/standalone/configuration/logback.xml        

sample content is as below. Replace the DATADOG_API_KEY with actual value.

<configuration

??<appender name="JSON_TCP" class="net.logstash.logback.appender.LogstashTcpSocketAppender">

????<remoteHost>intake.logs.datadoghq.com</remoteHost>

????<port>10516</port>

????<keepAliveDuration>20 seconds</keepAliveDuration>

????<encoder>

???????<pattern>DATADOG_API_KEY? %d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n </pattern>

????</encoder>

????<ssl/>

??</appender>

??<root level="DEBUG">

????<appender-ref ref="JSON_TCP" />

??</root>

</configuration>>        

Step8: Configure logback location in the JBoss EAP startup

vi $JBOSS_HOME/bin/standalone.conf        

add the below details

JBOSS_PATH=/Users/pramodpadmanabhan/tools/servers/jboss-eap-7.3

JAVA_OPTS="$JAVA_OPTS -DJBOSS_LOG_DIR=$JBOSS_PATH/standalone/log"

JAVA_OPTS="$JAVA_OPTS -Dlogback.configurationFile=$JBOSS_PATH/standalone/configuration/logback.xml"        

Step9: Configure the Webapp to exclude the default logging modules

vim $JBOSS_HOME/standalone/deployments/kie-server.war/WEB-INF/jboss-deployment-structure.xml        

sample file is as below



<?xml version="1.0" encoding="UTF-8"?>

<jboss-deployment-structure>

<deployment>

????<exclusions>

??????<module name="org.jboss.logging"/>

??????<module name="org.apache.log4j"/>

??????<module name="org.apache.commons.logging"/>

??????<module name="org.slf4j" />

??????<module name="org.slf4j.impl" />

????</exclusions>

…

</deployment>

</jboss-deployment-structure>        

Step10: Restart the JBoss EAP server.

now you should be able to see the logs in the Datadog server


Reference

  1. https://docs.datadoghq.com/logs/log_collection/java/

要查看或添加评论,请登录

Pramod Padmanabhan的更多文章

社区洞察

其他会员也浏览了