0% found this document useful (0 votes)
8 views16 pages

4.2.1 (TASK) Using Actuator

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views16 pages

4.2.1 (TASK) Using Actuator

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 16

Applying Spring Boot Actuator

By:MadSe
• Objective :

• Using Spring Boot Actuator to expose endpoints


that will show application related info.

• Steps :

1) Make a copy of our “mycoolapp” application


folder to create another app to keep the
applications organized.
2) Adding Actuator dependency in our POM file
and exposing endpoints

By:MadSe
Making a Copy out of Previous App

By:MadSe
• As given above, access the “mycoolapp” project properties.
• Get the application folder path.
• Open the path in Windows File Explorer and create a copy
• Rename it to “Actuator_project”
• Open the project in Net Beans again.
• NOTE : Only the folder name is changed. The name of the
project will remain the same.

By:MadSe
Adding Dependency Reference in POM.xml

By:MadSe
• #36  Adding a comment
• #37 - #40  Adding reference to the actuator

By:MadSe
Adding Parameters in “Application.properties”

By:MadSe
• By default, only “/health” is exposed
• #1  Exposing all the endpoints
• #2  Enabling the customizable information for the “/actuator/info”
endpoint.
• #3 - #5  Adding info about application.
• NEXT page  Compiling the app

By:MadSe
• Open the main “MyCoolApplication.java” file  Run
•  Check out the “Output” window
•  Notice the 14 new endpoints being exposed
•  Notice, the new endpoints will be prefixed with the base path
“/actuator”  Next, accessing the endpoints in the browser
By:MadSe
• Above, accessing the endpoints.
• The “Info” endpoints doesn’t display any information about our app.
• Check out the other endpoints given below

/actuator/health Provides application health information.


/actuator/metrics Exposes various metrics about the application
(e.g., memory usage, CPU usage).
/actuator/info Displays arbitrary application info
/actuator/env Exposes environment properties.
/actuator/loggers Manages and monitors logging levels.
/actuator/beans Displays all Spring beans in the application
context.
By:MadSe
Restricting Access To End Points

By:MadSe
• We can restrict access to endpoints for security reasons.

• To secure the endpoints, add the following dependency in POM.xml


•  Next, compile the main JAVA app  Check the OUTPUT log

By:MadSe
• Above, in the Output log, a security password generated
automatically to access the endpoints.
• Try accessing the endpoints given on the next page 

By:MadSe
• While trying to access “/actuator/info”, we get the screen above.
• To access, put in the user as “user” and password to be the one
mentioned in the “Output” window.

• NOTE : The “/actuator/health” endpoint will remain available with the


authentication.  Next, we will learn how to restrict access to a
particular endpoint like “/health”

By:MadSe
Restricting Access To “/health”

By:MadSe
• #8  Restricting default access to the “/health” endpoint  compile 
run
• Now, we will get password prompt while trying to access “/health” as
well  We will not be able to access “/health” now even if we put in
the right username and password as it is restricted in the application
parameters.

• Note  use comma-delimited list of endpoints to disable more than


one endpoints like “health, info”
By:MadSe

You might also like