Hello there,
We’ve properly digested the docs to integrate APM into a docker container to monitor a java application that runs inside that container. The java agent was properly configured in the Dockerfile.
We can build successfully the image and also run the container, but the java app is not sending data to new relic.
Even when New Relic Diagnostics is installed, and all the logs seems fine. It keeps invalidating our ingest license key.
This is my Dockerfile and screenshot of the nrdiag:
FROM maven:3.8.1-ibmjava-alpine as build
COPY pom.xml .
RUN mvn verify clean --fail-never --quiet
COPY . .
RUN mvn package -Dmaven.test.skip=true --quiet
FROM adoptopenjdk/openjdk11:alpine as deploy
RUN apk upgrade --update && \
apk add --update tzdata && \
apk add --update curl && \
ln -sf /usr/share/zoneinfo/America/Los_Angeles /etc/localtime && \
rm -fr /tmp/* /var/cache/apk/*
# New Relic
VOLUME /tmp
RUN mkdir -p /var/log
# Installing curl and zip
RUN apk --update --no-cache add unzip
# Configure new relic logs
RUN mkdir -p /opt/newrelic/logs
RUN chmod 777 /opt/newrelic && chmod 777 /opt/newrelic/logs
# Download and Install APM
RUN curl "http://download.newrelic.com/newrelic/java-agent/newrelic-agent/current/newrelic-java.zip" -o /tmp/newrelic.zip \
&& unzip /tmp/newrelic.zip -d /opt/ \
&& rm /tmp/newrelic.zip
RUN cat /opt/newrelic/newrelic.yml | sed -e "s/<%= license_key %>/$NRA_LICENSE_KEY/" \
-e "s/app_name:.*/app_name: $NRA_APP_NAME/" > /opt/newrelic/newrelic.yml.new
# Overwrite the default newrelic.yml
RUN mv /opt/newrelic/newrelic.yml.new /opt/newrelic/newrelic.yml
RUN addgroup -S microservices && \
adduser -S -D -h /app appuser microservices && \
chown -R appuser:microservices /app
USER appuser
ARG DEPENDENCY=/target/dependency
COPY --from=build ${DEPENDENCY}/BOOT-INF/lib /app/lib
COPY --from=build ${DEPENDENCY}/META-INF /app/META-INF
COPY --from=build ${DEPENDENCY}/BOOT-INF/classes /app
ENV JAVA_TOOL_OPTIONS \
-Dlog4j2.contextSelector=org.apache.logging.log4j.core.async.AsyncLoggerContextSelector \
-Dlog4j2.formatMsgNoLookups=true \
-Dspring.jpa.hibernate.ddl-auto=update \
-Djava.net.debug=handshake \
-XX:+UnlockExperimentalVMOptions \
-XX:+UseG1GC \
-XX:-UseCMSInitiatingOccupancyOnly \
-XX:+UseStringDeduplication \
-XX:MaxGCPauseMillis=120 \
-XX:InitiatingHeapOccupancyPercent=60 \
-XX:SurvivorRatio=2 \
-XX:ParallelGCThreads=10 \
-XX:ConcGCThreads=5
CMD java $JAVA_ADDITIONAL_OPTS --add-opens=java.base/java.net=ALL-UNNAMED -javaagent:/opt/newrelic/newrelic.jar -cp app:app/lib/* com.kinship.integration.petprofile.PetprofileServiceApplication
The license key and nr app name are been passed from an env_file
- APM Agent Language = Java
- APM Agent Version = Java Agent version 7.6.0
- Operating System = Linux
- Operating System Version
- Frameworks your app is using = Springboot