Run inside program (java -javaagent:./jmx_prometheus_javaagent-0.13.0.jar=9090:config.yaml -jar Main.jar)

8 views
Skip to first unread message

Ashish Singh

unread,
Sep 11, 2020, 5:43:23 AM9/11/20
to Prometheus Users

java -javaagent:./jmx_prometheus_javaagent-0.13.0.jar=9090:config.yaml -jar Main.jar

How can I do it from a program.

I tried these. no luck!!

try{ String nameOfRunningVM = ManagementFactory.getRuntimeMXBean().getName(); String pid = nameOfRunningVM.substring(0, nameOfRunningVM.indexOf('@')); VirtualMachine vm = VirtualMachine.attach(pid); vm.loadAgent("/Users/zop2816/Downloads/jmx_prometheus_javaagent-0.13.0.jar=9090:/Users/zop2816/Downloads/example.java.helloworld-master/config.yaml", null); vm.detach(); }catch (Exception e) { Exception o = e; e.printStackTrace(); }

Please help. TIA.

Reply all
Reply to author
Forward
0 new messages