Smart Agent provides the auto-attach feature to auto instrument a Java application with Java Agent or a NodeJS application with the Node.js Agent. This feature is used to detect and start the supported Splunk AppDynamics agents without modifying the start configuration of the applications. You can use Smart Agent Command Line Utility for additional configuration.

Supported Runtimes and Frameworks:

  • Java: Tomcat, Weblogic, Springboot, JBoss, Glassfish and plain Java applications
  • NodeJS

Customize Auto-Attach Configuration 

You can overwrite the default ld_preload.json (attaches the agent to all supported Java frameworks and NodeJS applications) and add your own with your updated rules.

The default location for ld_preload.json is <SmartAgent directory>/lib/ld_preload.json.

The default auto-attach path is the same as the agent path, which is defined at the root level.

If you are using any custom agent paths, ensure that it is specified in the ld_preload.json file.

For Java Agent, you can specify the required agent path for each regex within the ld_preload.json file. This allows specific Java Agent to auto-attach to a specific Java service.

To use advanced auto-attach configuration or configure auto-attach on multiple hosts in an automated way, you can use Smart Agent Command Line Utility.

You can update the ld_preload.json file based on the following scenarios:

ScenarioUpdate to ld_preload.json
To disable auto-attach feature for any of the Java processes.
{
  "logging": {
    "level": "trace",
    "directory": "/var/log/appdynamics",
    "fileName": "ld_preload.log",
    "usePid": true
  },
  "java": {
    "agentPath": "/opt/appdynamics/java-agent/javaagent.jar",
    "instrument": false,
    "filters": [
JSON

To ignore the Java processes that are pre-configured using the custom path.

But, use the Java Agent custom path to auto-attach any non-instrumented Java processes.

{
  "logging": {
    "level": "trace",
    "directory": "/var/log/appdynamics",
    "fileName": "ld_preload.log",
    "usePid": true
  },
  "java": {
    "agentPath": "custom_path/javaagent.jar",
    "instrument": true,
    "filters": [
JSON

Here, custom_path is the custom path where Java Agent is installed.

To auto-generate the application, tier, and node names.

{
  "logging": {
    "level": "trace",
    "directory": "/var/log/appdynamics",
    "fileName": "ld_preload.log",
    "usePid": true
  },
  "java": {
    "agentPath": "custom_path/javaagent.jar",
    "instrument": true,
    "filters": [
     {
     "name": "tomcat",
     "regex": ".java.tomcat.catalina.org\.apache\.catalina\.startup\.Bootstrap.start.",
     "instrument": true,
     "applicationName": "{env.HOST}-TomcatApp",
     "tierName": "{env.USER}-Tier",
     "nodeName": "{env.USER}-Node"
     },


CODE

Here, TomcatApp, Tier, and Node are examples of the suffix that you want to use for all the entities. This can be changed based on what you require as the suffix.

The following are the variable values that change based on the environment variable that you specify:

  • env.HOST - to include hostname. In this example, the application name includes TomcatApp as the suffix with the hostname. For example, ec2-1-1-TomcatApp
  • env.USER - to include the user. In this example, the tierName and nodeName includes respective Tier and Node as suffixes with the username. For example, ubuntu-Tier or ubuntu-Node


Filters

The JSON configuration is broken into sections per supported runtime. For example, Java, NodeJS. For each section, you can provide a set of filters using regular expressions and also define a filter to auto attach or ignore the discovered application(s).  The filters are applied in an order. The regular expressions are applied to the entire command line.

Example regex:
 {
        "name": "instrument node applications",
        "regex": "node .*\\.js.*$",
        "instrument": true
      },

     {
        "name": "ignore npm commands",
        "regex": "npm",
        "instrument": false
      } 
JSON

Startup scripts such as, /opt/tomcat/bin/startup.sh launch the Java applications internally with certain parameters. Auto-attach monitors the launch of the Java application and not of the shell script(s).