Actuator - Manage and Monitor JMX endpoint with JConsole, Jolokia | Spring Boot Recipes #4 | 2021

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello and welcome to tech guinness my name is chandra and i am a technology explorer this video is part of spring boot recipes and today we will see jmx endpoints exposed using actuators let's start here is a quick recap of actuators you can watch my previous video to know more about actuators in detail we can add production grade features to the spring boot app by adding actuator dependency here you can see the dependency which we need to add so actuator endpoints are exposed over http and jmx by default only health and info endpoints are available on http and rest others on jmx so we can monitor as well as manage the spring boot application over jmx by default jmx endpoints are not enabled so in case our requirement is to use the jmx ambience we need to enable the jmx exposure by setting the spring.jmi as true in the application by default springboot expose the domain.org.springframework.boot we'll see this in the demo first we will see how we can make use of j console to monitor and manage the actuator jmx ambience now you must be thinking what is j console right let me tell you j console is a jmx compliant monitoring and management tool this is available out of the box with the jdk so no need of downloading any other software j console provides a minimal gui that helps in monitoring the java application let's see j console in action so this is the setup which we have used in our last video here we'll go to the application.properties and these are the old properties which we have defined in the last video now in current video we need to enable the jmx endpoint so how we can do it by making this property as true so now let's start the application the application is started let's go to actuator actuators are working fine yeah it is up and running and we can check the health as well okay now to check jconsole what we need to do we just need to go to command prompt right and if your java path is set correctly and if you write jconsole you are good to go yes so we can see java monitoring and management console this is j console and in a new connection you can see there are two options coming local process or remote process so local process is the processes which are running on my local system and to monitor the remote processes which we can use this option where we need to just provide the hostname colon port and username password so it will be connected to that process we'll go with the local process here and we can see this is my process hello springboot actuator just double click here it will say that it is a insecure connection so we can go ahead yeah let me maximize this okay so you can see that using this out of the box tool we can check the heap memory usage what are the number of threads classes loaded then cpu usage okay but for today's video we'll directly go to ambience over here and these are the ambience which are exposed and our interest is in the org dot spring framework dot boot okay so here we can see end point and these are the end points available so we just checked health in the web endpoint okay let's see from here if we go to health operations health so you need to click on health here and you can see the output okay so it is not very much readable but we can say status up component this let's see few more for example if you want to check info we can go here info click here just copy it okay we can okay so we can see app equal to encoding is utf-8 java source is 11 target is 11 and name is spring boot actuator okay so other than this we can check like we can get the environment details right we have seen the custom endpoint as well which we have built in our last video okay and here we have the beans as well so to check what all beans are there we can see this and restaurant okay so here is the list of all the beans that are available now to check the logs we can go here loggers and this is the loggers so you can see the log levels of each component right these are the levels which are off error one in four debug and trace so root logger is info effective level info and similarly for that for a spring boot hello spring boot it is info now this was all about monitoring right how we are monitoring the ambience okay but we can manage as well i have given logging.level.com.tagginess.hello boot dot hello as info okay so i've cleared it let's go to postman and i will hit this end point this is one log and this is error log okay because we have set the log level as info now if you want to switch off right so what we need to do we need to say com dot tagginess dot hello spring boot and value i will give it as off so without touching the code so if everything is fine it will written null okay and again we will go to the application clear all okay and we will hit the end point once again so there is no logs now coming because it has switch off the locks so this is how we can manage and monitor jmx and means using the j console so now let's see how we can manage jmx over jolokia so another way to access jmx bin is to use zolokia so what exactly is zolokia it is a jmx http bridge that provides an alternative method of accessing jmx means so what you need to do is just add a dependency zolokiya core and spring boot will handle automatically using the auto configuration after this only one step that remains is to expose the jolokia endpoint on the web by using the property web exposure include after this we can access the end points using slash actuator slash zoology let's see jolokia in action so coming back to the code we need to add the zolokaya core dependency here you can see i have already added okay and then we need to go to the application dot properties and add zolokia in web exposure ok so once you have added it you just need to refresh the application so here we can see the actuator point let's refresh it and we can see there jolokia endpoint if you click here you can see all the properties so if you are getting this response that means your xolokia endpoint is working right here you can see agent is 1.6.2 protocol 7.2 listen for http service true okay now how to read the jmx being exposed by actuators okay so for this what you need to do just go to the next step slash we need to execute and the domain is org dot spring framework dot boot then we need to give the type type equal to endpoint and name equal to health and in the health we need to get the health operation yeah so we can see the jolokia response is having these components where first one is the request request it will say that this is the ambien which is requested type is execution and operation is health and value is the response okay so we can see it is now listing the disk space then ping status liveness state readiness state so this is how we will get the response okay now suppose i want to get the info so i can use name equal to info and operation is info we got the value right so be careful that name is case sensitive ok yeah so this is how we can use zolokia endpoints here we come to the end of this video thanks for watching source code can be found in my github repository if you like the content please share it with your friends please subscribe the channel to get latest videos keep exploring thanks
Info
Channel: Tekgainers
Views: 490
Rating: undefined out of 5
Keywords: Spring Boot, Boot, Spring, SpringBoot, Tekgainers, JMX, JConsole, Jolokia, Actuator
Id: XI5EzDD56j0
Channel Id: undefined
Length: 10min 19sec (619 seconds)
Published: Wed May 12 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.