<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>question Re: Sending custom Ambari Metrics gives response 500 in Support Questions</title>
    <link>https://community.cloudera.com/t5/Support-Questions/Sending-custom-Ambari-Metrics-gives-response-500/m-p/109292#M72142</link>
    <description>&lt;P&gt;It ended up being a problem with the way I was posting the JSON. I wasn't specifying in the header that it was a JSON file, so the server assumed it was type "application/x-www-form-urlencoded" rather than "application/json"&lt;/P&gt;&lt;P&gt;Sending this as a header (I'm using python requests) fixed it. {'Content-Type': 'application/json'}&lt;/P&gt;</description>
    <pubDate>Fri, 08 Jul 2016 06:20:40 GMT</pubDate>
    <dc:creator>jgaskin</dc:creator>
    <dc:date>2016-07-08T06:20:40Z</dc:date>
    <item>
      <title>Sending custom Ambari Metrics gives response 500</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Sending-custom-Ambari-Metrics-gives-response-500/m-p/109289#M72139</link>
      <description>&lt;P&gt;I'm trying to work on sending a custom metric to the Ambari Metric collector. I've been following this extremely helpful blog. &lt;A href="http://bryanbende.com/development/2015/07/31/ambari-metrics-part1-metrics-collector" target="_blank"&gt;http://bryanbende.com/development/2015/07/31/ambari-metrics-part1-metrics-collector&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Whenever I make a POST, however, I get a response 500 with this error:&lt;/P&gt;&lt;PRE&gt;"com.sun.jersey.api.MessageException: A message body reader for Java class org.apache.hadoop.metrics2.sink.timeline.TimelineMetrics, and Java type class org.apache.hadoop.metrics2.sink.timeline.TimelineMetrics, and MIME media type application/octet-stream was not found."
&lt;/PRE&gt;&lt;P&gt;Followed by a list of compatible readers.&lt;/P&gt;&lt;P&gt;Here's what I'm posting (except as a string with no whitespace) - it's pulled straight from the example here &lt;A href="https://cwiki.apache.org/confluence/display/AMBARI/Metrics+Collector+API+Specification" target="_blank"&gt;https://cwiki.apache.org/confluence/display/AMBARI/Metrics+Collector+API+Specification&lt;/A&gt;&lt;/P&gt;&lt;PRE&gt;{
  "metrics": [
    {
      "metricname": "AMBARI_METRICS.SmokeTest.FakeMetric",
      "appid": "amssmoketestfake",
      "hostname": "ambari20-5.c.pramod-thangali.internal",
      "timestamp": 1432075898000,
      "starttime": 1432075898000,
      "metrics": {
        "1432075898000": 0.963781711428,
        "1432075899000": 1432075898000
      }
    }
  ]
}&lt;/PRE&gt;&lt;P&gt;The url I'm pointing at is &lt;A href="http://&amp;lt;metrics-collector-host&amp;gt;:6188/ws/v1/timeline/metrics/" target="_blank"&gt;http://&amp;lt;metrics-collector-host&amp;gt;:6188/ws/v1/timeline/metrics/&lt;/A&gt;&lt;/P&gt;&lt;P&gt;A few things I've tried:&lt;/P&gt;&lt;UL&gt;
&lt;LI&gt;POSTing to both on the cluster I made from VMs to experiment with and with the official Hortonworks sandbox (as suggested in Bryan's tutorial - making sure port forwarding is set up). Neither works.&lt;/LI&gt;&lt;LI&gt;Restarting Ambari Metrics&lt;/LI&gt;&lt;LI&gt;Having Ambari Metrics run it's service check, which, from what I can tell, posts and gets a dummy metric. It worked fine.&lt;/LI&gt;&lt;LI&gt;Doing a GET request. Get requests are successful and do return the requested metrics.&lt;/LI&gt;&lt;LI&gt;Sending the POST from my local machine, the primary VM, and the VM that the metrics collector lives on.&lt;/LI&gt;&lt;LI&gt;Editing the "hostname" field in the json doc to match what machine I'm sending from (though that seems as though it shouldn't matter)&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;Thanks in advance!&lt;/P&gt;&lt;P&gt;James&lt;/P&gt;</description>
      <pubDate>Sat, 02 Jul 2016 04:41:53 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Sending-custom-Ambari-Metrics-gives-response-500/m-p/109289#M72139</guid>
      <dc:creator>jgaskin</dc:creator>
      <dc:date>2016-07-02T04:41:53Z</dc:date>
    </item>
    <item>
      <title>Re: Sending custom Ambari Metrics gives response 500</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Sending-custom-Ambari-Metrics-gives-response-500/m-p/109290#M72140</link>
      <description>&lt;P&gt;&lt;A rel="user" href="https://community.cloudera.com/users/11580/jgaskin.html" nodeid="11580"&gt;@James Gaskin&lt;/A&gt; Can you check if this helps -&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.hortonworks.com/questions/25042/custom-metric-names-in-ambari-metrics.html" target="_blank"&gt;https://community.hortonworks.com/questions/25042/custom-metric-names-in-ambari-metrics.html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.hortonworks.com/questions/31192/how-to-add-custom-kafka-metrics-via-ambari-metrics.html" target="_blank"&gt;https://community.hortonworks.com/questions/31192/how-to-add-custom-kafka-metrics-via-ambari-metrics.html&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 02 Jul 2016 11:36:50 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Sending-custom-Ambari-Metrics-gives-response-500/m-p/109290#M72140</guid>
      <dc:creator>sshimpi</dc:creator>
      <dc:date>2016-07-02T11:36:50Z</dc:date>
    </item>
    <item>
      <title>Re: Sending custom Ambari Metrics gives response 500</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Sending-custom-Ambari-Metrics-gives-response-500/m-p/109291#M72141</link>
      <description>&lt;P&gt;Hi &lt;A rel="user" href="https://community.cloudera.com/users/2648/sshimpi.html" nodeid="2648"&gt;@Sagar Shimpi&lt;/A&gt;,&lt;/P&gt;&lt;P&gt;Thanks so much for the response. Unfortunately neither of those posts hits the same problem I'm having.&lt;/P&gt;&lt;P&gt;The first article, the author is getting a 200 response from his POST requests, whereas I'm getting a 500.&lt;/P&gt;&lt;P&gt;With the second article, I'm trying to create a completely custom metric, not monitor something from an existing service.&lt;/P&gt;</description>
      <pubDate>Tue, 05 Jul 2016 23:51:33 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Sending-custom-Ambari-Metrics-gives-response-500/m-p/109291#M72141</guid>
      <dc:creator>jgaskin</dc:creator>
      <dc:date>2016-07-05T23:51:33Z</dc:date>
    </item>
    <item>
      <title>Re: Sending custom Ambari Metrics gives response 500</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Sending-custom-Ambari-Metrics-gives-response-500/m-p/109292#M72142</link>
      <description>&lt;P&gt;It ended up being a problem with the way I was posting the JSON. I wasn't specifying in the header that it was a JSON file, so the server assumed it was type "application/x-www-form-urlencoded" rather than "application/json"&lt;/P&gt;&lt;P&gt;Sending this as a header (I'm using python requests) fixed it. {'Content-Type': 'application/json'}&lt;/P&gt;</description>
      <pubDate>Fri, 08 Jul 2016 06:20:40 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Sending-custom-Ambari-Metrics-gives-response-500/m-p/109292#M72142</guid>
      <dc:creator>jgaskin</dc:creator>
      <dc:date>2016-07-08T06:20:40Z</dc:date>
    </item>
  </channel>
</rss>

