Prometheus unable to scrape from tomcat container

65 views
Skip to first unread message

sarbajit das

unread,
Nov 19, 2021, 11:14:27 AM11/19/21
to Prometheus Users
Hi All,
I trying to deploy a small application in a tomcat docker container and trying to monitor the container using Prometheus with the help of node exporter. But I am unable scrape metrics even though metrics is actually being pulled. Below is my Dockerfile :

FROM jatayu99/my-tomcat:latest
ADD prometheus-jmx-config.yml /prometheus-jmx-config.yml
ADD jmx_prometheus_javaagent-0.13.0.jar /jmx_prometheus_javaagent-0.13.0.jar
COPY ConferenceRoomCapstoneB35.war /usr/local/tomcat/webapps
ENV JAVA_OPTS="$JAVA_OPTS -javaagent:/jmx_prometheus_javaagent-0.13.0.jar=9830:/prometheus-jmx-config.yml"
EXPOSE 9830 8080

sarbajit@UBUNTU:~/expr/proj-ansi-roles$ cat roles/03-build-image/files/prometheus-jmx-config.yml
ssl: false
lowercaseOutputName: false
lowercaseOutputLabelNames: false

But if I try to use port 8080 for jmx_prometheus_javaagent-0.13.0.jar then prometheus is able to pull the metrics but my application is not running in that scenario.

Can anyone please help regarding this problem ??

Thanks & Regards,
Sarbajit Das

Matthias Rampke

unread,
Nov 21, 2021, 11:21:35 AM11/21/21
to sarbajit das, Prometheus Users
I think something is going wrong with the port mapping here. If I am reading the Dockerfile reference correctly, to expose multiple ports use multiple EXPOSE lines, like

EXPOSE 8080
EXPOSE 9830

Additionally, you need to still use the -p or -P flags on docker run to really expose the ports. Try being very explicit about all the ports:

docker run -p 8080:8080 -p 9830:9830 …

Then see if you can curl both ports.

/MR

--
You received this message because you are subscribed to the Google Groups "Prometheus Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to prometheus-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/prometheus-users/1cd4fa8e-905f-4239-9ad4-4777b7615001n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages