- Subscribe to RSS Feed
- Mark Question as New
- Mark Question as Read
- Float this Question for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
Sending custom Ambari Metrics gives response 500
- Labels:
-
Apache Ambari
Created ‎07-01-2016 09:41 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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:
- 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.
- Restarting Ambari Metrics
- Having Ambari Metrics run it's service check, which, from what I can tell, posts and gets a dummy metric. It worked fine.
- Doing a GET request. Get requests are successful and do return the requested metrics.
- Sending the POST from my local machine, the primary VM, and the VM that the metrics collector lives on.
- 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)
Thanks in advance!
James
Created ‎07-07-2016 11:20 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Created ‎07-05-2016 04:51 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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'}
