Use the following commands to build run the application:
$ mvn clean package
$ java -jar target/livelessons-operations-actuator-1.0.0-SNAPSHOT.jar
The following HTTP endpoints can be inspected in a running application:
To view the same information using JMX you can use jconsole
:
$ jconsole
Select demo.OperationsActuatorApplication
from the “local applications” section (use
insecure connection if asked) then click on the MBeans tab. You can the endpoints under
org.springframework.boot/Endpoint
pick an endpoint then click the getData
button
under operations
.
You can ssh into the running application using the following command:
$ ssh -p 2000 livelessons@localhost
The password is livelessons
(see application.properties
).
Type help
to get a list of commands. Endpoints can be executed using
endpoint invoke <name>
(for example endpoint invoke info
). Several endpoints are
also surfaced directly (for example metrics
). The dashboard
command is also quite
fun.
Jolokia allows you to expose JMX beans over HTTP. Adding the library is all you need to do to configure it with Spring Boot. It can be useful if you have existing MBeans (or MBeans exposed by libraries that you use).
Here is an example call that will return HeapMemoryUsage
information from the Memory
MBean in java/lang
:
$ curl http://localhost:8080/jolokia/read/java.lang:type=Memory/HeapMemoryUsage
This sample includes the git-commit-id-plugin`Maven Plugin which will write a
`git.properties
file whenever the project is build. This information is automatically
exposed on the /info
endpoint.
The commit SHA is very useful when running applications in production as it allows you
to know exactly which commit was used to build the running app. You also use this to
get back to the POM.xml
or build.gradle
and know exactly which library versions were
used when the app was built.