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.

Creating Custom Ambari Metrics

Highlighted

Creating Custom Ambari Metrics

New Contributor

Has anyone had any success in creating custom metrics from services not monitored by AMS? If so, how did you go about creating the JSON to send to the Ambari Metrics collector via API calls?

4 REPLIES 4

Re: Creating Custom Ambari Metrics

Super Mentor

@Greg Porter

You can post metrics JSON data to AMS using the following kind of API call:

# curl --header "Content-Type: application/json" -X POST http://$AMS_COLLECTOR:6188/ws/v1/timeline/metrics --data  @/tmp/metrics.json



Here you can use your application logic or (dummy data inside the "/tmp/metrics.json" file in the following format)

# cat /tmp/metrics.json
{
  "metrics": [
    {
      "metricname": "DummyService.some.metrics.abcdMetrics1",
      "appid": "ams-dummy-appid",
      "hostname": "hdfcluster1.example.com",
      "timestamp": 1548307991100,
      "starttime": 1548307991100,
      "metrics": {
        "1548307991100": 0.963781711428,
        "1548308000100": 1432075898000
      }
    },
    {
      "metricname": "DummyService.some.metrics.abcdMetrics2",
      "appid": "ams-dummy-appid",
      "hostname": "hdfcluster2.example.com",
      "timestamp": 1548307991101,
      "starttime": 1548307991101,
      "metrics": {
        "1548307991101": 0.963781711428,
        "1548308000101": 1432075898000
      }
    }
  ]
}

.

You can generate the 13 digits starttime using he following kind of linux command:

# echo `date +%s`000
1548308444000

.

Re: Creating Custom Ambari Metrics

Super Mentor

@Greg Porter Did it work ?

Re: Creating Custom Ambari Metrics

New Contributor

@Jay Kumar SenSharma no, unfortunately it did not work. I receive an output like this...

{"errors":[]}

Re: Creating Custom Ambari Metrics

Super Mentor