title: get jmx attributes with jolokia telegraf
body: <p>I have a JAVA application which I want to monitor its JMX attributes using <a href="https://github.com/influxdata/telegraf" rel="nofollow noreferrer"><code>telegraf</code></a> tool. </p>
  
  <p>The tool provides <code>jolikia</code> plugin to monitor JMX attributes. I have added following dependencies to my app's <code>pom.xml</code> file regarding <code>Maven</code> section of <a href="https://jolokia.org/download.html" rel="nofollow noreferrer">Jolokia documentation</a>:</p>
  
  <pre><code>&lt;dependency&gt;
      &lt;groupId&gt;org.jolokia&lt;/groupId&gt;
      &lt;artifactId&gt;jolokia-core&lt;/artifactId&gt;
      &lt;version&gt;1.3.7&lt;/version&gt;
  &lt;/dependency&gt;
  &lt;dependency&gt;
      &lt;groupId&gt;org.jolokia&lt;/groupId&gt;
      &lt;artifactId&gt;jolokia-client-java&lt;/artifactId&gt;
      &lt;version&gt;1.3.7&lt;/version&gt;
  &lt;/dependency&gt;
  </code></pre>
  
  <p>This is my <code>/etc/telegraf/telegraf.conf</code> file:</p>
  
  <pre><code>[[inputs.jolokia]]
  
     context = "/jolokia/"
     [[inputs.jolokia.servers]]
         name = "wr-core"
         host = "192.168.100.175"
         port = "1998"
  
     [[inputs.jolokia.metrics]]
         name = "send_success"
         mbean  = "wr-core:type=monitor,name=execution"
         attribute = "MessageSendSuccessCount"
  </code></pre>
  
  <p>The application is up in the provided IP/port (I can connect to it with <code>jconsole</code>). The application has a monitoring section which its object name (as shown in <code>jconsole</code>) is <code>wr-core:type=monitor,name=execution</code> and has the attribute <code>MessageSendSuccessCount</code>. But when I start <code>telegraf</code> service, following error occurs:</p>
  
  <pre><code>Jan 14 14:30:32 ZiZi telegraf[17258]: 2018-01-14T11:00:32Z E! Error in plugin [inputs.jolokia]: error performing request: Error decoding JSON response: invalid character '\x00' looking for beginning of value:
  </code></pre>
  
  <p>Note that <code>1998</code> is my app's jmx port. I also tried using <code>8778</code> which is <code>jolokia-agent</code> port; got:</p>
  
  <pre><code>Jan 14 14:40:03 ZiZi telegraf[9150]: 2018-01-14T11:10:03Z E! Error in plugin [inputs.jolokia]: error performing request: Post http://192.168.100.175:8778/jolokia/: dial tcp 192.168.100.175:8778: getsockopt: connection refused
  </code></pre>
  
  <p><strong>EDIT 1:</strong></p>
  
  <p>I have checked my <code>CLASSPATH</code> and both <code>jolokia-client</code> and <code>jolokia-core</code> were listed: <code>../lib/jolokia-client-java-1.3.7.jar:../lib/jolokia-core-1.3.7.jar</code>.</p>
  
  <p><strong>EDIT 2:</strong></p>
  
  <p>I have put following lines into my app's execution file:</p>
  
  <pre><code>JOLOKIA_OPTS=-javaagent:$LIB_PATH/jolokia-core-java-1.3.7.jar=port=8778,host=0.0.0.0
  
  JAVA_OPTS="-mx4096M $JAVA_OPTS $JACOCO_OPTS $JOLOKIA_OPTS"
  </code></pre>
  
  <p>But when I run the file, I get this error (even though <code>../lib/jolokia-core-java-1.3.7.jar</code> has been listed in the <code>CLASSPATH</code>):</p>
  
  <pre><code>Error opening zip file or JAR manifest missing : ../lib/jolokia-core-java-1.3.7.jar
  Error occurred during initialization of VM
  agent library failed to init: instrument
  </code></pre>