Monitoring Tomcat App with JMX Exporter

5,220 views
Skip to first unread message

mr-m...@wiu.edu

unread,
Jun 6, 2017, 3:51:29 PM6/6/17
to Prometheus Developers
I'm not figuring this out for some reason. I've got an app from a vendor that runs in Tomcat and I'd like to monitor the jmx stats.

I've added the JMX entries to the catalina.sh file and JMX is listening on 127.0.0.1:9000.

I downloaded the jar file and the tomcat.yml config example from the JMX exporter project, and added the hostPort entry to tomcat.yml.
`hostPort: 127.0.0.1:9000`

I've attempted to run it like so:
java -javaagent:./jmx_prometheus_javaagent-0.9.jar=1234:tomcat.yml

...it takes a few seconds and then just returns this and then the rest of the java usage info...

2017-06-06 14:30:49.429:INFO:ipjsoejs.Server:jetty-8.y.z-SNAPSHOT
2017-06-06 14:30:49.532:INFO:ipjsoejs.AbstractConnector:Started SelectChann...@0.0.0.0:1234
Usage: java [-options] class [args...]
.....

The README indicates I need a -jar somefile.jar on the end of that command, but I'm not sure what needs to go there. The vendor's war file?

Thanks,
Matt

Ke Sai

unread,
Jun 7, 2017, 6:58:28 PM6/7/17
to Prometheus Developers
I think you only need to use the agent.jar. How I got it to work is place the jmx_prom.jar in tomcat's lib dir, and include "-javaagent:./jmx_prometheus_javaagent-0.9.jar=1234:config.yaml" in my tomcat start script, then add a scraper to prometheus.yml config.

Ke Sai

unread,
Jun 7, 2017, 6:59:11 PM6/7/17
to Prometheus Developers
If you have an tomcat start script, try putting "-javaagent:./jmx_prometheus_javaagent-0.9.jar=1234:config.yaml" into CATALINA_OPTS 


On Tuesday, June 6, 2017 at 3:51:29 PM UTC-4, Matt Mencel wrote:

Matt Mencel

unread,
Jun 8, 2017, 9:51:40 AM6/8/17
to Prometheus Developers
Thanks!  I actually got it working yesterday with the the jmx_prometheus_httpserver, but your solution is much cleaner so I've gone with this one.

Thanks again!

Matt Mencel

unread,
Jun 8, 2017, 10:24:27 AM6/8/17
to Prometheus Developers
Interesting...  when I switched to the javaagent way of doing it, I lost all the Catalina metrics.  My config.yaml looks like this...

---
hostPort: localhost:5555
username: 
password: 

rules:
- pattern: ".*"

So I'm collecting everything.  But yesterday when I was using the httpserver way I got hundreds of metrics from the Catalina namespace and now I get none.

Matt

Brian Brazil

unread,
Jun 8, 2017, 10:41:59 AM6/8/17
to Matt Mencel, Prometheus Developers
On 8 June 2017 at 15:24, Matt Mencel <mr-m...@wiu.edu> wrote:
Interesting...  when I switched to the javaagent way of doing it, I lost all the Catalina metrics.  My config.yaml looks like this...

---
hostPort: localhost:5555
username: 
password: 

Remove these lines, they're not required for the java agent.

Brian
 

--
You received this message because you are subscribed to the Google Groups "Prometheus Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to prometheus-developers+unsub...@googlegroups.com.
To post to this group, send email to prometheus-developers@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/prometheus-developers/9d230c13-5d28-4115-a91b-062635e07da3%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--

tangc...@gmail.com

unread,
Aug 30, 2017, 3:06:24 PM8/30/17
to Prometheus Developers
Hi,thanks for shining here. where do you put config.yaml file? thanks
Message has been deleted
Message has been deleted

ashis...@gmail.com

unread,
Mar 14, 2019, 6:52:08 AM3/14/19
to Prometheus Developers
Hi All,

I am facing issue during configure the jmx exporter .
Could you please help me to configure.

Which entry i need to put in catalina.sh

I am folloing this blog by which i need to add jvm parameter in java application.
but i am unable to find location.

Please suggest.

Reply all
Reply to author
Forward
0 new messages