Created 07-01-2016 09:41 PM
I'm trying to work on sending a custom metric to the Ambari Metric collector. I've been following this extremely helpful blog. http://bryanbende.com/development/2015/07/31/ambari-metrics-part1-metrics-collector
Whenever I make a POST, however, I get a response 500 with this error:
"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."
Followed by a list of compatible readers.
Here's what I'm posting (except as a string with no whitespace) - it's pulled straight from the example here https://cwiki.apache.org/confluence/display/AMBARI/Metrics+Collector+API+Specification
{ "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 } } ] }
The url I'm pointing at is http://<metrics-collector-host>:6188/ws/v1/timeline/metrics/
A few things I've tried:
Thanks in advance!
James
Created 07-07-2016 11:20 PM
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"
Sending this as a header (I'm using python requests) fixed it. {'Content-Type': 'application/json'}
Created 07-02-2016 04:36 AM
Created 07-05-2016 04:51 PM
Hi @Sagar Shimpi,
Thanks so much for the response. Unfortunately neither of those posts hits the same problem I'm having.
The first article, the author is getting a 200 response from his POST requests, whereas I'm getting a 500.
With the second article, I'm trying to create a completely custom metric, not monitor something from an existing service.
Created 07-07-2016 11:20 PM
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"
Sending this as a header (I'm using python requests) fixed it. {'Content-Type': 'application/json'}