(OpenShift Only) Set the APPDYNAMICS_AGENT_UNIQUE_HOST_ID Environment Variable

For Java applications running in OpenShift, set the APPDYNAMICS_AGENT_UNIQUE_HOST_ID environment variable to enable APM correlation with the Cluster Agent. Since the value depends on a runtime value, set this environment variable in the image startup script using the values documented in Manually Configure App Agents to Correlate with the Cluster Agent.

For example, for an OpenShift 3.10 or 3.11 environment, add this startup script startup.sh to the Docker image:

#!/bin/bash
# OpenShift 3.10 or 3.11:
APPDYNAMICS_AGENT_UNIQUE_HOST_ID=$(sed -rn '1s#.*/##; 1s/docker-(.{12}).*/\\1/p' /proc/self/cgroup)
exec java $JAVA_OPTS -jar /myapp.jar

and update the startup command in the Dockerfile to reference it:

CMD ["/startup.sh"]