Deploy OneAgent on Cloud Foundry for application-only monitoring

Applications deployed on Cloud Foundry are usually run through technology-specific buildpacks that provide framework and runtime support for applications running on the Cloud Foundry platform. The following guidelines apply to integration with the supported Cloud Foundry buildpacks.

Before you begin

You'll need to

Generate PaaS token

The first step is to get your environment ID and PaaS token for your Dynatrace environment.

Create a Dynatrace service in your Cloud Foundry environment

Cloud Foundry allows you to connect applications with 3rd party tools and other external resources (for example, databases) by means of services. On Cloud Foundry, service instances hold the credentials that are required to connect to such resources. You'll use this same approach to connect your apps with OneAgent. This is why you need to define a service instance by either creating a so-called "user-provided service" or by using a service broker application. To create a Dynatrace service in your Cloud Foundry environment, select one of the following options:

Bind Dynatrace service to your application

You can either bind the created Dynatrace service to your application in your manifest.yml file prior to starting your app or you can bind the service to your app and restage the app afterwards.

If you're pushing a Java application, this could look like the following example:

---
applications:
- name: spring-music
  memory: 768M
  instances: 1
  host: spring-music-${random-word}
  path: spring-music.war
  buildpack: https://github.com/cloudfoundry/java-buildpack.git
services:
  - dynatrace-service

Configure default OneAgent log stream for Cloud Foundry (optional)

By default, OneAgent logs are written to the Cloud Foundry standard error stream. With OneAgent version 1.125 or later, you can configure the default OneAgent log stream for applications deployed in your IBM Cloud environment. All you have to do is set the environment variable DT_LOGSTREAM to either stdout or stderr.

For example:

cf set-env APP_NAME DT_LOGSTREAM stdout