Spring Boot

Spring Boot Actuator A Complete Guide

<div dir&equals;"ltr" style&equals;"text-align&colon; justify&semi;">&NewLine;<div style&equals;"text-align&colon; justify&semi;">&NewLine;<div style&equals;"font-size&colon; 13pt&semi;">&NewLine;<div style&equals;"font-family&colon; calibri&comma; sans-serif&semi; font-size&colon; 13pt&semi;">Hello friends&excl;&excl;&excl; In this article&comma; we’re going to introduce <strong>Spring Boot Actuator<&sol;strong> for collecting metrics about your production grade applications and also talk about some simple ways to work with them in production&period; Spring Boot Actuator is a sub-project of Spring Boot&period; It adds several production grade services to your application with little effort on your part&period; Lets discuss here about spring boot actuator and different types of metrics that can be collected using this feature&period;<&sol;div>&NewLine;<&sol;div>&NewLine;<h2>Spring Boot Actuator<&sol;h2>&NewLine;<div style&equals;"font-size&colon; 13pt&semi;">&NewLine;<div style&equals;"font-family&colon; calibri&comma; sans-serif&semi; font-size&colon; 13pt&semi;"><b>Related Tutorial read before it&period;<&sol;b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;introduction-to-spring-boot-a-spring-boot-complete-guide&sol;"><b>Introduction to Spring Boot &&num;8211&semi; A Spring Boot Complete Guide<&sol;b><&sol;a><&sol;div>&NewLine;<h3 style&equals;"font-family&colon; calibri&comma; sans-serif&semi; font-size&colon; 13pt&semi;"><b>Table of Contents<&sol;b><&sol;h3>&NewLine;<ol style&equals;"font-family&colon; calibri&comma; sans-serif&semi; font-size&colon; 13pt&semi;">&NewLine;<li><b><a href&equals;"http&colon;&sol;&num;1">What Is An Actuator&quest;<&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;spring-boot-actuator-complete-guide&sol;&num;2">How to Enable an Actuator&quest;<&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;spring-boot-actuator-complete-guide&sol;&num;3">Endpoints<&sol;a><&sol;b>&NewLine;<ul>&NewLine;<li style&equals;"list-style-type&colon; none&semi;">&NewLine;<ul>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;spring-boot-actuator-complete-guide&sol;&num;31">Customizing Existing Endpoints<&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;spring-boot-actuator-complete-guide&sol;&num;32">Health information- &sol;health Endpoint<&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;spring-boot-actuator-complete-guide&sol;&num;33">Security with HealthIndicators<&sol;a><&sol;b>&NewLine;<ul>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;spring-boot-actuator-complete-guide&sol;&num;331">A Custom HealthIndicator<&sol;a><&sol;b><&sol;li>&NewLine;<&sol;ul>&NewLine;<&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;spring-boot-actuator-complete-guide&sol;&num;34">Application information- &sol;info Endpoint<&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;spring-boot-actuator-complete-guide&sol;&num;35">Metrics Information-&sol;metrics Endpoint<&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;spring-boot-actuator-complete-guide&sol;&num;36">Endpoint – Logfile<&sol;a><&sol;b><&sol;li>&NewLine;<&sol;ul>&NewLine;<&sol;li>&NewLine;<&sol;ul>&NewLine;<&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;2016&sol;08&sol;spring-boot-actuator-complete-guide&period;html&num;4">Custom Metric Data<&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;2016&sol;08&sol;spring-boot-actuator-complete-guide&period;html&num;5">Create A New Endpoint<&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;2016&sol;08&sol;spring-boot-actuator-complete-guide&period;html&num;6">A New Endpoint To List All Endpoints<&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;2016&sol;08&sol;spring-boot-actuator-complete-guide&period;html&num;7">Actuator Example application<&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;2016&sol;08&sol;spring-boot-actuator-complete-guide&period;html&num;8">Summary<&sol;a><&sol;b><&sol;li>&NewLine;<&sol;ol>&NewLine;<div id&equals;"ads-id" align&equals;"center"><&sol;div>&NewLine;<h3 id&equals;"1" style&equals;"font-family&colon; calibri&comma; sans-serif&semi; font-size&colon; 13pt&semi;"><b>1&period; What Is Spring Boot Actuator&quest;<&sol;b><&sol;h3>&NewLine;<div style&equals;"font-family&colon; calibri&comma; sans-serif&semi; font-size&colon; 13pt&semi;">Spring Boot Actuator is sub-project of Spring Boot and it is one of the nice feature that adds great value to the Spring Boot applications&period; It adds several production grade services to your application with little effort on your part&period; There are also has many features added to your application out-of-the-box for managing the service in a production &lpar;or other&rpar; environment&period; They’re mainly used to expose different types of information about the running application – health&comma; metrics&comma; info&comma; dump&comma; env etc&period;<&sol;div>&NewLine;<div style&equals;"font-family&colon; calibri&comma; sans-serif&semi; font-size&colon; 13pt&semi;"><&sol;div>&NewLine;<h3 id&equals;"2" style&equals;"font-family&colon; calibri&comma; sans-serif&semi; font-size&colon; 13pt&semi;"><b>2&period; How To Enable Spring Boot Actuator&quest;<&sol;b><&sol;h3>&NewLine;<div style&equals;"font-family&colon; calibri&comma; sans-serif&semi; font-size&colon; 13pt&semi;">The spring-boot-actuator module provides all of Spring Boot’s production-ready features&period; The simplest way to enable the features is to add a dependency to the <b>spring-boot-starter-actuator<&sol;b> &OpenCurlyQuote;Starter’&period;<&sol;div>&NewLine;<div style&equals;"font-family&colon; calibri&comma; sans-serif&semi; font-size&colon; 13pt&semi;"><b><br &sol;>&NewLine;<&sol;b><b>2&period;1 In Maven Project<&sol;b><&sol;div>&NewLine;<pre class&equals;"highlight" style&equals;"font-family&colon; calibri&comma; sans-serif&semi; font-size&colon; 13pt&semi;">&lt&semi;dependency&gt&semi; &NewLine; &lt&semi;groupId&gt&semi;org&period;springframework&period;boot&lt&semi;&sol;groupId&gt&semi; &NewLine; &lt&semi;artifactId&gt&semi;spring-boot-starter-actuator&lt&semi;&sol;artifactId&gt&semi; &NewLine; &lt&semi;&sol;dependency&gt&semi; &NewLine;<&sol;pre>&NewLine;<div style&equals;"font-family&colon; calibri&comma; sans-serif&semi; font-size&colon; 13pt&semi;"><b><br &sol;>&NewLine;<&sol;b><b>2&period;2 In Gradle Project<&sol;b><&sol;div>&NewLine;<pre class&equals;"highlight" style&equals;"font-family&colon; calibri&comma; sans-serif&semi; font-size&colon; 13pt&semi;">dependencies &lbrace; &NewLine; compile&lpar;"org&period;springframework&period;boot&colon;spring-boot-starter-actuator"&rpar; &NewLine;&rcub; &NewLine;<&sol;pre>&NewLine;<h3 id&equals;"3" style&equals;"font-family&colon; calibri&comma; sans-serif&semi; font-size&colon; 13pt&semi;"><b>3&period; Endpoints<&sol;b><&sol;h3>&NewLine;<div style&equals;"font-family&colon; calibri&comma; sans-serif&semi; font-size&colon; 13pt&semi;">Actuator endpoints allow you to monitor and interact with your application&period; Spring Boot includes a number of built-in endpoints and you can also add your own&period; Most endpoints are sensitive – meaning they’re not fully public – while a handful are not&colon; &sol;health and &sol;info&period;<&sol;div>&NewLine;<div style&equals;"font-family&colon; calibri&comma; sans-serif&semi; font-size&colon; 13pt&semi;"><&sol;div>&NewLine;<div style&equals;"font-family&colon; calibri&comma; sans-serif&semi; font-size&colon; 13pt&semi;">Here’s some of the most common endpoints Boot provides out of the box&colon;<&sol;div>&NewLine;<div style&equals;"font-family&colon; calibri&comma; sans-serif&semi; font-size&colon; 13pt&semi;"><&sol;div>&NewLine;<ul style&equals;"font-family&colon; calibri&comma; sans-serif&semi; font-size&colon; 13pt&semi;">&NewLine;<li><b>&sol;actuator-<&sol;b> Provides a hypermedia-based &OpenCurlyDoubleQuote;discovery page” for the other endpoints&period; Requires Spring HATEOAS to be on the classpath&period; Sensitive by Default&period;<&sol;li>&NewLine;<li><b>&sol;autoconfig- <&sol;b>Displays an auto-configuration report showing all auto-configuration candidates and the reason why they &OpenCurlyQuote;were’ or &OpenCurlyQuote;were not’ applied&period; Sensitive by Default&period;<&sol;li>&NewLine;<li><b>&sol;beans-<&sol;b> Displays a complete list of all the Spring beans in your application&period; Sensitive by Default&period;<&sol;li>&NewLine;<li><b>&sol;configprops-<&sol;b> This endpoint shows configuration properties used by your application&period; Sensitive by Default&period;<&sol;li>&NewLine;<li><b>&sol;dump-<&sol;b> Performs a thread dump&period; Sensitive by Default&period;<&sol;li>&NewLine;<li><b>&sol;env-<&sol;b> Exposes spring’s properties from the configurations&period; Sensitive by Default&period;<&sol;li>&NewLine;<li><b>&sol;health<&sol;b> – Shows application health information &lpar;a simple &OpenCurlyQuote;status’ when accessed over an unauthenticated connection or full message details when authenticated&rpar;&period; It is sensitive by default&period;<&sol;li>&NewLine;<li><b>&sol;info<&sol;b> – Displays arbitrary application info&period; Not sensitive by default&period;<&sol;li>&NewLine;<li><b>&sol;metrics<&sol;b> – Shows &OpenCurlyQuote;metrics’ information for the current application&period; It is also sensitive by default&period;<&sol;li>&NewLine;<li><b>&sol;mappings-<&sol;b> Displays a list of all &commat;RequestMapping paths&period; Sensitive by Default&period;<&sol;li>&NewLine;<li><b>&sol;shutdown-<&sol;b> This endpoint allows to shutdown the application&period; This is not enabled by default&period; Sensitive by Default&period;<&sol;li>&NewLine;<li><b>&sol;trace <&sol;b>– Displays trace information &lpar;by default the last few HTTP requests&rpar;&period; Sensitive by Default&period;<&sol;li>&NewLine;<li><b>&sol;logfile<&sol;b>&&num;8211&semi; Provides access to the configured log files &lpar;This feature supported since Spring Boot 1&period;3&period;0&rpar;&period; Sensitive by Default&period;<&sol;li>&NewLine;<li><b>&sol;flyway-<&sol;b> This endpoint provides the details of any flyway database migrations have been applied&period; Sensitive by Default&period;<&sol;li>&NewLine;<li><b>&sol;liquibase-<&sol;b> This endpoint provides the details of any liquibase database migrations have been applied&period; Sensitive by Default&period;<&sol;li>&NewLine;<&sol;ul>&NewLine;<div id&equals;"31" style&equals;"font-family&colon; calibri&comma; sans-serif&semi; font-size&colon; 13pt&semi;"><b>3&period;1 Customizing Existing Endpoints<&sol;b><&sol;div>&NewLine;<div style&equals;"font-family&colon; calibri&comma; sans-serif&semi; font-size&colon; 13pt&semi;">Above listed each endpoint can be customized with properties using the following format&colon;<&sol;div>&NewLine;<div style&equals;"font-family&colon; calibri&comma; sans-serif&semi; font-size&colon; 13pt&semi;"><b><i>endpoints&period;&lbrack;endpoint name&rsqb;&period;&lbrack;property to customize&rsqb;<&sol;i><&sol;b><&sol;div>&NewLine;<ul style&equals;"font-family&colon; calibri&comma; sans-serif&semi; font-size&colon; 13pt&semi;">&NewLine;<li>id – by which this endpoint will be accessed over HTTP<&sol;li>&NewLine;<li>enabled – if true then it can be accessed otherwise not<&sol;li>&NewLine;<li>sensitive – if true then need authorization to show crucial information over HTTP<&sol;li>&NewLine;<&sol;ul>&NewLine;<div style&equals;"font-family&colon; calibri&comma; sans-serif&semi; font-size&colon; 13pt&semi;"><&sol;div>&NewLine;<div style&equals;"font-family&colon; calibri&comma; sans-serif&semi; font-size&colon; 13pt&semi;">You can change how those endpoints are exposed using <b>application&period;properties<&sol;b>&comma; the most common settings&colon;<&sol;div>&NewLine;<ul style&equals;"font-family&colon; calibri&comma; sans-serif&semi; font-size&colon; 13pt&semi;">&NewLine;<li><b>management&period;port&equals;8081<&sol;b> &&num;8211&semi; you can expose those endpoints on port other than the one application is using &lpar;8081 here&rpar;&period;<&sol;li>&NewLine;<li><b>management&period;address&equals;127&period;0&period;0&period;1<&sol;b> &&num;8211&semi; you can only allow to access by IP address &lpar;localhost here&rpar;&period;<&sol;li>&NewLine;<li><b>management&period;context-path&equals;&sol;actuator<&sol;b> &&num;8211&semi; allows you to have those endpoints grouped under specified context path rather than root&comma; i&period;e&period; &sol;actuator&sol;health&period;<&sol;li>&NewLine;<li><b>endpoints&period;health&period;enabled&equals;false<&sol;b> &&num;8211&semi; allows to enable&sol;disable specified endpoint by name&comma; here &sol;health is disabled&period;<&sol;li>&NewLine;<&sol;ul>&NewLine;<div style&equals;"font-family&colon; calibri&comma; sans-serif&semi; font-size&colon; 13pt&semi;"><b>Securing endpoints<&sol;b><&sol;div>&NewLine;<div style&equals;"font-family&colon; calibri&comma; sans-serif&semi; font-size&colon; 13pt&semi;">For security purposes&comma; you might choose to expose the actuator endpoints over a non-standard port – the <b>management&period;port<&sol;b> property can easily be used to configure that&period; The information exposed by endpoints is most of the time sensitive&period; While &sol;health is usually harmless to be exposed&comma; &sol;metrics would be too much&period; Fortunately&comma; you can use Spring Security for that purpose&period;<&sol;div>&NewLine;<div style&equals;"font-family&colon; calibri&comma; sans-serif&semi; font-size&colon; 13pt&semi;"><&sol;div>&NewLine;<div style&equals;"font-family&colon; calibri&comma; sans-serif&semi; font-size&colon; 13pt&semi;">Adding starter to class path by adding following dependency to <b>pom&period;xml<&sol;b><&sol;div>&NewLine;<pre class&equals;"highlight" style&equals;"font-family&colon; calibri&comma; sans-serif&semi; font-size&colon; 13pt&semi;">&lt&semi;dependency&gt&semi; &NewLine; &lt&semi;groupId&gt&semi;org&period;springframework&period;boot&lt&semi;&sol;groupId&gt&semi; &NewLine; &lt&semi;artifactId&gt&semi;spring-boot-starter-security&lt&semi;&sol;artifactId&gt&semi; &NewLine;&lt&semi;&sol;dependency&gt&semi; &NewLine;<&sol;pre>&NewLine;<div style&equals;"font-family&colon; calibri&comma; sans-serif&semi; font-size&colon; 13pt&semi;">You can disable basic security it in<b> application&period;properties<&sol;b>&comma; so that it leaves only the sensitive Actuator endpoints secured and leaves the rest open for access&colon;<&sol;div>&NewLine;<pre class&equals;"highlight" style&equals;"font-family&colon; calibri&comma; sans-serif&semi; font-size&colon; 13pt&semi;">security&period;basic&period;enabled&equals;false &NewLine;<&sol;pre>&NewLine;<div style&equals;"font-family&colon; calibri&comma; sans-serif&semi; font-size&colon; 13pt&semi;">You can secure these endpoints by defining the default security properties – user name&comma; password and role – in <b>application&period;properties<&sol;b> file&colon;<&sol;div>&NewLine;<pre class&equals;"highlight" style&equals;"font-family&colon; calibri&comma; sans-serif&semi; font-size&colon; 13pt&semi;">security&period;user&period;name&equals;admin &NewLine;security&period;user&period;password&equals;secret &NewLine;management&period;security&period;role&equals;SUPERUSER &NewLine;<&sol;pre>&NewLine;<div style&equals;"font-family&colon; calibri&comma; sans-serif&semi; font-size&colon; 13pt&semi;">In case you&&num;8217&semi;re using the security features across the application and decided to secure those endpoints yourself&comma; you can disable default security for Actuator&colon;<&sol;div>&NewLine;<pre class&equals;"highlight" style&equals;"font-family&colon; calibri&comma; sans-serif&semi; font-size&colon; 13pt&semi;">management&period;security&period;enabled&equals;false &NewLine;<&sol;pre>&NewLine;<div id&equals;"32" style&equals;"font-family&colon; calibri&comma; sans-serif&semi; font-size&colon; 13pt&semi;"><b>3&period;2 Health information- &sol;health Endpoint<&sol;b><&sol;div>&NewLine;<div style&equals;"font-family&colon; calibri&comma; sans-serif&semi; font-size&colon; 13pt&semi;">Health information can be used to check the status of your running application&period; It is often used by monitoring software to alert someone if a production system goes down&period; The default information exposed by the health endpoint depends on how it is accessed&period;<&sol;div>&NewLine;<div style&equals;"font-family&colon; calibri&comma; sans-serif&semi; font-size&colon; 13pt&semi;"><b><u>http&colon;&sol;&sol;localhost&colon;8080&sol;health<&sol;u><&sol;b><&sol;div>&NewLine;<pre class&equals;"highlight" style&equals;"font-family&colon; calibri&comma; sans-serif&semi; font-size&colon; 13pt&semi;">&lbrace; &NewLine;"status" &colon; "UP" &NewLine;&rcub; &NewLine;<&sol;pre>&NewLine;<div style&equals;"font-family&colon; calibri&comma; sans-serif&semi; font-size&colon; 13pt&semi;">This health information is collected from all the beans implementing <b>HealthIndicator <&sol;b>interface configured in your application context&period;<&sol;div>&NewLine;<div style&equals;"font-family&colon; calibri&comma; sans-serif&semi; font-size&colon; 13pt&semi;"><&sol;div>&NewLine;<div id&equals;"33" style&equals;"font-family&colon; calibri&comma; sans-serif&semi; font-size&colon; 13pt&semi;"><b>3&period;3 Security with HealthIndicators<&sol;b><&sol;div>&NewLine;<div style&equals;"font-family&colon; calibri&comma; sans-serif&semi; font-size&colon; 13pt&semi;">Some information returned by HealthIndicator is sensitive in nature – but you can configure <b>endpoints&period;health&period;sensitive&equals;false<&sol;b> to expose the other information like diskspace&comma; datasource etc&period;<&sol;div>&NewLine;<pre class&equals;"highlight" style&equals;"font-family&colon; calibri&comma; sans-serif&semi; font-size&colon; 13pt&semi;">endpoints&period;health&period;sensitive&equals;false &NewLine;<&sol;pre>&NewLine;<div style&equals;"font-family&colon; calibri&comma; sans-serif&semi; font-size&colon; 13pt&semi;">You can write your custom health indicator to provide additional details to the user&period; The following are the list of health indication implementation classes available for customization&colon;<&sol;div>&NewLine;<div style&equals;"font-family&colon; calibri&comma; sans-serif&semi; font-size&colon; 13pt&semi;"><&sol;div>&NewLine;<ul style&equals;"font-family&colon; calibri&comma; sans-serif&semi; font-size&colon; 13pt&semi;">&NewLine;<li>DiskSpaceHealthIndicator<&sol;li>&NewLine;<li>DataSourceHealthIndicator<&sol;li>&NewLine;<li>MongoHealthIndicator<&sol;li>&NewLine;<li>RabbitHealthIndicator<&sol;li>&NewLine;<li>SolrHealthIndicator<&sol;li>&NewLine;<&sol;ul>&NewLine;<div style&equals;"font-family&colon; calibri&comma; sans-serif&semi; font-size&colon; 13pt&semi;"><&sol;div>&NewLine;<div style&equals;"font-family&colon; calibri&comma; sans-serif&semi; font-size&colon; 13pt&semi;">The basic configurations for health endpoint is&colon;<&sol;div>&NewLine;<pre class&equals;"highlight" style&equals;"font-family&colon; calibri&comma; sans-serif&semi; font-size&colon; 13pt&semi;">endpoints&period;health&period;id&equals;health &NewLine;endpoints&period;health&period;sensitive&equals;true &NewLine;endpoints&period;health&period;enabled&equals;true &NewLine;<&sol;pre>&NewLine;<div id&equals;"331" style&equals;"font-family&colon; calibri&comma; sans-serif&semi; font-size&colon; 13pt&semi;"><b>Customized Health checkup&colon;<&sol;b><&sol;div>&NewLine;<div style&equals;"font-family&colon; calibri&comma; sans-serif&semi; font-size&colon; 13pt&semi;">The basic idea for health checks is that they can provide more insightful information to you on the application&&num;8217&semi;s health&period; Besides checking if the application is UP or DOWN&comma; which is done by default&comma; you can add checks for things like database connectivity or whatever suits you&period; This is in fact what is being done when you add other Spring Boot starters&comma; as they often provide additional health checks&period;<&sol;div>&NewLine;<pre class&equals;"highlight" style&equals;"font-family&colon; calibri&comma; sans-serif&semi; font-size&colon; 13pt&semi;">&sol;&ast;&ast; &NewLine; &ast; &NewLine; &ast;&sol; &NewLine;package com&period;dineshonjava&period;sba&semi; &NewLine; &NewLine;import org&period;springframework&period;boot&period;actuate&period;health&period;Health&semi; &NewLine;import org&period;springframework&period;boot&period;actuate&period;health&period;HealthIndicator&semi; &NewLine; &NewLine;&sol;&ast;&ast; &NewLine; &ast; &commat;author Dinesh&period;Rajput &NewLine; &ast; &NewLine; &ast;&sol; &NewLine;public class MyAppHealth implements HealthIndicator&lbrace; &NewLine; &NewLine; &commat;Override &NewLine; public Health health&lpar;&rpar; &lbrace; &NewLine; int errorCode &equals; check&lpar;&rpar;&semi; &sol;&sol; perform some specific health check &NewLine; if &lpar;errorCode &excl;&equals; 0&rpar; &lbrace; &NewLine; return Health&period;down&lpar;&rpar;&period;withDetail&lpar;"Error Code"&comma; errorCode&rpar;&period;build&lpar;&rpar;&semi; &NewLine; &rcub; &NewLine; return Health&period;up&lpar;&rpar;&period;build&lpar;&rpar;&semi; &NewLine; &rcub; &NewLine; &NewLine; private int check&lpar;&rpar; &lbrace; &NewLine; &sol;&sol; Your logic to check health &NewLine; return 0&semi; &NewLine; &rcub; &NewLine; &NewLine;&rcub; &NewLine;<&sol;pre>&NewLine;<div style&equals;"font-family&colon; calibri&comma; sans-serif&semi; font-size&colon; 13pt&semi;">As you can see all it takes is to create a bean implementing HealthIndicator with a method health&lpar;&rpar; returning appropriate Health object&period; The checks you create will appear on the &sol;health endpoint&comma; so the application can be monitored for them&period; The output will be&colon;<&sol;div>&NewLine;<div style&equals;"font-family&colon; calibri&comma; sans-serif&semi; font-size&colon; 13pt&semi;"><b><u>http&colon;&sol;&sol;localhost&colon;8080&sol;health<&sol;u><&sol;b><&sol;div>&NewLine;<pre class&equals;"highlight" style&equals;"font-family&colon; calibri&comma; sans-serif&semi; font-size&colon; 13pt&semi;">&lbrace; &NewLine;status&colon; "UP"&comma; &NewLine;diskSpace&colon; &lbrace; &NewLine;status&colon; "UP"&comma; &NewLine;total&colon; 240721588224&comma; &NewLine;free&colon; 42078715904&comma; &NewLine;threshold&colon; 10485760 &NewLine;&rcub; &NewLine;&rcub; &NewLine;<&sol;pre>&NewLine;<div id&equals;"34" style&equals;"font-family&colon; calibri&comma; sans-serif&semi; font-size&colon; 13pt&semi;"><b>3&period;4 Application information- &sol;info Endpoint<&sol;b><&sol;div>&NewLine;<div style&equals;"font-family&colon; calibri&comma; sans-serif&semi; font-size&colon; 13pt&semi;">Application information exposes various information collected from all InfoContributor beans defined in your ApplicationContext&period; Spring Boot includes a number of auto-configured InfoContributors and you can also write your own&period; The default value for sensitive is false&period; There is no harm in exposing this details as that is common details that has to be exposed to others&period;<&sol;div>&NewLine;<div style&equals;"font-family&colon; calibri&comma; sans-serif&semi; font-size&colon; 13pt&semi;"><&sol;div>&NewLine;<div style&equals;"font-family&colon; calibri&comma; sans-serif&semi; font-size&colon; 13pt&semi;">You can also customize the data shown by &sol;info endpoint – for example&colon; Configuration in <b>application&period;properties<&sol;b> file&colon;<&sol;div>&NewLine;<pre class&equals;"highlight" style&equals;"font-family&colon; calibri&comma; sans-serif&semi; font-size&colon; 13pt&semi;">&lbrace; &NewLine;endpoints&period;info&period;id&equals;info &NewLine;endpoints&period;info&period;sensitive&equals;false &NewLine;endpoints&period;info&period;enabled&equals;true &NewLine; &NewLine;info&period;app&period;name&equals;Spring Boot Actuator Application &NewLine;info&period;app&period;description&equals;This is my first Working Spring Actuator Examples &NewLine;info&period;app&period;version&equals;0&period;0&period;1-SNAPSHOT &NewLine;<&sol;pre>&NewLine;<div style&equals;"font-family&colon; calibri&comma; sans-serif&semi; font-size&colon; 13pt&semi;">And the sample output&colon;<&sol;div>&NewLine;<div style&equals;"font-family&colon; calibri&comma; sans-serif&semi; font-size&colon; 13pt&semi;"><b><u>http&colon;&sol;&sol;localhost&colon;8080&sol;info<&sol;u><&sol;b><&sol;div>&NewLine;<pre class&equals;"highlight" style&equals;"font-family&colon; calibri&comma; sans-serif&semi; font-size&colon; 13pt&semi;">&lbrace; &NewLine;&lbrace; &NewLine;app&colon; &lbrace; &NewLine;version&colon; "0&period;0&period;1-SNAPSHOT"&comma; &NewLine;description&colon; "This is my first Working Spring Actuator Examples"&comma; &NewLine;name&colon; "Spring Boot Actuator Application" &NewLine;&rcub; &NewLine;&rcub; &NewLine;<&sol;pre>&NewLine;<div id&equals;"35" style&equals;"font-family&colon; calibri&comma; sans-serif&semi; font-size&colon; 13pt&semi;"><b>3&period;5 Metrics Information-&sol;metrics Endpoint<&sol;b><&sol;div>&NewLine;<div style&equals;"font-family&colon; calibri&comma; sans-serif&semi; font-size&colon; 13pt&semi;">The metrics endpoint is one of the more important endpoints as it gathers and publishes information about OS&comma; JVM and Application level metrics&semi; out of the box&comma; we get things like memory&comma; heap&comma; processors&comma; threads&comma; classes loaded&comma; classes unloaded&comma; thread pools along with some HTTP metrics as well&period; By default this endpoint is enabled under the HTTP URL &sol;metrics&period;<&sol;div>&NewLine;<div style&equals;"font-family&colon; calibri&comma; sans-serif&semi; font-size&colon; 13pt&semi;">he example configuration for this endpoint is&colon;<&sol;div>&NewLine;<pre class&equals;"highlight" style&equals;"font-family&colon; calibri&comma; sans-serif&semi; font-size&colon; 13pt&semi;">&lbrace; &NewLine;endpoints&period;metrics&period;id&equals;metrics &NewLine;endpoints&period;metrics&period;sensitive&equals;true &NewLine;endpoints&period;metrics&period;enabled&equals;true &NewLine;<&sol;pre>&NewLine;<div style&equals;"font-family&colon; calibri&comma; sans-serif&semi; font-size&colon; 13pt&semi;">Here’s what the output of this endpoint looks like out of the box&colon;<&sol;div>&NewLine;<div style&equals;"font-family&colon; calibri&comma; sans-serif&semi; font-size&colon; 13pt&semi;">http&colon;&sol;&sol;localhost&colon;8080&sol;metrics<&sol;div>&NewLine;<pre class&equals;"highlight" style&equals;"font-family&colon; calibri&comma; sans-serif&semi; font-size&colon; 13pt&semi;">&lbrace; &NewLine;&lbrace; &NewLine;mem&colon; 55470&comma; &NewLine;mem&period;free&colon; 5398&comma; &NewLine;processors&colon; 4&comma; &NewLine;instance&period;uptime&colon; 9452&comma; &NewLine;uptime&colon; 14466&comma; &NewLine;systemload&period;average&colon; -1&comma; &NewLine;heap&period;committed&colon; 35020&comma; &NewLine;heap&period;init&colon; 16384&comma; &NewLine;heap&period;used&colon; 29621&comma; &NewLine;heap&colon; 253440&comma; &NewLine;nonheap&period;committed&colon; 20800&comma; &NewLine;nonheap&period;init&colon; 160&comma; &NewLine;nonheap&period;used&colon; 20451&comma; &NewLine;nonheap&colon; 0&comma; &NewLine;threads&period;peak&colon; 17&comma; &NewLine;threads&period;daemon&colon; 14&comma; &NewLine;threads&period;totalStarted&colon; 20&comma; &NewLine;threads&colon; 16&comma; &NewLine;classes&colon; 6542&comma; &NewLine;classes&period;loaded&colon; 6542&comma; &NewLine;classes&period;unloaded&colon; 0&comma; &NewLine;gc&period;copy&period;count&colon; 60&comma; &NewLine;gc&period;copy&period;time&colon; 232&comma; &NewLine;gc&period;marksweepcompact&period;count&colon; 2&comma; &NewLine;gc&period;marksweepcompact&period;time&colon; 61&comma; &NewLine;httpsessions&period;max&colon; -1&comma; &NewLine;httpsessions&period;active&colon; 0 &NewLine;&rcub; &NewLine;<&sol;pre>&NewLine;<div style&equals;"font-family&colon; calibri&comma; sans-serif&semi; font-size&colon; 13pt&semi;"><&sol;div>&NewLine;<div style&equals;"font-family&colon; calibri&comma; sans-serif&semi; font-size&colon; 13pt&semi;">There are following multiple resources matrics exposed by spring boot actualtor<&sol;div>&NewLine;<div style&equals;"font-family&colon; calibri&comma; sans-serif&semi; font-size&colon; 13pt&semi;"><b>3&period;5&period;1&period; System Metrics<&sol;b><&sol;div>&NewLine;<div style&equals;"font-family&colon; calibri&comma; sans-serif&semi; font-size&colon; 13pt&semi;">The following system metrics are exposed by Spring Boot&colon;<&sol;div>&NewLine;<ul style&equals;"font-family&colon; calibri&comma; sans-serif&semi; font-size&colon; 13pt&semi;">&NewLine;<li>The total system memory in KB &lpar;mem&rpar;<&sol;li>&NewLine;<li>The amount of free memory in KB &lpar;mem&period;free&rpar;<&sol;li>&NewLine;<li>The number of processors &lpar;processors&rpar;<&sol;li>&NewLine;<li>The system uptime in milliseconds &lpar;uptime&rpar;<&sol;li>&NewLine;<li>The application context uptime in milliseconds &lpar;instance&period;uptime&rpar;<&sol;li>&NewLine;<li>The average system load &lpar;systemload&period;average&rpar;<&sol;li>&NewLine;<li>Heap information in KB &lpar;heap&comma; heap&period;committed&comma; heap&period;init&comma; heap&period;used&rpar;<&sol;li>&NewLine;<li>Thread information &lpar;threads&comma; thread&period;peak&comma; thread&period;daemon&rpar;<&sol;li>&NewLine;<li>Class load information &lpar;classes&comma; classes&period;loaded&comma; classes&period;unloaded&rpar;<&sol;li>&NewLine;<li>Garbage collection information &lpar;gc&period;xxx&period;count&comma; gc&period;xxx&period;time&rpar;<&sol;li>&NewLine;<&sol;ul>&NewLine;<div style&equals;"font-family&colon; calibri&comma; sans-serif&semi; font-size&colon; 13pt&semi;"><b>3&period;5&period;2&period; DataSource metrics<&sol;b><&sol;div>&NewLine;<div style&equals;"font-family&colon; calibri&comma; sans-serif&semi; font-size&colon; 13pt&semi;">The following metrics are exposed for each supported DataSource defined in your application&colon;<&sol;div>&NewLine;<ul style&equals;"font-family&colon; calibri&comma; sans-serif&semi; font-size&colon; 13pt&semi;">&NewLine;<li>The number of active connections &lpar;datasource&period;xxx&period;active&rpar;<&sol;li>&NewLine;<li>The current usage of the connection pool &lpar;datasource&period;xxx&period;usage&rpar;&period;<&sol;li>&NewLine;<&sol;ul>&NewLine;<div style&equals;"font-family&colon; calibri&comma; sans-serif&semi; font-size&colon; 13pt&semi;"><b>3&period;5&period;3 Cache metrics<&sol;b><&sol;div>&NewLine;<div style&equals;"font-family&colon; calibri&comma; sans-serif&semi; font-size&colon; 13pt&semi;">The following metrics are exposed for each supported cache defined in your application&colon;<&sol;div>&NewLine;<ul style&equals;"font-family&colon; calibri&comma; sans-serif&semi; font-size&colon; 13pt&semi;">&NewLine;<li>The current size of the cache &lpar;cache&period;xxx&period;size&rpar;<&sol;li>&NewLine;<li>Hit ratio &lpar;cache&period;xxx&period;hit&period;ratio&rpar;<&sol;li>&NewLine;<li>Miss ratio &lpar;cache&period;xxx&period;miss&period;ratio&rpar;<&sol;li>&NewLine;<&sol;ul>&NewLine;<div style&equals;"font-family&colon; calibri&comma; sans-serif&semi; font-size&colon; 13pt&semi;">By default&comma; Spring Boot provides cache statistics for EhCache&comma; Hazelcast&comma; Infinispan&comma; JCache and Guava&period;<&sol;div>&NewLine;<div style&equals;"font-family&colon; calibri&comma; sans-serif&semi; font-size&colon; 13pt&semi;"><b>3&period;5&period;4 Tomcat session metrics<&sol;b><&sol;div>&NewLine;<div style&equals;"font-family&colon; calibri&comma; sans-serif&semi; font-size&colon; 13pt&semi;">If you are using Tomcat as your embedded servlet container&comma; session metrics will automatically be exposed&period; The httpsessions&period;active and httpsessions&period;max keys provide the number of active and maximum sessions&period;<&sol;div>&NewLine;<div style&equals;"font-family&colon; calibri&comma; sans-serif&semi; font-size&colon; 13pt&semi;"><&sol;div>&NewLine;<div style&equals;"font-family&colon; calibri&comma; sans-serif&semi; font-size&colon; 13pt&semi;">there are many more matrics you can following spring boot docs for more info http&colon;&sol;&sol;docs&period;spring&period;io&sol;spring-boot&sol;docs&sol;current-SNAPSHOT&sol;reference&sol;htmlsingle&sol;&period;<&sol;div>&NewLine;<div style&equals;"font-family&colon; calibri&comma; sans-serif&semi; font-size&colon; 13pt&semi;"><&sol;div>&NewLine;<div style&equals;"font-family&colon; calibri&comma; sans-serif&semi; font-size&colon; 13pt&semi;"><b>3&period;6 Endpoint – Logfile<&sol;b><&sol;div>&NewLine;<div style&equals;"font-family&colon; calibri&comma; sans-serif&semi; font-size&colon; 13pt&semi;">This endpoint will be automatically enabled if <b>logging&period;path<&sol;b> or <b>logging&period;file<&sol;b> properties are configured in the <b>application&period;properties<&sol;b> file&period; When you access the logile endpoint&comma; this will return the complete log of the application&period;<&sol;div>&NewLine;<div style&equals;"font-family&colon; calibri&comma; sans-serif&semi; font-size&colon; 13pt&semi;"><&sol;div>&NewLine;<h3 id&equals;"4" style&equals;"font-family&colon; calibri&comma; sans-serif&semi; font-size&colon; 13pt&semi;"><b>4&period; Custom Metric Data<&sol;b><&sol;h3>&NewLine;<div style&equals;"font-family&colon; calibri&comma; sans-serif&semi; font-size&colon; 13pt&semi;">To record your own metrics inject a CounterService and&sol;or GaugeService into your bean&period; The CounterService exposes increment&comma; decrement and reset methods&semi; the GaugeService provides a submit method&period;<&sol;div>&NewLine;<div style&equals;"font-family&colon; calibri&comma; sans-serif&semi; font-size&colon; 13pt&semi;"><&sol;div>&NewLine;<div style&equals;"font-family&colon; calibri&comma; sans-serif&semi; font-size&colon; 13pt&semi;"><b>For example<&sol;b> – we’ll customize the login flow to record a successful and failed login attempt&colon;<&sol;div>&NewLine;<pre class&equals;"highlight" style&equals;"font-family&colon; calibri&comma; sans-serif&semi; font-size&colon; 13pt&semi;">&sol;&ast;&ast; &NewLine; &ast; &NewLine; &ast;&sol; &NewLine;package com&period;dineshonjava&period;sba&semi; &NewLine; &NewLine;import org&period;springframework&period;beans&period;factory&period;annotation&period;Autowired&semi; &NewLine;import org&period;springframework&period;boot&period;actuate&period;metrics&period;CounterService&semi; &NewLine;import org&period;springframework&period;stereotype&period;Service&semi; &NewLine; &NewLine;&sol;&ast;&ast; &NewLine; &ast; &commat;author Dinesh&period;Rajput &NewLine; &ast; &NewLine; &ast;&sol; &NewLine;&commat;Service &NewLine;public class LoginService &lbrace; &NewLine; &NewLine; &NewLine; CounterService counterService&semi; &NewLine; &NewLine; &commat;Autowired &NewLine; public LoginService&lpar;CounterService counterService&rpar; &lbrace; &NewLine; this&period;counterService &equals; counterService&semi; &NewLine; doLogin&lpar;&rpar;&semi; &NewLine; &rcub; &NewLine; &NewLine; public boolean login&lpar;String userName&comma; String password&rpar; &lbrace; &NewLine; boolean success&semi; &NewLine; if &lpar;userName&period;equals&lpar;"admin"&rpar; &amp&semi;&amp&semi; "secret"&period;equals&lpar;password&rpar;&rpar; &lbrace; &NewLine; counterService&period;increment&lpar;"counter&period;login&period;success"&rpar;&semi; &NewLine; success &equals; true&semi; &NewLine; &rcub; &NewLine; else &lbrace; &NewLine; counterService&period;increment&lpar;"counter&period;login&period;failure"&rpar;&semi; &NewLine; success &equals; false&semi; &NewLine; &rcub; &NewLine; return success&semi; &NewLine; &rcub; &NewLine; &NewLine; private void doLogin&lpar;&rpar; &lbrace; &NewLine; for&lpar;int i&equals;0&semi; i&lt&semi;10&semi; i&plus;&plus;&rpar;&lbrace; &NewLine; login&lpar;"admin"&comma; "secret"&rpar;&semi; &NewLine; &rcub; &NewLine; login&lpar;"admin"&comma; "scret"&rpar;&semi; &NewLine; login&lpar;"admin"&comma; "scret"&rpar;&semi; &NewLine; &rcub; &NewLine;&rcub; &NewLine; &NewLine;<&sol;pre>&NewLine;<div style&equals;"font-family&colon; calibri&comma; sans-serif&semi; font-size&colon; 13pt&semi;">Here’s what the output might look like&colon;<&sol;div>&NewLine;<pre class&equals;"highlight" style&equals;"font-family&colon; calibri&comma; sans-serif&semi; font-size&colon; 13pt&semi;">&period;&period;&period;&period;&period;&period; &NewLine;counter&period;login&period;failure&colon; 2&comma; &NewLine;counter&period;login&period;success&colon; 10 &NewLine;&period;&period;&period;&period; &NewLine;&rcub; &NewLine;<&sol;pre>&NewLine;<div style&equals;"font-family&colon; calibri&comma; sans-serif&semi; font-size&colon; 13pt&semi;">Besides <b>CounterService <&sol;b>the other one provided by default is <b>GaugeService <&sol;b>that is used to collect a single double value&comma; i&period;e&period; a measured execution time&period; You can also create and use your own implementations of these two&period;<&sol;div>&NewLine;<div style&equals;"font-family&colon; calibri&comma; sans-serif&semi; font-size&colon; 13pt&semi;"><&sol;div>&NewLine;<h3 id&equals;"5" style&equals;"font-family&colon; calibri&comma; sans-serif&semi; font-size&colon; 13pt&semi;"><b>5&period; Create A New Endpoint<&sol;b><&sol;h3>&NewLine;<div style&equals;"font-family&colon; calibri&comma; sans-serif&semi; font-size&colon; 13pt&semi;">Besides using the existing endpoints provided by Spring Boot – you can also create an entirely new endpoint&period; This is useful when you want to expose application details which are an added feature to your application&period;<&sol;div>&NewLine;<div style&equals;"font-family&colon; calibri&comma; sans-serif&semi; font-size&colon; 13pt&semi;"><&sol;div>&NewLine;<pre class&equals;"highlight" style&equals;"font-family&colon; calibri&comma; sans-serif&semi; font-size&colon; 13pt&semi;">&sol;&ast;&ast; &NewLine; &ast; &NewLine; &ast;&sol; &NewLine;package com&period;dineshonjava&period;sba&semi; &NewLine; &NewLine;import java&period;util&period;ArrayList&semi; &NewLine;import java&period;util&period;List&semi; &NewLine; &NewLine;import org&period;springframework&period;boot&period;actuate&period;endpoint&period;Endpoint&semi; &NewLine;import org&period;springframework&period;stereotype&period;Component&semi; &NewLine; &NewLine;&sol;&ast;&ast; &NewLine; &ast; &commat;author Dinesh&period;Rajput &NewLine; &ast; &NewLine; &ast;&sol; &NewLine;&commat;Component &NewLine;public class MyCustomEndpoint implements Endpoint&lt&semi;List&lt&semi;String&gt&semi;&gt&semi;&lbrace; &NewLine; &NewLine; &commat;Override &NewLine; public String getId&lpar;&rpar; &lbrace; &NewLine; return "myCustomEndpoint"&semi; &NewLine; &rcub; &NewLine; &NewLine; &commat;Override &NewLine; public List&lt&semi;String&gt&semi; invoke&lpar;&rpar; &lbrace; &NewLine; &sol;&sol; Custom logic to build the output &NewLine; List&lt&semi;String&gt&semi; list &equals; new ArrayList&lt&semi;String&gt&semi;&lpar;&rpar;&semi; &NewLine; list&period;add&lpar;"App message 1"&rpar;&semi; &NewLine; list&period;add&lpar;"App message 2"&rpar;&semi; &NewLine; list&period;add&lpar;"App message 3"&rpar;&semi; &NewLine; list&period;add&lpar;"App message 4"&rpar;&semi; &NewLine; return list&semi; &NewLine; &rcub; &NewLine; &NewLine; &commat;Override &NewLine; public boolean isEnabled&lpar;&rpar; &lbrace; &NewLine; return true&semi; &NewLine; &rcub; &NewLine; &NewLine; &commat;Override &NewLine; public boolean isSensitive&lpar;&rpar; &lbrace; &NewLine; return true&semi; &NewLine; &rcub; &NewLine; &NewLine;&rcub; &NewLine; &NewLine;<&sol;pre>&NewLine;<div style&equals;"font-family&colon; calibri&comma; sans-serif&semi; font-size&colon; 13pt&semi;">The way to access this new endpoint is by its id&comma; at <b>&sol;myCustomEndpoint<&sol;b>&period;<&sol;div>&NewLine;<div style&equals;"font-family&colon; calibri&comma; sans-serif&semi; font-size&colon; 13pt&semi;"><u><b>http&colon;&sol;&sol;localhost&colon;8080&sol;myCustomEndpoint<&sol;b><&sol;u><&sol;div>&NewLine;<div style&equals;"font-family&colon; calibri&comma; sans-serif&semi; font-size&colon; 13pt&semi;">Output&colon;<&sol;div>&NewLine;<pre class&equals;"highlight" style&equals;"font-family&colon; calibri&comma; sans-serif&semi; font-size&colon; 13pt&semi;">&lbrack; &NewLine;"App message 1"&comma; &NewLine;"App message 2"&comma; &NewLine;"App message 3"&comma; &NewLine;"App message 4" &NewLine;&rsqb; &NewLine;<&sol;pre>&NewLine;<div style&equals;"font-family&colon; calibri&comma; sans-serif&semi; font-size&colon; 13pt&semi;">MyCustomEndpoint class implements Endpoint&period; Any class of type Endpoint will be exposed as an endpoint in the server If you look at the methods&comma; getId&lpar;&rpar;&comma; isEnabled&lpar;&rpar; and isSensitive&lpar;&rpar;&comma; which are the properties that are overridden by the <b>application&period;properties<&sol;b> file&period; invoke&lpar;&rpar; is the important method responsible for writing the message&period;<&sol;div>&NewLine;<div style&equals;"font-family&colon; calibri&comma; sans-serif&semi; font-size&colon; 13pt&semi;"><&sol;div>&NewLine;<h3 id&equals;"6" style&equals;"font-family&colon; calibri&comma; sans-serif&semi; font-size&colon; 13pt&semi;"><b>6&period; A New Endpoint To List All Endpoints<&sol;b><&sol;h3>&NewLine;<div style&equals;"font-family&colon; calibri&comma; sans-serif&semi; font-size&colon; 13pt&semi;">It is quite useful if you have an endpoint to display all the endpoints in a single web page&period; There is a built-in endpoint &sol;actuator for this purpose&comma; but you have to add HateOAS in the classpath to enable that feature&period; To implement this one&comma; you’ll need to extend the AbstractEndpoint class&colon;<&sol;div>&NewLine;<pre class&equals;"highlight" style&equals;"font-family&colon; calibri&comma; sans-serif&semi; font-size&colon; 13pt&semi;">&sol;&ast;&ast; &NewLine; &ast; &NewLine; &ast;&sol; &NewLine;package com&period;dineshonjava&period;sba&semi; &NewLine; &NewLine;import java&period;util&period;List&semi; &NewLine; &NewLine;import org&period;springframework&period;beans&period;factory&period;annotation&period;Autowired&semi; &NewLine;import org&period;springframework&period;boot&period;actuate&period;endpoint&period;AbstractEndpoint&semi; &NewLine;import org&period;springframework&period;boot&period;actuate&period;endpoint&period;Endpoint&semi; &NewLine;import org&period;springframework&period;stereotype&period;Component&semi; &NewLine; &NewLine;&sol;&ast;&ast; &NewLine; &ast; &commat;author Dinesh&period;Rajput &NewLine; &ast; &NewLine; &ast;&sol; &NewLine;&commat;Component &NewLine;&commat;SuppressWarnings&lpar;"rawtypes"&rpar; &NewLine;public class MyListEndpoints extends AbstractEndpoint&lt&semi;List&lt&semi;Endpoint&gt&semi;&gt&semi;&lbrace; &NewLine; &NewLine; List&lt&semi;Endpoint&gt&semi; endpoints&semi; &NewLine; &NewLine; &commat;Autowired &NewLine; public MyListEndpoints&lpar;List&lt&semi;Endpoint&gt&semi; endpoints&rpar; &lbrace; &NewLine; super&lpar;"myListEndpoints"&rpar;&semi; &NewLine; this&period;endpoints &equals; endpoints&semi; &NewLine; &rcub; &NewLine; &NewLine; &commat;Override &NewLine; public List&lt&semi;Endpoint&gt&semi; invoke&lpar;&rpar; &lbrace; &NewLine; return this&period;endpoints&semi; &NewLine; &rcub; &NewLine; &NewLine;&rcub; &NewLine; &NewLine;<&sol;pre>&NewLine;<div style&equals;"font-family&colon; calibri&comma; sans-serif&semi; font-size&colon; 13pt&semi;">Here’s how the output will look like&colon;<&sol;div>&NewLine;<div style&equals;"font-family&colon; calibri&comma; sans-serif&semi; font-size&colon; 13pt&semi;">When you implement the above class&comma; there will be a new endpoint &OpenCurlyDoubleQuote;myListEndpoints” will be registered and exposed to the users&period; The output will be&colon;<&sol;div>&NewLine;<div style&equals;"font-family&colon; calibri&comma; sans-serif&semi; font-size&colon; 13pt&semi;">http&colon;&sol;&sol;localhost&colon;8080&sol;myListEndpoints<&sol;div>&NewLine;<pre class&equals;"highlight" style&equals;"font-family&colon; calibri&comma; sans-serif&semi; font-size&colon; 13pt&semi;">&lbrack; &NewLine;&lbrace; &NewLine;id&colon; "myCustomEndpoint"&comma; &NewLine;enabled&colon; true&comma; &NewLine;sensitive&colon; true &NewLine;&rcub;&comma; &NewLine;&lbrace; &NewLine;id&colon; "mappings"&comma; &NewLine;sensitive&colon; true&comma; &NewLine;enabled&colon; true &NewLine;&rcub;&comma; &NewLine;&lbrace; &NewLine;id&colon; "env"&comma; &NewLine;sensitive&colon; true&comma; &NewLine;enabled&colon; true &NewLine;&rcub;&comma; &NewLine;&lbrace; &NewLine;id&colon; "health"&comma; &NewLine;sensitive&colon; false&comma; &NewLine;enabled&colon; true&comma; &NewLine;timeToLive&colon; 1000 &NewLine;&rcub;&comma; &NewLine;&lbrace; &NewLine;id&colon; "beans"&comma; &NewLine;sensitive&colon; true&comma; &NewLine;enabled&colon; true &NewLine;&rcub;&comma; &NewLine;&lbrace; &NewLine;id&colon; "info"&comma; &NewLine;sensitive&colon; false&comma; &NewLine;enabled&colon; true &NewLine;&rcub;&comma; &NewLine;&lbrace; &NewLine;id&colon; "metrics"&comma; &NewLine;sensitive&colon; false&comma; &NewLine;enabled&colon; true &NewLine;&rcub;&comma; &NewLine;&lbrace; &NewLine;id&colon; "trace"&comma; &NewLine;sensitive&colon; true&comma; &NewLine;enabled&colon; true &NewLine;&rcub;&comma; &NewLine;&lbrace; &NewLine;id&colon; "dump"&comma; &NewLine;sensitive&colon; true&comma; &NewLine;enabled&colon; true &NewLine;&rcub;&comma; &NewLine;&lbrace; &NewLine;id&colon; "autoconfig"&comma; &NewLine;sensitive&colon; true&comma; &NewLine;enabled&colon; true &NewLine;&rcub;&comma; &NewLine;&lbrace; &NewLine;id&colon; "shutdown"&comma; &NewLine;sensitive&colon; true&comma; &NewLine;enabled&colon; false &NewLine;&rcub;&comma; &NewLine;&lbrace; &NewLine;id&colon; "configprops"&comma; &NewLine;sensitive&colon; true&comma; &NewLine;enabled&colon; true &NewLine;&rcub; &NewLine;&rsqb; &NewLine;<&sol;pre>&NewLine;<div style&equals;"font-family&colon; calibri&comma; sans-serif&semi; font-size&colon; 13pt&semi;"><&sol;div>&NewLine;<h3 id&equals;"7" style&equals;"font-family&colon; calibri&comma; sans-serif&semi; font-size&colon; 13pt&semi;"><b>7&period; Actuator Example application<&sol;b><&sol;h3>&NewLine;<div style&equals;"font-family&colon; calibri&comma; sans-serif&semi; font-size&colon; 13pt&semi;">In this section we will make the application which have all required configuration&period; For creating the application we have used here Spring Boot Web Initializr with Maven Build and following dependencies in pom&period;xml&period;<&sol;div>&NewLine;<pre class&equals;"highlight" style&equals;"font-size&colon; 13pt&semi;">&lt&semi;&quest;xml version&equals;"1&period;0" encoding&equals;"UTF-8"&quest;&gt&semi; &NewLine;&lt&semi;project xmlns&equals;"http&colon;&sol;&sol;maven&period;apache&period;org&sol;POM&sol;4&period;0&period;0" xmlns&colon;xsi&equals;"http&colon;&sol;&sol;www&period;w3&period;org&sol;2001&sol;XMLSchema-instance" &NewLine; xsi&colon;schemaLocation&equals;"http&colon;&sol;&sol;maven&period;apache&period;org&sol;POM&sol;4&period;0&period;0 http&colon;&sol;&sol;maven&period;apache&period;org&sol;xsd&sol;maven-4&period;0&period;0&period;xsd"&gt&semi; &NewLine; &lt&semi;modelVersion&gt&semi;4&period;0&period;0&lt&semi;&sol;modelVersion&gt&semi; &NewLine; &NewLine; &lt&semi;groupId&gt&semi;com&period;dineshonjava&period;sba&lt&semi;&sol;groupId&gt&semi; &NewLine; &lt&semi;artifactId&gt&semi;SpringBootActuator&lt&semi;&sol;artifactId&gt&semi; &NewLine; &lt&semi;version&gt&semi;0&period;0&period;1-SNAPSHOT&lt&semi;&sol;version&gt&semi; &NewLine; &lt&semi;packaging&gt&semi;jar&lt&semi;&sol;packaging&gt&semi; &NewLine; &NewLine; &lt&semi;name&gt&semi;SpringBootActuator&lt&semi;&sol;name&gt&semi; &NewLine; &lt&semi;description&gt&semi;SpringBootActuator project for Spring Boot Actuator&lt&semi;&sol;description&gt&semi; &NewLine; &NewLine; &lt&semi;parent&gt&semi; &NewLine; &lt&semi;groupId&gt&semi;org&period;springframework&period;boot&lt&semi;&sol;groupId&gt&semi; &NewLine; &lt&semi;artifactId&gt&semi;spring-boot-starter-parent&lt&semi;&sol;artifactId&gt&semi; &NewLine; &lt&semi;version&gt&semi;1&period;4&period;0&period;RELEASE&lt&semi;&sol;version&gt&semi; &NewLine; &lt&semi;relativePath&sol;&gt&semi; &lt&semi;&excl;-- lookup parent from repository --&gt&semi; &NewLine; &lt&semi;&sol;parent&gt&semi; &NewLine; &NewLine; &lt&semi;properties&gt&semi; &NewLine; &lt&semi;project&period;build&period;sourceEncoding&gt&semi;UTF-8&lt&semi;&sol;project&period;build&period;sourceEncoding&gt&semi; &NewLine; &lt&semi;project&period;reporting&period;outputEncoding&gt&semi;UTF-8&lt&semi;&sol;project&period;reporting&period;outputEncoding&gt&semi; &NewLine; &lt&semi;java&period;version&gt&semi;1&period;8&lt&semi;&sol;java&period;version&gt&semi; &NewLine; &lt&semi;&sol;properties&gt&semi; &NewLine; &NewLine; &lt&semi;dependencies&gt&semi; &NewLine; &lt&semi;dependency&gt&semi; &NewLine; &lt&semi;groupId&gt&semi;org&period;springframework&period;boot&lt&semi;&sol;groupId&gt&semi; &NewLine; &lt&semi;artifactId&gt&semi;spring-boot-starter-actuator&lt&semi;&sol;artifactId&gt&semi; &NewLine; &lt&semi;&sol;dependency&gt&semi; &NewLine; &lt&semi;dependency&gt&semi; &NewLine; &lt&semi;groupId&gt&semi;org&period;springframework&period;boot&lt&semi;&sol;groupId&gt&semi; &NewLine; &lt&semi;artifactId&gt&semi;spring-boot-starter-security&lt&semi;&sol;artifactId&gt&semi; &NewLine; &lt&semi;&sol;dependency&gt&semi; &NewLine; &lt&semi;dependency&gt&semi; &NewLine; &lt&semi;groupId&gt&semi;org&period;springframework&period;boot&lt&semi;&sol;groupId&gt&semi; &NewLine; &lt&semi;artifactId&gt&semi;spring-boot-starter-web&lt&semi;&sol;artifactId&gt&semi; &NewLine; &lt&semi;&sol;dependency&gt&semi; &NewLine; &NewLine; &lt&semi;dependency&gt&semi; &NewLine; &lt&semi;groupId&gt&semi;org&period;springframework&period;boot&lt&semi;&sol;groupId&gt&semi; &NewLine; &lt&semi;artifactId&gt&semi;spring-boot-starter-test&lt&semi;&sol;artifactId&gt&semi; &NewLine; &lt&semi;scope&gt&semi;test&lt&semi;&sol;scope&gt&semi; &NewLine; &lt&semi;&sol;dependency&gt&semi; &NewLine; &lt&semi;&sol;dependencies&gt&semi; &NewLine; &NewLine; &lt&semi;build&gt&semi; &NewLine; &lt&semi;plugins&gt&semi; &NewLine; &lt&semi;plugin&gt&semi; &NewLine; &lt&semi;groupId&gt&semi;org&period;springframework&period;boot&lt&semi;&sol;groupId&gt&semi; &NewLine; &lt&semi;artifactId&gt&semi;spring-boot-maven-plugin&lt&semi;&sol;artifactId&gt&semi; &NewLine; &lt&semi;&sol;plugin&gt&semi; &NewLine; &lt&semi;&sol;plugins&gt&semi; &NewLine; &lt&semi;&sol;build&gt&semi; &NewLine; &NewLine; &NewLine;&lt&semi;&sol;project&gt&semi; &NewLine;<&sol;pre>&NewLine;<div style&equals;"font-size&colon; 13pt&semi;"><&sol;div>&NewLine;<div style&equals;"font-size&colon; 13pt&semi;">And below is project struct as we have finally&period;<&sol;div>&NewLine;<div style&equals;"font-size&colon; 13pt&semi;"><&sol;div>&NewLine;<div class&equals;"separator" style&equals;"clear&colon; both&semi; font-size&colon; 13pt&semi; text-align&colon; center&semi;"><img src&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;wp-content&sol;uploads&sol;2016&sol;08&sol;Spring-Boot-Actuator&period;jpg" border&equals;"0" &sol;><&sol;div>&NewLine;<div style&equals;"font-size&colon; 13pt&semi;"><&sol;div>&NewLine;<div style&equals;"font-size&colon; 13pt&semi;"><b>application&period;properties<&sol;b> file for configuration for actuator<&sol;div>&NewLine;<pre class&equals;"highlight" style&equals;"font-size&colon; 13pt&semi;">&num;&sol;info endpoint configuration &NewLine;endpoints&period;info&period;id&equals;info &NewLine;endpoints&period;info&period;sensitive&equals;false &NewLine;endpoints&period;info&period;enabled&equals;true &NewLine;info&period;app&period;name&equals;Spring Boot Actuator Application &NewLine;info&period;app&period;description&equals;This is my first Working Spring Actuator Examples &NewLine;info&period;app&period;version&equals;0&period;0&period;1-SNAPSHOT &NewLine; &NewLine;&num;&sol;metrics endpoint configuration &NewLine;endpoints&period;metrics&period;id&equals;metrics &NewLine;endpoints&period;metrics&period;sensitive&equals;false &NewLine;endpoints&period;metrics&period;enabled&equals;true &NewLine; &NewLine;&num;securing endpoints by spring security &NewLine;security&period;basic&period;enabled&equals;true &NewLine;security&period;user&period;name&equals;admin &NewLine;security&period;user&period;password&equals;secret &NewLine; &NewLine;&num;&sol;health endpoint configuration &lpar;Comment when you are using customized health check&rpar; &NewLine;endpoints&period;health&period;id&equals;health &NewLine;endpoints&period;health&period;sensitive&equals;false &NewLine;endpoints&period;health&period;enabled&equals;true &NewLine; &NewLine;&num;Management for endpoints &NewLine;management&period;port&equals;8080 &NewLine;management&period;context-path&equals;&sol; &NewLine;management&period;security&period;enabled&equals;true &NewLine;<&sol;pre>&NewLine;<div style&equals;"font-size&colon; 13pt&semi;"><&sol;div>&NewLine;<div style&equals;"font-size&colon; 13pt&semi;"><b>Whole Code&colon;<&sol;b> Here I am not going put all required files for this application you can find whole application from following <strong><a href&equals;"https&colon;&sol;&sol;github&period;com&sol;DOJ-SoftwareConsultant&sol;SpringBootActuator">git<&sol;a> <&sol;strong>repository&period;<&sol;div>&NewLine;<div style&equals;"font-size&colon; 13pt&semi;"><b><a href&equals;"https&colon;&sol;&sol;www&period;blogger&period;com&sol;goog&lowbar;967565840"> <&sol;a><&sol;b><&sol;div>&NewLine;<p><b><a href&equals;"https&colon;&sol;&sol;github&period;com&sol;DOJ-SoftwareConsultant&sol;SpringBootActuator" target&equals;"&lowbar;blank" rel&equals;"noopener">https&colon;&sol;&sol;github&period;com&sol;DOJ-SoftwareConsultant&sol;SpringBootActuator<&sol;a><&sol;b><&sol;p>&NewLine;<h3><b>8&period; Summary&colon;<&sol;b><&sol;h3>&NewLine;<p>In this tutorial we had a first look at the interesting Actuator functionality provided by Spring Boot&period; I have explained about the basic concepts on actuators&comma; endpoints&comma; list of endpoints&comma; creating custom endpoints&comma; health check&comma;metrics and provided a complete working example application for spring boot actuator&period;<&sol;p>&NewLine;<p><b>Spring Boot Actuator Video&colon; by Baeldung<&sol;b><&sol;p>&NewLine;<p>Happy Spring Boot Learning&excl;&excl;&excl;<&sol;p>&NewLine;<div style&equals;"background-color&colon; &num;f2f9fc&semi; border-radius&colon; 3px&semi; border&colon; 1px solid &num;c9e6f2&semi; line-height&colon; 1&period;45&semi; padding&colon; 16px&semi;">&NewLine;<p><b>Spring Boot Related Topics<&sol;b><&sol;p>&NewLine;<ol style&equals;"text-align&colon; left&semi;">&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;introduction-to-spring-boot-a-spring-boot-complete-guide&sol;">Introduction to Spring Boo<&sol;a>t<&sol;b><&sol;li>&NewLine;<li><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;essentials-key-components-and-internals-of-spring-boot-framework&sol;"><b>Essentials and Key Components of Spring Boot<&sol;b><&sol;a><&sol;li>&NewLine;<li><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;spring-boot-cli-installation-and-hello-world-example&sol;"><b>Spring Boot CLI Installation and Hello World Example<&sol;b><&sol;a><&sol;li>&NewLine;<li><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;spring-boot-initilizr-web-interface-and-examples&sol;"><b>Spring Boot Initializr Web Interface<&sol;b><&sol;a><&sol;li>&NewLine;<li><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;spring-boot-initilizr-with-ides-via-spring-tool-suite&sol;"><b>Spring Boot Initializr With IDEs<&sol;b><&sol;a><&sol;li>&NewLine;<li><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;spring-boot-initializr-with-spring-boot-cli&sol;"><b>Spring Boot Initializr With Spring Boot CLI<&sol;b><&sol;a><&sol;li>&NewLine;<li><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;installing-spring-boot&sol;"><b>Installing Spring Boot<&sol;b><&sol;a><&sol;li>&NewLine;<li><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;developing-your-first-spring-boot-application-hello-world&sol;"><b>Developing your first Spring Boot application<&sol;b><&sol;a><&sol;li>&NewLine;<li><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;customizing-spring-boot-auto-configuration&sol;"><b>External Configurations for Spring Boot Applications<&sol;b><&sol;a><&sol;li>&NewLine;<li><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;logging-configuration-in-spring-boot&sol;"><b>Logging Configuration in Spring Boot<&sol;b><&sol;a><&sol;li>&NewLine;<li><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;spring-boot-with-spring-mvc-application&sol;"><b>Spring Boot and Spring MVC<&sol;b><&sol;a><&sol;li>&NewLine;<li><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;working-with-sql-databases-in-spring-boot-application&sol;"><b>Working with SQL Databases and Spring Boot<&sol;b><&sol;a><&sol;li>&NewLine;<li><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;mysql-configuration-with-spring-boot&sol;"><b>MySQL Configurations<&sol;b><&sol;a><&sol;li>&NewLine;<li><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;spring-data-jpa-using-in-spring-boot-application&sol;"><b>Spring Data JPA using Spring Boot Application<&sol;b><&sol;a><&sol;li>&NewLine;<li><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;spring-boot-with-nosql-technologies&sol;"><b>Spring Boot with NoSQL technologies<&sol;b><&sol;a><&sol;li>&NewLine;<li><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;spring-cache-tutorial&sol;"><b>Spring Cache Tutorial<&sol;b><&sol;a><&sol;li>&NewLine;<li><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;spring-security-tutorial-using-spring-boot&sol;"><b>Spring Security Tutorial with Spring Boot<&sol;b><&sol;a><&sol;li>&NewLine;<li><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;spring-boot-and-mongodb-in-rest-application&sol;"><b>Spring Boot and MongoDB in REST Application<&sol;b><&sol;a><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;spring-boot-actuator-complete-guide&sol;">Complete Guide for Spring Boot Actuator<&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;microservices-with-spring-boot&sol;">Microservices with Spring Boot<&sol;a><&sol;b><&sol;li>&NewLine;<&sol;ol>&NewLine;<&sol;div>&NewLine;<p>&nbsp&semi;<&sol;p>&NewLine;<&sol;div>&NewLine;<&sol;div>&NewLine;<&sol;div>&NewLine;<div class&equals;"wp-post-navigation"> &NewLine;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab; <div class&equals;"wp-post-navigation-pre"> &NewLine;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab; <a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;spring-security-tutorial-using-spring-boot&sol;">Previous<&sol;a> &NewLine;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab; <&sol;div> &NewLine;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab; <div class&equals;"wp-post-navigation-next"> &NewLine;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab; <a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;maven-pom-xml-file&sol;">Next<&sol;a> &NewLine;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab; <&sol;div> &NewLine;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;<&sol;div>&NewLine;<script type&equals;"text&sol;javascript">&NewLine;jQuery&lpar;document&rpar;&period;ready&lpar;function&lpar;&dollar;&rpar; &lbrace;&NewLine; &dollar;&period;post&lpar;'https&colon;&sol;&sol;dineshonjava&period;com&sol;wp-admin&sol;admin-ajax&period;php'&comma; &lbrace;action&colon; 'mts&lowbar;view&lowbar;count'&comma; id&colon; '125'&rcub;&rpar;&semi;&NewLine;&rcub;&rpar;&semi;&NewLine;<&sol;script>

