In my Spring Boot App Yaml I have:
management:
metrics:
export:
simple:
enabled: true
endpoints:
web:
exposure:
include: "*"
However, when i hit
localhost:8080/actuator/metrics
its working in spring boot standalone app, but in the docker image the endpoint actuator/metrics doesnt work and it redirect me to the default page, the app still works fine.
My docker file:
FROM openjdk:11-jre-buster
RUN apt update && apt install curl -y \
&& rm -rf /var/lib/apt/lists/*
MAINTAINER xxxxx
ARG VERSION
ENV SERVER_PORT 80
ENV JAVA_OPTS -Xmx1g
# add this to solve buster sso issue
ENV OPENSSL_CONF=/etc/ssl
ENV SPRINGPROFILES=actuator
WORKDIR /app
COPY maven/docker-package/ /app
# Tesseract installation
RUN apt-get install apt-transport-https && \
echo "deb [trusted=yes] https://notesalexp.org/tesseract-ocr/buster/ buster main" >> /etc/apt/sources.list && \
apt-get update -oAcquire::AllowInsecureRepositories=true && \
apt-get install notesalexp-keyring -oAcquire::AllowInsecureRepositories=true && \
apt-get update && \
apt-get -y install tesseract-ocr
EXPOSE ${SERVER_PORT}
HEALTHCHECK --interval=5s --timeout=5s --retries=3 \
CMD curl -f http://localhost:80/actuator/health || exit 1
ENTRYPOINT ["sh", "/app/docker-entrypoint.sh"]
docker-entrypoint.sh:
java $JAVA_OPTS -Djava.security.egd=file:/dev/./urandom -Dlicense.path=/app/licenses/ "-Dspring.profiles.active=${SPRINGPROFILES}" -Dlogging.config=/app/config/log4j2.xml -Dserver.port=80 -jar /app/app-executable.jar
what am i missing? is there any configuration needs to be done to expose the metrics in docker? thanks for your responses.
you should open port on run docker:
sudo docker run **** 8080/8080 *****
Have you added actuator
profile:
environment:
- "SPRINGPROFILES=prod,actuator"
More information here .
copying the application.yml under Config directory and setting it into my configDir of my app and then moving it into the image solved my problem!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.