Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Display build timestamp in Spring Boot actuator info endpoint

I am using the Spring Boot actuator to get my application's info.

I have added the Spring Boot actuator dependency in my pom.xml, and added below lines in my property file:

info:
   app:
     name: @project.name@
     description: @project.description@
     version: @project.version@

I get the values: name, description and version of my project from pom.xml. I also want to get build time and display it on the /info endpoint.

Any suggestions?

Should I also Change my pom.xml file for it? I tried using :

info.app.build-time=@build-time@

But this doesnt work.

Thanks

like image 286
pgman Avatar asked Sep 22 '17 10:09

pgman


People also ask

How do I find my actuator information?

You can reach the info actuator on your local machine: http://localhost:8080/actuator/info once you start your Spring Boot application.

Which endpoint is Spring Boot actuator?

The application runs on port 8080 by default. Once the actuator has started, we can see the list of all the endpoints exposed over HTTP. Let's invoke the health endpoint by invoking the URL http://localhost:8080/actuator/health. It denotes the status UP.

How do you call an actuator endpoint in a Spring Boot?

When we add Spring Actuator Dependencies to our spring boot project, it automatically enables actuator endpoints. Add below dependencies to your spring application to enable spring boot actuator endpoints. Now when you will run the application, you will see actuator endpoints being mapped in the logs.

What is the Spring Boot actuator what information can it give you?

Actuator is mainly used to expose operational information about the running application — health, metrics, info, dump, env, etc. It uses HTTP endpoints or JMX beans to enable us to interact with it. Once this dependency is on the classpath, several endpoints are available for us out of the box.


1 Answers

You can define a timestamp Maven property in your pom.xml like so:

<properties>
   <timestamp>${maven.build.timestamp}</timestamp>
   <maven.build.timestamp.format>yyyy-MM-dd-HH:mm</maven.build.timestamp.format>
</properties>

And then reference it using the @...@ convention like so:

info:
   app:
     timestamp: @timestamp@
like image 165
glytching Avatar answered Sep 28 '22 16:09

glytching