'Get metrics at a given point of my tomcat

I need hints to fix this or any others suggestions to get metrics at a given point from tomcat server evolving in a docker container. here is my current context/progress :

Im using Rancher to do a load test every days thanks to Gatling, my web app, my db and a tomcat server.

Currently i collect datas with a little script who start the Gatling mission and send a mail at the end with some interresting metrics and the results zipped.

And now i want to complete my datas with metrics from the tomcat server. I know that i don't have access to kubernetes from my script. So i found a solution : get these metrics from JMX.

I tried to add on my deployment.yaml these params without results :

spec:
  template:
    spec:
      containers:
        - image: {{ .Values.docker.repo }}/{{ .Values.docker.image }}
          env:
            - name: CATALINA_OPTS
              value: '-Dcom.sun.management.jmxremote=true
                      -Dcom.sun.management.jmxremote.port=myport
                      -Dcom.sun.management.jmxremote.rmi.port=myport
                      -Dcom.sun.management.jmxremote.ssl=false
                      -Dcom.sun.management.jmxremote.authenticate=false
                      -Dcom.sun.management.jmxremote.local.only=false
                      -Djava.rmi.server.hostname=my.url'

And for a second try, at the end of my dockerfile :

[...]

CMD ["java",
"-Dsx.home=/usr/local/sx",
"-Dlog4j.directory=/usr/local/app/logs",
"-Dsx.groupid=tenant1",
"-Dtomcat.webapp.lib=/route/to/app;/route/to/libs",
"-Dtomcat.webapp.config=/route/to/config.properties",
"-Dtomcat.https.port=myport",
"-Dtomcat.https.keystorePass=pass",
"-Dtomcat.https.keystoreFile=/route/to/the/.keystore",
"-Dcom.sun.management.jmxremote=true",
"-Dcom.sun.management.jmxremote.port=anotherport",
"-Dcom.sun.management.jmxremote.ssl=false",
"-Dcom.sun.management.jmxremote.authenticate=false",
"-Dcom.sun.management.jmxremote.local.only=true",
"-Djava.rmi.server.hostname=ipserver",
"-Dcom.sun.management.jmxremote.rmi.port=anotherport",
"-jar", "sx-tomcat.jar", "config.properties"]

for both when I'm trying to connect on the JConsole with ipserver:anotherport, I still have this issue :

Connection failed: non-JRMP server at remote endpoint

https://i.stack.imgur.com/eQauX.png

JMX looks like disabled

What am I wrong here ? this is my 2nd day on this problem, i feel like i'm going to go crazy soon



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source