Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
330 views
in Technique[技术] by (71.8m points)

Spring Boot - Actuator Metrics Endpoint not working in docker image

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.

question from:https://stackoverflow.com/questions/65933736/spring-boot-actuator-metrics-endpoint-not-working-in-docker-image

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

you should open port on run docker :

sudo docker run **** 8080/8080 *****

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...