I have a spring boot application packaged into a war running on a port, now i want to attach a java agent to this application, to monitor the micro services using Prometheus. But without using any of the spring plugins to scrape the metrics from.
For which i found a way to run the java agent with the application by starting it as (jus packaged my app into jar for trial it worked perfectly)
java -javaagent <Path-to javaagent jar>:PORT -jar app.jar
this works fine if my project is packaged into jar, It started java-agent on PORT and my application on a different port and im able to get the metrics from java-agent.
but the actual issue is my application is packaged into a war.
Can we run a java-agent with a war file?
also, another thing i want to try is, Attach this agent jar to the jvm after application is started with maven, like any other spring boot application with "mvn spring-boot:run"
How can this be achieved?