Overview

Cloud Foundry is an enterprise PaaS (Platform as a Service.) Cloud Foundry itself is an open source project but a commercial distribution is available from Pivotal. Instructions for setting up a Cloud Foundry demo/development environment utilizing vagrant/virtualbox called bosh-lite is available here: https://github.com/cloudfoundry/bosh-lite

Prerequisites

  • Working Cloud Foundry deployment
  • CF command line tools
  • Web server to host agent binaries
  • Gradle
  • Ruby
  • Bundler (gem install bundler)
  • Java Buildpack April 8, 2016 build commit # bed4c6137c7bf08c09813a4b5b33eed0d3eaee46 upwards

Prepare Dynatrace system profile for Cloud Foundry Java Apps

All applications deployed to Cloud Foundry automatically deploy with the agent name in the format of <CF Application Name>-Monitoring. Add an agent mapping utilizing the "ends" matching filter:

Create Dynatrace Service

Option one via "create-user-provided-service" command

Point the Cloud Foundry environment at the Dynatrace Collector (in this example the collector is located at 192.168.1.48) 

*note, syntax differs per cli environment. windows environments the double quotes must be escaped with a backslash (\) and encases the whole command in double quotes. Powershell requires the double quotes be escaped with a backslash yet encloses the block in a single quote. Further syntax differences can always be found via cf help create-user-provided-service

Via Linux/Mac cf cli:

cf create-user-provided-service cf-dynatrace -p '{"server":"192.168.1.48"}'

On Windows:

cf create-user-provided-service cf-dynatrace -p "{\"server\":\"192.168.1.48\"}"

On Powershell:

cf create-user-provided-service cf-dynatrace -p '{\"server\":\"192.168.1.48\"}'


If necessary, create Cloud Foundry security group to allow outbound connectivity to Dynatrace Collector
Create security.json

[
{
"protocol": "tcp",
"destination": "192.168.1.48",
"ports": "9998"
}
]

Create dynatrace_group

cf create-security-group dynatrace_group ./security.json

Apply the security group to Cloud Foundry

cf bind-running-security-group dynatrace_group
cf bind-staging-security-group dynatrace_group

Option two via Dynatrace Appmon Service Broker tile and Pivotal OpsManager

If necessary, create Cloud Foundry security group to allow outbound connectivity to Dynatrace Collector
Create security.json

[
{
"protocol": "tcp",
"destination": "192.168.1.48",
"ports": "9998"
}
]

Create dynatrace_group

cf create-security-group dynatrace_group ./security.json

Apply the security group to Cloud Foundry

cf bind-running-security-group dynatrace_group
cf bind-staging-security-group dynatrace_group

Configuring the Dynatrace Appmon Tile

Dynatrace Service Broker tile available via PivNet at the following URL: https://network.pivotal.io/products/p-dynatrace-appmon

  1. Login to Pivotal Ops Manager

  2. Click on “Import a Product” and import the Dynatrace Appmon Tile 

  3. Select the Dynatrace Appmon Tile on the left hand panel under Available Products

  4. Click Add on the Dynatrace Appmon Tile

  5. Select the Dynatrace Appmon tile:

  6. Configure the Availability Zone

  7. Configure the Dynamic Service Plans

  8. Click “Add” button on the extreme right against Dynamic Service Plans

    1. Create a separate Service Plan for each Dynatrace Appmon Collector instance to be used.

    2. Configure the Dynatrace Appmon Collector server address and port.

    3. Add additional collectors as needed.

  9. Enable Global Service Access checkbox for the services to be accessible to all users in Marketplace.

  10. Save configurations.

  11. Apply Changes.

  12. On completion of Dynatrace Appmon Tile install, check Services Marketplace in Apps Manager

  13. View Dynatrace Appmon Service Plan

  14. Provide the plan an instance name (for use with bind-service command)


Create and deploy Java sample app

Download and compile spring-music java application

Clone source for spring-music sample application

git clone https://github.com/cloudfoundry-samples/spring-music.git

Compile spring-music application using gradlew (this may take a few minutes!)

./gradlew assemble

  Before deploying application to Cloud Foundry the manifest.yml must be edited to increase timeout allowing for agent instrumentation time

---
applications:
- name: spring-music
memory: 512M
instances: 1
timeout: 180
host: spring-music-${random-word}
path: build/libs/spring-music.war

Deploy Spring Music application to Cloud Foundry (deploying with --no-start flag so that we can attach Dynatrace before starting app)

cf push spring-music-cf -b java_buildpack_dyna --no-start

Attach agents to application

Cloud Foundry uses a bind mechanism to attach applications to external services. Here you will enter the user provided service name or the plan instance name

cf bind-service spring-music-cf cf-dynatrace

Start Application

cf start spring-music-cf

At this point agents should be deployed along with the application. If the application is scaled to additional instances by Cloud Foundry new instances will automatically be instrumented with Dynatrace!