Enabling Business Transaction Monitoring for a Spring Boot Application
The steps for deploying an eG Java BTM on a Spring Boot application will differ based on how that application is being monitored - in an agent-based manner or in an agentless manner.
BTM-Enabling a Spring Boot Application Monitored in an Agent-based Manner
If the target application is being monitored in an agent-based manner, then follow the steps below to BTM-enable it:
- Login to the system hosting the target application.
- Open a browser, connect to the eG manager, and login to the eG admin interface.
- Manage the Spring Boot application as a separate component using the eG administrative interface. When managing, make sure you leave the Agentless flag unchecked.
- If multiple application instances are operating on a single node, and you want to BTM-enable all the instances, then you will have to manage each instance as a separate component using the eG administrative interface.
-
Next, follow the Agents -> BTM Profiler Settings menu sequence in the eG admin interface. Figure 1 will then appear, listing the Java application servers managed in the environment. Locate the Spring Boot application that you managed recently in that list, and click the Copy JVM icon (
) corresponding to it (see Figure 1).
Figure 1 : Clicking the Copy JVM option corresponding to the Spring Boot application managed in an agent-based manner
-
Figure 2 will then appear. Copy the JVM option displayed in Figure 2 to the clip board or any text editor.
Figure 2 : Copying the JVM option displayed in the admin interface to a clip board or text editor
-
Then, using the same editor, edit the copied snippet to replace the placeholder <<EGURKHA_AGENT_HOME>> with the full path to the location of the eG agent.
For instance, if the eG agent is installed in /opt/egurkha (on a Unix system), then the code snippet will be as follows:
Copy-javaagent:opt/egurkha/lib/apm/Java/default/eg_btm.jar=component_guid=XXXXXXXXXXX-6639-4671-b978-653243b56e69Similarly, if the eG agent was installed in C:\eGurkha ( of a Windows system), then the code snippet will be as follows:
Copy-javaagent:C:\eGurkha\lib\apm\Java\default\eg_btm.jar=component_guid=XXXXXXXXXXX-6639-4671-b978-653243b56e69 -
Now, proceed to use the copied code snippet to BTM-enable the target application. This can be performed in one of the following ways:
-
By running the copied snippet from the command line;
-
By editing the startup script file of the target application to include the snippet;
-
By appending the code snippet to the systemd file of the target application
-
-
If you choose option (a), then, proceed as follows:
-
Open the Shell prompt (if the application is running on a Linux system) or the command prompt (if the application is running on a Windows system) on the application host, and issue a command of following format:
Copyjava -javaagent:<Paste_code_snippet_copied_to_clipboard> -jar <Springboot_app_name>.jar -
For instance, if the Spring Boot application being instrumented is called my-Spring Boot-app, then the command will be:
On Unix
Copyjava -javaagent:opt/egurkha/lib/apm/Java/default/eg_btm.jar=component_guid=XXXXXXXXXXXXXXXXXXXXXX-6639-4671-b978-653243b56e69 -jar my-springboot-app.jarOn Windows
Copyjava -javaagent:C:\eGurkha\lib\apm\Java\default\eg_btm.jar=component_guid=XXXXXXXXXXXXXXXXXXXX:2cdaf886-6639-4671-b978-653243b56e69 -jar my-springboot-app.jar -
Upon successful execution, this command will BTM-enable the target Spring Boot application.
-
Finally, restart the eG agent.
-
-
If you choose option (b) on the other hand, proceed as described below:
- Edit the start-up script of the target application.
-
Look for the export JAVA_TOOL_OPTIONS= specification in the file. Then, copy the code snippet from the clip board of step 7 above and append it to that specification. When doing so, make sure that you enclose the copied code snippet in double quotes, as shown below:
On Unix
Copyexport JAVA_TOOL_OPTIONS="-javaagent:opt/egurkha/lib/apm/Java/default/eg_btm.jar=component_guid=XXXXXXXXXXXXXXXX2cdaf886-6639-4671-b978-653243b56e69"On Windows
Copyexport JAVA_TOOL_OPTIONS="-javaagent:C:\eGurkha\lib\apm\Java\default\eg_btm.jar=component_guid=XXXXXXXXXXXXXXXXXXXX:2cdaf886-6639-4671-b978-653243b56e69" - Finally, save the file, and restart the target application and the eG agent.
-
Option (c) is applicable in environments where the target application runs as a system daemon. In this case, you will have to edit the systemd file of the application, as described below:
-
Look for the JAVA_OPTS= specification in the file.
-
Once the specification is found, copy the code snippet from the clipboard of step 7 and append it to the JAVA_OPTS= specification. When doing so, enclose the entire code snippet in double-quotes, as shown in the sample below:
On Unix
CopyJAVA_OPTS="-javaagent:opt/egurkha/lib/apm/Java/default/eg_btm.jar=component_guid=XXXXXXXXXXXXXXXXXX-6639-4671-b978-653243b56e69"On Windows
CopyJAVA_OPTS="-javaagent:C:\eGurkha\lib\apm\Java\default\eg_btm.jar=component_guid=XXXXXXXXXXXXXXXXXXXX:2cdaf886-6639-4671-b978-653243b56e69" -
Finally, save the file and restart the application and the eG agent.
-
- If multiple application instances on a single node are monitored, make sure you follow steps 5-11 for each instance.
BTM-Enabling a Spring Boot Application Monitored in an Agentless Manner
To achieve this, follow the steps below:
- Login to the system hosting the target Spring Boot application.
- Open a browser on the node, connect to the eG manager, and login to the eG admin interface.
- Manage the target application as a separate component using the eG administrative interface. When managing, make sure you enable the Agentless flag.
- If multiple instances of the target Sprintboot application are operating on a single node, and you want to BTM-enable all the instances, then you will have to manage each instance as a separate component using the eG administrative interface. When doing so, make a note of the Nick name and Port number using which you managed each instance.
- Next, log out of the eG admin interface. Then, create a btm directory anywhere on the application host- say, C:\btm (if the target application is operating on a Windows system), or /opt/btm (if the target application is operating on a Unix system). Under this directory, create a sub-folder. Make sure that you name this sub-folder in the following format: <Managed_Component_NickName>_<Managed_Component_Port>. For instance, if you have managed the target application using the nick name AppServer1 and the port number 8088, the new directory under the btm directory should be named as AppServer1_8088.
-
If you have managed multiple application instances running on a single node, then you will have to create multiple sub-directories under the btm directory- one each for every instance. Each of these sub-directories should be named after the Nick name and Port number using which the corresponding instance has been managed in eG.
- Once the new sub-directory(ies) is created, open a browser on the application host, connect to the eG manager, and login to the eG admin interface again.
- Follow the Agents -> BTM Profiler Settings menu sequence in the eG admin interface.
-
Figure 3 will appear listing the servers that can be instrumented for APM by eG. In this list, locate the Spring Boot application that you want to BTM-enable. Once you locate it, click the Download icon corresponding to it to download the APM Profiler Agent to that application host. If multiple application instances on a single node are managed, then you will have to download the APM Profiler Agent separately for each of the managed instances.
Figure 3 : Downloading the APM Profiler Agent for the Spring Boot application
- Upon clicking the Download icon in Figure 3, a zip file named javaagent_<Nick_name_of_Managed_Application>_<Port_number_of_Managed_Application will get downloaded. For instance, if you have managed the target application using the nickname 'AppServer1' and the port number '8088', then the name of the zip file will be javaagent_AppServer1_8088. Where multiple application instances have been managed, you will be downloading multiple zip files - one each for every instance. The names of these zip files will automatically carry the nick name and port number you assigned to the corresponding application instance.
- Copy the downloaded zip file(s) to the corresponding sub-directory(ies) of the btm directory (see step 6 above). For example, the zip file named javaagent_AppServer1_8088, should be copied to the C:\btm\AppServer1_8088 directory (on Windows) or /opt/btm/AppServer1_8088 (on Unix).
- Extract the contents of each zip file into the same sub-directory to which that zip file was copied.
-
Figure 4 depicts the extracted contents of the zip file.
- From Figure 4, it is evident that the zip file contains an eg_btm.jar file.
-
Next, proceed to BTM-enable the target application/instance. This can be performed in one of the following ways:
-
By running a command from the command line;
-
By editing the startup script file of the target application;
-
By editing the systemd file of the target application
-
-
If you choose option (a), then, proceed as follows:
-
Open the Shell prompt (if the application is running on a Linux system) or the command prompt (if the application is running on a Windows system) on the application host, and issue a command of following format:
Copyjava -javaagent:<Path_to_eg_btm.jar> -jar <Springboot_app_name>.jar -
For instance, say that the Spring Boot application being instrumented is called my-Spring Boot-app, and that the eg_btm.jar resides in the btm/AppServer1_8088 folder in the root. In this case, the command will be:
On Unix
Copyjava -javaagent:opt/btm/AppServer1_8088/eg_btm.jar -jar my-springboot-app.jarOn Windows
Copyjava -javaagent:C:\btm\AppServer1_8088\eg_btm.jar -jar my-springboot-app.jar -
Upon successful execution, this command will BTM-enable the target Spring Boot application.
-
Finally, restart the eG agent.
-
-
If you choose option (b) on the other hand, proceed as described below:
- Edit the start-up script of the target application.
-
Look for the export JAVA_TOOL_OPTIONS= parameter in the file. Then, configure that parameter with the the full path to the eg_btm.jar file. When doing so, make sure that you enclose the path specification in double quotes. Sample specifications have been provided below:
On Unix
Copyexport JAVA_TOOL_OPTIONS="-javaagent:opt/btm/AppServer1_8088/eg_btm.jar"On Windows
Copyexport JAVA_TOOL_OPTIONS="-javaagent:C:\btm\AppServer1_8088\eg_btm.jar" -
Finally, save the file, and restart the target application and the eG agent.
-
Option (c) is applicable in environments where the target application runs as a system daemon. In this case, you will have to edit the systemd file of the application, as described below:
-
Look for the JAVA_OPTS= specification in the file.
-
Once the specification is found, configure the JAVA_OPTS= specification with the full path to the eg_btm.jar file. When doing so, enclose the entire path specification in double-quotes. Some sample specifications are provided below:
On Unix
CopyJAVA_OPTS="-javaagent:opt/btm/AppServer1_8088/eg_btm.jar"On Windows
CopyJAVA_OPTS="-javaagent:C:\btm\AppServer1_8088\eg_btm.jar" -
Finally, save the file and restart the application and the eG agent.
-