JMXTrans Agent Integration

About JMXTrans Agent Integration

This topic is intended for app developers who are going to use the Heartbeat service to collect JMX metrics from their Java apps.

A custom Java buildpack is required to integrate the JMXTrans agent into a Java app for JMX monitoring. JMXTrans agent integration enables the app to send performance metrics to the StatsD server. These metrics are subsequently pushed to Graphite’s Carbon component for caching and persistence.

Downloading and Compiling a Java App

  1. From the command line, navigate to the app directory. Below, a sample spring-petclinic app (cloned from https://github.com/spring-projects/spring-petclinic) is used.

    cd spring-petclinic/

  2. Compile the app:

    ./mvnw package

Creating an Application Manifest

  1. Create an application manifest based on this example:

    applications:
    - name: spring-petclinic
      memory: 1G
      random-route: true
      path: target/spring-petclinic-1.5.1.jar
      buildpack: https://github.com/Altoros/java-buildpack#jmx-agent-integration
    
  2. Add the manifest to your project:

    cd spring-petclinic
    vim manifest.yml

Note: Altoros modified the buildpack to attach and configure the JMXTrans agent. Use only the provided Altoros/java-buildpack link to access the current version of the buildpack.

Pushing the App

  1. Navigate to the app directory.

    cd spring-petclinic

  2. Push the app.

    cf push

Binding a Service Instance to the App

  1. Navigate to cf marketplace.

    cf marketplace
        Getting services from marketplace in org admin / space demo as admin...
    OK
    service              plans          description
    app-autoscaler       standard       Scales bound applications in response to load (beta)
    heartbeat            standard       Heartbeat Monitoring Solution

  2. Find Heartbeat in the list of the available services and select the service plan (currently, only the standard service plan is available—it will be selected by default).

  3. Create a service instance.

    cf create-service heartbeat standard heartbeat

  4. Bind the service to your app.

    cf bind-service spring-petclinic heartbeat

  5. Restage the app to start the metrics flow.

    cf restage spring-petclinic

Create a pull request or raise an issue on the source for this page in GitHub