Dinesh Rajput

Dinesh Rajput is the chief editor of a website Dineshonjava, a technical blog dedicated to the Spring and Java technologies. It has a series of articles related to Java technologies. Dinesh has been a Spring enthusiast since 2008 and is a Pivotal Certified Spring Professional, an author of a book Spring 5 Design Pattern, and a blogger. He has more than 10 years of experience with different aspects of Spring and Java design and development. His core expertise lies in the latest version of Spring Framework, Spring Boot, Spring Security, creating REST APIs, Microservice Architecture, Reactive Pattern, Spring AOP, Design Patterns, Struts, Hibernate, Web Services, Spring Batch, Cassandra, MongoDB, and Web Application Design and Architecture. He is currently working as a technology manager at a leading product and web development company. He worked as a developer and tech lead at the Bennett, Coleman & Co. Ltd and was the first developer in his previous company, Paytm. Dinesh is passionate about the latest Java technologies and loves to write technical blogs related to it. He is a very active member of the Java and Spring community on different forums. When it comes to the Spring Framework and Java, Dinesh tops the list!

Share
Published by
Dinesh Rajput

Recent Posts

Strategy Design Patterns using Lambda

Strategy Design Patterns We can easily create a strategy design pattern using lambda. To implement…

4 years ago

Decorator Pattern using Lambda

Decorator Pattern A decorator pattern allows a user to add new functionality to an existing…

4 years ago

Delegating pattern using lambda

Delegating pattern In software engineering, the delegation pattern is an object-oriented design pattern that allows…

4 years ago

Spring Vs Django- Know The Difference Between The Two

Technology has emerged a lot in the last decade, and now we have artificial intelligence;…

4 years ago

TOP 20 MongoDB INTERVIEW QUESTIONS 2022

Managing a database is becoming increasingly complex now due to the vast amount of data…

4 years ago

Scheduler @Scheduled Annotation Spring Boot

Overview In this article, we will explore Spring Scheduler how we could use it by…

4 years ago