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
Node.js applications deployed on Cloud Foundry will utilize the application name as the agent name. In this example you can use the agent name of "node" with the contains filter to match any application name containing "node":
The Cloud Foundry security group allows outbound connectivity to Dynatrace Collector
Clone source for cf-sample-app-nodejs sample application
The Dynatrace node.js agent can be retrieved from the Dynatrace Downloads area of the community portal.
Extract the Dynatrace Node.js agent inside of the application directory and remove the tarball archive:
Here we have two different ways to deploy the agent to the Node.js application. The configuration can be hardcoded into the application or retrieved from the Cloud Foundry user provided service configured earlier.
In the sample application's server.js file add the following lines towards the beginning of the file. Simply replace the IP address in the URL with IP of the Dynatrace Collector:
Deploy application to Cloud Foundry
This configuration makes use of the cfenv Node package to fetch and parse Cloud Foundry environment variables. The cfenv package can be added to the node application by altering the dependencies section of the package.json to add cfenv without a defined version:
The application's server.js is then edited to include the lines of code necessary to deploy the Dynatrace agent and configuration based on fetched environment variables managed by Cloud Foundry. Here we are using cfenv to fetch the application's name from Cloud Foundry and to fetch the server address for the user provided service created earlier. At the top of the server.js the following lines are added:
Create a user provided service pointing the Cloud Foundry environment at the Dynatrace Collector (in this example the collector is located at 192.168.1.48)
Deploy application to Cloud Foundry (deploying with --no-start flag so that we can attach Dynatrace before starting app)
Cloud Foundry uses a bind mechanism to attach applications to external services. ** NOTE ** This is not necessary if using the manual configuration.
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!