Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

Custom metric names in Ambari-Metrics

Highlighted

Custom metric names in Ambari-Metrics

New Contributor

Metrics are working in my Ambari installation, it looks like all my hosts are sending information correctly to the ambari-metrics server. Everything looks great when I pull up my Ambari dashboard. I'm interested, however, in sending over custom metrics data on every node, particularly from a JSON file from a program I'm using. I haven't had much luck, and would love some advice.

I've read and found that each host is supposed to send a POST request to the Metrics Collector, and found a guide on that on the Ambari Collector API specification page. However, when I try to execute the requests shown on the page (using Postman), I do not get a valid response.

I am first sending a POST request identical to what's on the page, except I have replaced the hostname with my server's correct hostname. I get a 200 empty-XML response from that request. After, I send a GET request again identical to the page's request, except with my hostname. The response is a JSON object containing a single array, "metrics", which is empty.

Is this the correct approach? Obviously, something I'm doing is wrong, but I'm not sure what. Should I be executing a name/appid that actually exist? I'm interested in making a corresponding View with this information, should I make that and fill in that information? What's the format for the "metricname" property? Is there a way I can quickly query the metrics collector or server to test inputting values and finding my test values, like in a database fashion?

4 REPLIES 4
Highlighted

Re: Custom metric names in Ambari-Metrics

Expert Contributor

@Austin Lasher

When you POST metrics, the appId and hostname will be your "keys" to lookup.

You can request the metrics you posted with query params - appId, hostname, startTime and endTime.

Can you share your POST and GET calls? If the payload JSON is large, you can share a part of it.

Highlighted

Re: Custom metric names in Ambari-Metrics

New Contributor

Hello Aravindan, thanks for looking into my issue.

Here's a sample POST request I'm making:

{
    "metrics": [{
          "metricname": "BDMTMetric",
          "appid": "bdmtfaketest",
          "hostname": "<correct-internal-hostname>",
          "timestamp": 1459379402573,
          "starttime": 1459379402573,
          "metrics": {
            "1459379402573": 206
          }
    }]
}

I'm sending that to the collector service, "http://<correct-dns>:6188/ws/v1/timeline/metrics".

With this request, I was actually able to retrieve the information from the collector service with another GET request by the metric name. It seems, though, that the aggregator has averaged this information, and gave me a single average time. However, I'm interested in knowing the entire history of the data I'm sending, at every minute interval, for every node in my cluster. Is this possible with some configuration of the ambari-metrics collector? I've read through the options and made adjustments, but with no luck so far.

Again, I appreciate your help, or from any other help I receive here. Thank you!

Highlighted

Re: Custom metric names in Ambari-Metrics

Expert Contributor

It is true that AMS aggregates data across hosts in slices of 30 seconds. The AMS aggregation logic is being currently worked upon and refined.

If you wanted to get the raw data, please pass on the query param "hostname=<>" in your GET request. That should give the exact data that you POST to AMS.

Highlighted

Re: Custom metric names in Ambari-Metrics

Expert Contributor

You can use "precision=SECONDS" as a parameter to get fine grained data. Note: This is usually ok for past 2-4 hours of data. AMS does enforce a hard limit on how much raw data you can ask for in 1 request. You can also keep going back to past 24 hours in 1 hour chunks. Valid values for precision have been documented on the API page.

Don't have an account?
Coming from Hortonworks? Activate your account here