Version detection strategies

Dynatrace uses built-in version detection strategies to support different technology standards for versioning. The latest version detected can be influenced by environment variables, Kubernetes labels, and events ingestion.

Environment variables

The best and easiest way to get version information also available on every purepath is to provide metadata via environment variables.

  • DT_RELEASE_VERSION for Version
  • DT_RELEASE_STAGE for Stage
  • DT_RELEASE_PRODUCT for Product

For example, for any process running on Linux

  1. Run the following command, making sure to replace <version> with your actual release value.
export DT_RELEASE_VERSION=<version>
  1. Start the process.

After a few seconds, the version of this process will appear in Dynatrace.

Kubernetes labels

For Kubernetes, you can use Kubernetes recommended labels for deployed pods to provide metadata for

  • Related versions (label: app.kubernetes.io/version)
  • A related product (label: app.kubernetes.io/part-of) optional

Kubernetes recommended labels mapped to release metadata: recommended-labels

Dynatrace OneAgent with viewer permissions on the namespace can automatically detect labels attached to the Kubernetes pods.

  • Version and Product show up in the release inventory.
  • Kubernetes namespaces and configured Dynatrace host-group names show up as Stages in the release inventory.

If you don't want to change your deployment configuration, you can update Kubernetes labels. Dynatrace will update captured versions after a few seconds.

kubectl label --overwrite pod yourPodId -n yourNamespace app.kubernetes.io/version=42

Events ingestion

If it's inconvenient to add environment variables for processes in your environments, or if you want to update version information without environment variable changes for your deployed software, you can send custom deployment events to Dynatrace APIs that explicitly provide version information.

This example JSON shows how to send custom deployment events to the API. Note that processes are matched via tags.

{
  "eventType": "CUSTOM_DEPLOYMENT",
  "attachRules":
  { "tagRule" :
    { "meTypes" : "PROCESS_GROUP_INSTANCE", "tags" : "YOUR_TAG" }
  },
  "deploymentName":"${CD_JOB_NAME}",
  "deploymentVersion":"1.1",
  "deploymentProject":"YOUR_PRJ",
  "remediationAction":"http://revertMe",
  "ciBackLink":"${BUILD_URL}",
  "source":"YOUR_CD_TOOL",
  "customProperties":{ "Commits": "${GIT_COMMITS}" }
}