title: Monitor the Jetty-based Java application using Prometheus and Grafana
body: <p>I have deployed a Java application in the server (in 8091) using <code>nohup</code> and Jetty.</p>
  <p>I need to monitor that application using Prometheus and Grafana.</p>
  <p>So downloaded the JMX exporter.</p>
  <p>Need to get all the available metrics (JMX exporter) for that application monitoring.</p>
  <p>Downloaded the below jar file:</p>
  <pre><code> https://repo1.maven.org/maven2/io/prometheus/jmx/jmx_prometheus_javaagent/0.1.0/jmx_prometheus_javaagent-0.1.0.jar
  </code></pre>
  <p>Config.yaml</p>
  <pre><code>[root@localhost software]# cat config.yaml
  ---
  startDelaySeconds: 0
  hostPort: 127.0.0.1:7101
  jmxUrl: service:jmx:rmi:///jndi/rmi://127.0.0.1:7101/jmxrmi
  ssl: false
  lowercaseOutputName: true
  lowercaseOutputLabelNames: true
  rules:
  - pattern: &quot;.*&quot;
  </code></pre>
  <p>The deployment command which I used for usual deployment: (in this directory, Jetty was present)</p>
  <pre><code>nohup  -Dorg.eclipse.jetty.server.Request.maxFormContentSize=10000000 -Xms256m -Xmx256m -Djava.io.tmpdir=temp_dir -jar jetty-runner-9.0.7.v20131107.jar --log yyyy_mm_dd-java-application-1-request.log --out yyyy_mm_dd-java-application-1-output.log --port 8091 --path /java-application-1 hotfix.war &gt;&gt; java-application-1.log 2&gt;&amp;1 &amp;
  </code></pre>
  <p>it works fine ..</p>
  <p>When I tried to monitor the application with JMX exporter, I used the below command:</p>
  <pre><code>nohup java -javaagent:./jmx_prometheus_javaagent-0.1.0.jar=7101:config.yaml -Dorg.eclipse.jetty.server.Request.maxFormContentSize=10000000 -Xms256m -Xmx256m -Djava.io.tmpdir=epoch_temp_dir -jar jetty-runner-9.0.7.v20131107.jar --log yyyy_mm_dd-java-application-1-request.log --out yyyy_mm_dd-java-application-1-output.log --port 8091 --path /java-application-1 hotfix.war &gt;&gt; java-application-1.log 2&gt;&amp;1 &amp;
  </code></pre>
  <blockquote>
  <p>it reports as  :  [1]+  Aborted                 (core dumped) nohup
  java -javaagent:./jmx_prometheus_javaagent-0.1.0.jar=7101:config.yaml
  -Dorg.eclipse.jetty.server.Request.maxFormContentSize=10000000 -Xms256m -Xmx256m -Djava.io.tmpdir=epoch_temp_dir -jar jetty-runner-9.0.7.v20131107.jar --log
  yyyy_mm_dd-java-application-1-request.log --out
  yyyy_mm_dd-java-application-1-output.log --port 8091 --path
  /java-application-1 hotfix.war &gt;&gt; java-application-1.log 2&gt;&amp;1</p>
  </blockquote>
  <p>In log file  :
  It reports as :</p>
  <pre><code>nohup: ignoring input
  Exception in thread &quot;main&quot; java.lang.reflect.InvocationTargetException
          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
          at java.lang.reflect.Method.invoke(Method.java:498)
          at sun.instrument.InstrumentationImpl.loadClassAndStartAgent(InstrumentationImpl.java:386)
          at sun.instrument.InstrumentationImpl.loadClassAndCallPremain(InstrumentationImpl.java:401)
  Caused by: java.lang.IllegalArgumentException: At most one of hostPort and jmxUrl must be provided
          at io.prometheus.jmx.shaded.io.prometheus.jmx.JmxCollector.loadConfig(JmxCollector.java:120)
          at io.prometheus.jmx.shaded.io.prometheus.jmx.JmxCollector.&lt;init&gt;(JmxCollector.java:74)
          at io.prometheus.jmx.shaded.io.prometheus.jmx.JavaAgent.premain(JavaAgent.java:36)
          ... 6 more
  FATAL ERROR in native method: processing of -javaagent failed
  </code></pre>
  <p>I m not sure whether the <code>config.yaml</code> and the command which I used for monitoring the deployed Java application was correct.</p>
  <p>How to monitor this Jetty-based java application using Prometheus and Grafana?</p>