[英]Spring Boot - Actuator Metrics Endpoint not working in docker image
In my Spring Boot App Yaml I have:在我的 Spring 引导应用程序 Yaml 中,我有:
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.它在 spring 启动独立应用程序中工作,但在 docker 映像中,端点执行器/指标不起作用,它将我重定向到默认页面,该应用程序仍然可以正常工作。
My docker file:我的 docker 文件:
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:码头入口点.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?
是否需要进行任何配置才能公开 docker 中的指标? thanks for your responses.
感谢您的回复。
you should open port on run docker:您应该在运行 docker 时打开端口:
sudo docker run **** 8080/8080 *****
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!复制 Config 目录下的 application.yml 并将其设置到我的应用程序的 configDir 中,然后将其移动到图像中解决了我的问题!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.