How do I monitor IBM Cloud applications?

IBM Cloud not only offers a broad range of services, it also provides IBM Cloud Foundry, a Platform as a Service (PaaS) solution that's based on open source Cloud Foundry technology.

Applications deployed on IBM Cloud Foundry (formerly Bluemix) are usually run through technology-specific and IBM-related buildpacks that provide framework and runtime support for applications running on the platform. For example, to run Java applications on IBM Cloud, typically the IBM WebSphere Liberty buildpack is used rather than the normal Java buildpack.

Before you begin

What you'll need:


These guidelines apply to integration with the supported Cloud Foundry buildpacks.

Generate PaaS token

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

  1. Login with your Dynatrace account.

  2. Select Deploy Dynatrace from the navigation menu.

  3. Click the Set up PaaS integration button.

  4. Your environment ID appears in the Environment ID text box. You'll need this ID to link your Dynatrace account with your PaaS environment. Click Copy to copy the ID to the clipboard. You can do this at any time by revisiting this page.

  5. To generate a PaaS token, click the Generate new token button. The PaaS token is essentially an API token that's used in combination with your environment ID to download Dynatrace OneAgent. As you will notice, there is already a default InstallerDownload token available that you could alternatively use. However, for security reasons, it is recommended that you create several discrete tokens for different environments.

  6. Type in a meaningful name for your PaaS token. A meaningful token name might be the name of the PaaS platform you want to monitor (for example, azure, cloud-foundry, or openshift). To view and manage your existing PaaS tokens, go to Settings -> Integration -> Platform as a Service.

  7. Click Generate to create the PaaS token. The newly created PaaS token will appear in the list below. Click Copy to copy the generated token to the clipboard. You can do this at any time by revisiting this page and clicking Show token next to the relevant PaaS token.

Get the Cloud Foundry CLI

The code examples below use the cf CLI for interfacing with the Cloud Foundry cluster (i.e, IBM Cloud environment). You can find the appropriate CLI for your operating system on GitHub.

Create a Dynatrace service in your IBM Cloud environment

Cloud Foundry (and therefore also IBM Cloud) 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.

Please select one of the following:

Option 1: Create a user-provided service

Create a single service instance for Dynatrace with the name dynatrace as a substring, like in the example below. You will then be prompted for your environment ID and API token. The API token corresponds to the token mentioned above.

cf cups dynatrace-service -p "environmentid, apitoken"

If you're using Dynatrace Managed, you need to add an extra field to the payload that specifies the API endpoint of your Managed Server: apiurl

For example:

cf cups dynatrace-service -p "environmentid, apitoken, apiurl"

This needs to be set to https://<YourManagedServerURL>/e/<environmentID>/api.

Option 2: Create a service instance via service broker

If you want to maintain Dynatrace credentials in a central location, use a service broker. For complete details, visit GitHub. You must configure and run the broker as an application, add the service broker to Cloud Foundry, enable service access to users, and finally, create the service instance.

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, the result may resemble the following example. If you're deploying to IBM Cloud, be sure to accept IBM licenses by setting the proper environment variables. For details, please refer to the buildpack readme.

- name: demo-helloworld
  path: target/JavaHelloWorldApp.war
  memory: 512M
  instances: 1
  host: hello-world-${random-word}
  disk_quota: 1024M
  - dynatrace-service
  IBM_LIBERTY_LICENSE: <liberty-license-key>
  IBM_JVM_LICENSE: <jvm-license-key>

Improved OneAgent error handling

The Dynatrace integration for the Node.js buildpack allows you to push your application even when download of Dynatrace OneAgent fails (for example, because of a network connection error). For details see supported Cloud Foundry buildpacks.

Configure default Dynatrace OneAgent log stream for Cloud Foundry

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 Dynatrace 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

Update OneAgent for Cloud Foundry

For details on updating Dynatrace OneAgent to the latest release for use with IBM Cloud, please see How do I monitor Cloud Foundry?