[英]How to get the current server timestamp using spring boot actuator
I'm using spring boot actuator to monitor the health of my micro service. 我正在使用弹簧启动执行器来监视微服务的运行状况。 I also need the server current timestamp. 我还需要服务器当前的时间戳。 info/ just returns the timestamp of the build. info /只是返回构建的时间戳。 Instead, I want the server current timestamp. 相反,我需要服务器的当前时间戳。
See https://docs.spring.io/spring-boot/docs/current/reference/html/production-ready-endpoints.html#production-ready-application-info-custom 参见https://docs.spring.io/spring-boot/docs/current/reference/html/production-ready-endpoints.html#production-ready-application-info-custom
You can simply add values that you need by providing an additional InfoContributor
. 您可以通过提供其他InfoContributor
来简单地添加所需的值。
@Component
public class TimeInfoContributor implements InfoContributor {
@Override
public void contribute(Info.Builder builder) {
// Calculate your desired timeValue here.
builder.withDetail("time", timeValue);
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.